|
|||||||||
| Home >> All >> com >> eireneh >> bible >> [ passage overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.eireneh.bible.passage
Class PassageTally

java.lang.Objectcom.eireneh.bible.passage.AbstractPassage
com.eireneh.bible.passage.PassageTally
- All Implemented Interfaces:
- java.lang.Cloneable, Passage, PassageConstants, java.io.Serializable
- public class PassageTally
- extends AbstractPassage
Similar to a Passage, but that stores a ranking for each of the Verses that it contains.
TODO: Specify how passage ranks work. Currently there is no well defined spec for what the rank of a verse means - it is just an int. Since this number is expoed in 2 places (getNameAndTally() and getTallyFor()) we should specify what the numbers mean. Trouble is most tallies come from searches where the numbers only have relative meaning.
This class exactly implements the Passage interface when the ordering is set to ORDER_BIBLICAL, however an additional setting of ORDER_TALLY sorts the verses by the rank in this tally.
Calling tally.add(Gen 1:1); tally.add(Gen 1:1); is
redundant for a Passage however a PassageTally will increase the rank
of Gen 1:1, there are additional methods unAdd() and
unAddAll() that do the reverse, of decreasing the rank of
the specified verse(s).
The point is to allow a search for "God loves us, and gave Jesus to die to save us" to correctly identify John 3:16. So we are using fuzzy matching big style, but I think this will be very useful.
How should we rank VerseRanges? We could use a sum of the ranks of the verses in a range or the maximum value of a range. The former would seem to be more mathematically correct, but I think that the latter is better because: the concept of max value is preserved, because a wide blurred match is generally not as good as a sharply defined one.
Should we be going for a PassageTallyFactory type approach? Of the 3 implentations of Passage, The RangedPassage does not make sense here, and a PassageTally will not have the range of uses that a Passage has, so I think there is more likely to be a correct answer. So right now the answer is no.
Memory considerations: The BitSet approach will always use a
int[31000] = 128k of memory.
The Distinct approach will be n * int[4] where n is the number of
verses stored. I expect most searches to have at least n=1000. Also
128k
Given this, (A Distinct style PassageTally will usually use more
memory than a BitSet sytle PassageTally) And the intuative result
that the BitSet will be faster, I'm going to start by implementing
the latter only.
|
Distribution Licence: Project B is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. The License is available on the internet here, by writing to Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, Or locally at the Licence link below. The copyright to this program is held by it's authors. |
| Nested Class Summary | |
private class |
PassageTally.OrderedVerseEnumeration
Iterate over the Verses in order of their rank in the tally |
private class |
PassageTally.OrderedVerseRangeEnumeration
Iterate over the Ranges in order of their rank in the tally |
private class |
PassageTally.VerseEnumeration
Iterate over the Verses in normal verse order |
| Nested classes inherited from class com.eireneh.bible.passage.AbstractPassage |
AbstractPassage.VerseRangeEnumeration |
| Field Summary | |
private int[] |
board
The tallyboard itself |
protected static com.eireneh.util.Logger |
log
The log stream |
private int |
max
The maximum tally possible |
static int |
MAX_TALLY
The highest tally possible |
private int |
order
The maximum tally possible |
static int |
ORDER_BIBLICAL
Sort in Biblical order |
static int |
ORDER_TALLY
Sort in tally rank order |
| Fields inherited from class com.eireneh.bible.passage.AbstractPassage |
BITWISE, DISTINCT, listeners, METHOD_COUNT, original_name, RANGED, skip_normalization, suppress_events |
| Fields inherited from interface com.eireneh.bible.passage.PassageConstants |
ACCURACY_BOOK_CHAPTER, ACCURACY_BOOK_ONLY, ACCURACY_BOOK_VERSE, ACCURACY_CHAPTER_VERSE, ACCURACY_NONE, ACCURACY_VERSE_ONLY, CASE_LOWER, CASE_MIXED, CASE_SENTANCE, CASE_UPPER, CASES, RANGE_ALLOWED_DELIMS, RANGE_PREF_DELIM, REF_ALLOWED_DELIMS, REF_PREF_DELIM, RESTRICT_BOOK, RESTRICT_CHAPTER, RESTRICT_NONE, RESTRICTIONS, VERSE_ALLOWED_DELIMS, VERSE_END_MARK1, VERSE_END_MARK2, VERSE_NUMERIC_BOOK, VERSE_PREF_DELIM1, VERSE_PREF_DELIM2 |
| Constructor Summary | |
PassageTally()
Create an empty PassageTally |
|
PassageTally(java.lang.String refs)
Create a Verse from a human readable string. |
|
| Method Summary | |
void |
add(VerseBase that)
Add/Increment this verses in the rankings |
void |
addAll(Passage that)
Add/Increment these verses in the rankings |
private void |
alterVerseBase(VerseBase that,
int tally)
Increment/Decrement this verses in the rankings |
void |
blur(int verses,
int restrict)
Widen the range of the verses in this list. |
void |
clear()
Removes all of the Verses from this Passage. |
java.lang.Object |
clone()
Get a copy of ourselves. |
boolean |
contains(VerseBase that)
Does this tally contain all the specified verses? |
void |
flatten()
Take the verses in the tally and give them all and equal rank of 1. |
int |
getIndexOf(Verse verse)
What is the index of the give verse in the current ordering scheme |
java.lang.String |
getName()
A Human readable version of the PassageTally. |
java.lang.String |
getName(int max_count)
A Human readable version of the verse list. |
java.lang.String |
getNameAndTally()
A Human readable version of the PassageTally. |
java.lang.String |
getNameAndTally(int max_count)
A Human readable version of the PassageTally. |
int |
getOrdering()
Get how we sort the verses we output. |
int |
getTallyOf(Verse verse)
The ranking given to a specific verse |
private void |
increment(int ord,
int tally)
Increment a verse by an amount |
private void |
incrementMax(int tally)
Increment a verse by an amount |
private void |
kill(int ord)
Wipe the rank of the given verse to zero |
java.util.Enumeration |
rangeElements()
Iterate through the range elements in the current sort order |
void |
remove(VerseBase that)
Remove these verses from the rankings, ie, set their rank to zero. |
void |
removeAll(Passage that)
Remove/Decrement these verses in the rankings |
private void |
resetMax()
Sometimes we end up not knowing what the max is - this makes sure we know accurately |
void |
setOrdering(int order)
Set how we sort the verses we output. |
java.lang.String |
toString()
Simply bounce to getName() to help String concatenation. |
Passage |
trimVerses(int count)
Ensures that there are a maximum of count Verses in
this Passage. |
void |
unAdd(VerseBase that)
Remove/Decrement this verses in the rankings |
void |
unAddAll(Passage that)
Remove/Decrement these verses in the rankings |
java.util.Enumeration |
verseElements()
Iterate through the verse elements in the current sort order |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
ORDER_BIBLICAL
public static final int ORDER_BIBLICAL
- Sort in Biblical order
- See Also:
- Constant Field Values
ORDER_TALLY
public static final int ORDER_TALLY
- Sort in tally rank order
- See Also:
- Constant Field Values
MAX_TALLY
public static final int MAX_TALLY
- The highest tally possible
- See Also:
- Constant Field Values
board
private int[] board
- The tallyboard itself
max
private int max
- The maximum tally possible
order
private int order
- The maximum tally possible
log
protected static com.eireneh.util.Logger log
- The log stream
| Constructor Detail |
PassageTally
public PassageTally()
- Create an empty PassageTally
PassageTally
public PassageTally(java.lang.String refs) throws NoSuchVerseException
- Create a Verse from a human readable string. The opposite
of toString()
| Method Detail |
setOrdering
public void setOrdering(int order)
- Set how we sort the verses we output. The options are:
- ORDER_BIBLICAL: Natural Biblical order
- ORDER_TALLY: In an order specified by this class
getOrdering
public int getOrdering()
- Get how we sort the verses we output.
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
- Get a copy of ourselves.
- Specified by:
clonein interfacePassage- Overrides:
clonein classAbstractPassage
toString
public java.lang.String toString()
- Simply bounce to getName() to help String concatenation.
- Overrides:
toStringin classAbstractPassage
getName
public java.lang.String getName()
- A Human readable version of the PassageTally.
Uses short books names, and the shortest possible rendering eg "Mat 3:1-4"
- Specified by:
getNamein interfacePassage- Overrides:
getNamein classAbstractPassage
getName
public java.lang.String getName(int max_count)
- A Human readable version of the verse list. Uses short books names,
and the shortest possible rendering eg "Mat 3:1-4, 6"
getNameAndTally
public java.lang.String getNameAndTally()
- A Human readable version of the PassageTally.
Uses short books names, and the shortest possible rendering eg "Mat 3:1-4"
getNameAndTally
public java.lang.String getNameAndTally(int max_count)
- A Human readable version of the PassageTally.
Uses short books names, and the shortest possible rendering eg "Mat 3:1-4"
verseElements
public java.util.Enumeration verseElements()
- Iterate through the verse elements in the current sort order
rangeElements
public java.util.Enumeration rangeElements()
- Iterate through the range elements in the current sort order
- Specified by:
rangeElementsin interfacePassage- Overrides:
rangeElementsin classAbstractPassage
contains
public boolean contains(VerseBase that)
- Does this tally contain all the specified verses?
getTallyOf
public int getTallyOf(Verse verse)
- The ranking given to a specific verse
getIndexOf
public int getIndexOf(Verse verse)
- What is the index of the give verse in the current ordering scheme
add
public void add(VerseBase that)
- Add/Increment this verses in the rankings
unAdd
public void unAdd(VerseBase that)
- Remove/Decrement this verses in the rankings
remove
public void remove(VerseBase that)
- Remove these verses from the rankings, ie, set
their rank to zero.
addAll
public void addAll(Passage that)
- Add/Increment these verses in the rankings
- Specified by:
addAllin interfacePassage- Overrides:
addAllin classAbstractPassage
unAddAll
public void unAddAll(Passage that)
- Remove/Decrement these verses in the rankings
removeAll
public void removeAll(Passage that)
- Remove/Decrement these verses in the rankings
- Specified by:
removeAllin interfacePassage- Overrides:
removeAllin classAbstractPassage
clear
public void clear()
- Removes all of the Verses from this Passage.
- Specified by:
clearin interfacePassage- Overrides:
clearin classAbstractPassage
trimVerses
public Passage trimVerses(int count)
- Ensures that there are a maximum of
countVerses in this Passage. If there were more thancountVerses then a new Passage is created containing the Verses fromcount+1 onwards. If there was not greater thancountin the Passage, then the passage remains unchanged, and null is returned.- Specified by:
trimVersesin interfacePassage- Overrides:
trimVersesin classAbstractPassage
flatten
public void flatten()
- Take the verses in the tally and give them all and equal rank of 1.
After this method has executed then both sorting methods for a.
blur
public void blur(int verses,
int restrict)
- Widen the range of the verses in this list. This is primarily for
"find x within n verses of y" type applications.
- Specified by:
blurin interfacePassage- Overrides:
blurin classAbstractPassage
resetMax
private void resetMax()
- Sometimes we end up not knowing what the max is - this makes sure
we know accurately
alterVerseBase
private void alterVerseBase(VerseBase that, int tally)
- Increment/Decrement this verses in the rankings
increment
private final void increment(int ord,
int tally)
- Increment a verse by an amount
incrementMax
private final void incrementMax(int tally)
- Increment a verse by an amount
kill
private final void kill(int ord)
- Wipe the rank of the given verse to zero
|
|||||||||
| Home >> All >> com >> eireneh >> bible >> [ passage overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC