|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.labs.minion.retrieval.PassageImpl
public class PassageImpl
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.sun.labs.minion.Passage |
---|
Passage.Type |
Field Summary | |
---|---|
protected int |
charSize
The size of the passage, in characters. |
protected int |
context
The amount of context to keep. |
protected java.lang.String |
elidedHLValue
The elided passage, highlighted. |
protected java.lang.String |
elidedUnHLValue
The elided passage, unhighlighted. |
protected int |
end
The end of the range we want to collect for this passage. |
protected boolean |
finished
Whether we're finished collecting this field. |
protected java.lang.String |
fullHLValue
The full passage, highlighted. |
protected java.lang.String |
fullUnHLValue
The full passage, unhighlighted. |
protected static java.lang.String |
logTag
|
protected int |
maxSize
The maximum length, in characters, of any highlighted passage that we'll return. |
protected java.lang.String[] |
mt
The terms from the document matching the query terms. |
protected float |
penalty
The penalty score associated with this passage. |
protected int[] |
posns
The word numbers associated with this passage. |
protected java.lang.String[] |
qt
The query terms making up this passage. |
protected int |
size
The size of the passage, in tokens. |
protected int |
start
The start of the range we want to collect for this passage. |
protected int[] |
tokenEnds
The list of ending positions for the highlighted tokens in this passage |
protected int[] |
tokenPosns
The positions in the tokens array of the words
associated with this passage. |
protected Token[] |
tokens
The tokens and punctuation making up this passage, collected while parsing the document. |
protected int[] |
tokenStarts
The list of starting positions for the highlighted tokens in this passage |
Constructor Summary | |
---|---|
PassageImpl(int[] posns,
float penalty,
java.lang.String[] qt,
int context,
int maxSize)
Creates a passage for the given set of positions. |
Method Summary | |
---|---|
protected boolean |
add(Token t)
Tries to add a token to this passage. |
int |
compareTo(java.lang.Object o)
|
java.lang.String |
elide(PassageHighlighter ph,
boolean htmlEncode)
Creates a string from a set of tokens that does not exceed the given length. |
protected PassageImpl |
endField()
Tells us that our field has ended. |
java.lang.String |
getHLValue()
Gets the highlighted value for this passage. |
java.lang.String |
getHLValue(boolean elided)
Gets the highlighted value for this passage. |
int[] |
getMatchEnd()
Gets the ending character positions in the document for the terms that make up the passage. |
java.lang.String[] |
getMatchingTerms()
Gets the terms from the passage that match the terms in the query. |
int[] |
getMatchStart()
Gets the starting character positions in the document for the terms that make up the passage. |
float |
getScore()
Gets the penalty score associated with this passage. |
java.lang.String |
getUnHLValue(boolean elided)
Gets the unhighlighted value for this passage. |
int[] |
getWordPositions()
Gets the character positions of the passage words in the higlighted passage string that was returned earlier. |
java.lang.String |
highlight(PassageHighlighter highlighter)
Marks up the passage using the highlighter. |
java.lang.String |
highlight(PassageHighlighter highlighter,
boolean htmlEncode)
Marks up the passage using the highlighter. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected float penalty
protected java.lang.String[] qt
protected java.lang.String[] mt
protected int[] posns
protected int[] tokenPosns
tokens
array of the words
associated with this passage.
protected int[] tokenStarts
protected int[] tokenEnds
protected int context
protected int start
protected int end
protected int size
protected int charSize
protected int maxSize
protected boolean finished
protected Token[] tokens
protected java.lang.String fullHLValue
protected java.lang.String fullUnHLValue
protected java.lang.String elidedHLValue
protected java.lang.String elidedUnHLValue
protected static java.lang.String logTag
Constructor Detail |
---|
public PassageImpl(int[] posns, float penalty, java.lang.String[] qt, int context, int maxSize)
posns
- The word positions of the terms making up the passage.penalty
- The penalty associated with this passage.qt
- The terms used in the query.context
- The size of the surrounding context to put in the
passage, in words. -1 means take the entire containing field.maxSize
- The maximum length, in characters, of any highlighted
passage that we will return. -1 means that there is no maximum
length.Method Detail |
---|
public float getScore()
getScore
in interface Passage
protected boolean add(Token t)
t
- The token to try to add.protected PassageImpl endField()
public java.lang.String highlight(PassageHighlighter highlighter, boolean htmlEncode)
Passage
highlight
in interface Passage
highlighter
- The highlighter that will be used to mark up the
passage. If this is null
no highlighting will be
done.htmlEncode
- If true
the highlighted passage will
have its text HTML encoded so that it may be safely given to a Web
browser.
Passage.getHLValue(boolean)
,
Passage.getUnHLValue(boolean)
public java.lang.String highlight(PassageHighlighter highlighter)
Passage
highlight
in interface Passage
highlighter
- The highlighter that will be used to mark up the
passage. If this is null
no highlighting will be
done.
Passage.getHLValue(boolean)
,
Passage.getUnHLValue(boolean)
public java.lang.String getHLValue()
Passage
getHLValue
in interface Passage
public java.lang.String getHLValue(boolean elided)
Passage
getHLValue
in interface Passage
elided
- If true
returns the passage cut down to
the size specified when the passages were made. If
false
the unelided, highlighted passage is returned.
public java.lang.String getUnHLValue(boolean elided)
Passage
getUnHLValue
in interface Passage
elided
- If true
returns the passage cut down to
the size specified when the passages were made. If
false
the unelided, unhighlighted passage is returned.
public java.lang.String elide(PassageHighlighter ph, boolean htmlEncode)
The basic idea: produce the passage in chunks centered around the hit terms. Begin with chunks that are just the hit terms and then at each step, add tokens before and after the hit terms until the string length limit is reached.
ph
- the highlighter to use on the passagehtmlEncode
- whether the string should be HTML encoded while highlighting
public int[] getWordPositions()
getWordPositions
in interface Passage
public java.lang.String[] getMatchingTerms()
getMatchingTerms
in interface Passage
null
, then
that means that a term is missing from the passage.public int[] getMatchStart()
getMatchStart
in interface Passage
public int[] getMatchEnd()
getMatchEnd
in interface Passage
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |