public class TextSnippet extends java.lang.Object implements java.lang.Comparable<TextSnippet>, java.util.Comparator<TextSnippet>
Modifier and Type | Class and Description |
---|---|
static class |
TextSnippet.Cache |
static class |
TextSnippet.ResultClass |
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
descriptionline |
private java.lang.String |
error |
private int |
hashCache |
private boolean |
isMarked |
private java.lang.String |
line |
private static int |
MAX_CACHE |
private static java.util.regex.Pattern |
p1
\\A[^\\p{L}\\p{N}].+ |
private static java.util.regex.Pattern |
p2
.+[^\\p{L}\\p{N}]\\Z |
private static java.util.regex.Pattern |
p3
\\A[\\p{L}\\p{N}]+[^\\p{L}\\p{N}].+\\Z
updated to \\A([\\p{L}\\p{N}]+[^\\p{L}\\p{N}].+)([\\p{N}]+[.,][\\p{N}])+\\Z
to detect words with none alphanumeric chars (1) allow comma/dot surrounded by number (2) |
private static java.util.regex.Pattern |
p4
[^\\p{L}\\p{N}] |
private TextSnippet.ResultClass |
resultStatus |
static TextSnippet.Cache |
snippetsCache |
private static java.util.regex.Pattern |
SPLIT_PATTERN |
private byte[] |
urlhash |
Constructor and Description |
---|
TextSnippet(byte[] urlhash,
java.lang.String line,
boolean isMarked,
TextSnippet.ResultClass errorCode,
java.lang.String errortext) |
TextSnippet(LoaderDispatcher loader,
URIMetadataNode row,
HandleSet queryhashes,
CacheStrategy cacheStrategy,
boolean pre,
int snippetMaxLength,
boolean reindexing) |
Modifier and Type | Method and Description |
---|---|
int |
compare(TextSnippet o1,
TextSnippet o2) |
int |
compareTo(TextSnippet o) |
java.lang.String |
descriptionline(QueryGoal queryGoal)
Snippet line formatted/encoded for display in browser
possible html code in raw line is html encoded
query words marked by ..
|
boolean |
exists() |
java.lang.String |
getError() |
TextSnippet.ResultClass |
getErrorCode() |
java.lang.String |
getLineMarked(QueryGoal queryGoal)
Marks all words in current line which have the same
hash values as the ones contained in argument.
|
java.lang.String |
getLineRaw() |
private static java.lang.String |
getWordMarked(java.lang.String word,
java.util.Set<byte[]> queryHashes)
Marks words with <b>-tags.
|
int |
hashCode() |
private void |
init(byte[] urlhash,
java.lang.String line,
boolean isMarked,
TextSnippet.ResultClass errorCode,
java.lang.String errortext)
Init a snippet line for urlhash
|
boolean |
isMarked() |
private static void |
removeMatchingHashes(java.lang.String sentence,
HandleSet queryhashes) |
java.lang.String |
toString() |
private static final int MAX_CACHE
private static final java.util.regex.Pattern p1
\\A[^\\p{L}\\p{N}].+
private static final java.util.regex.Pattern p2
.+[^\\p{L}\\p{N}]\\Z
private static final java.util.regex.Pattern p3
\\A[\\p{L}\\p{N}]+[^\\p{L}\\p{N}].+\\Z
updated to \\A([\\p{L}\\p{N}]+[^\\p{L}\\p{N}].+)([\\p{N}]+[.,][\\p{N}])+\\Z
to detect words with none alphanumeric chars (1) allow comma/dot surrounded by number (2)private static final java.util.regex.Pattern p4
[^\\p{L}\\p{N}]
public static final TextSnippet.Cache snippetsCache
private byte[] urlhash
private java.lang.String line
private boolean isMarked
private java.lang.String error
private TextSnippet.ResultClass resultStatus
private static final java.util.regex.Pattern SPLIT_PATTERN
private java.lang.String descriptionline
private int hashCache
public TextSnippet(byte[] urlhash, java.lang.String line, boolean isMarked, TextSnippet.ResultClass errorCode, java.lang.String errortext)
public TextSnippet(LoaderDispatcher loader, URIMetadataNode row, HandleSet queryhashes, CacheStrategy cacheStrategy, boolean pre, int snippetMaxLength, boolean reindexing)
private void init(byte[] urlhash, java.lang.String line, boolean isMarked, TextSnippet.ResultClass errorCode, java.lang.String errortext)
urlhash
- hash of the url for this snippetline
- text to use as snippetisMarked
- true if query words already marked in input texterrorCode
- errortext
- public boolean exists()
public boolean isMarked()
public java.lang.String getLineRaw()
public java.lang.String getError()
public TextSnippet.ResultClass getErrorCode()
public java.lang.String getLineMarked(QueryGoal queryGoal)
queryHashes
- hashes of search wordspublic java.lang.String descriptionline(QueryGoal queryGoal)
queryGoal
- public int compareTo(TextSnippet o)
compareTo
in interface java.lang.Comparable<TextSnippet>
public int compare(TextSnippet o1, TextSnippet o2)
compare
in interface java.util.Comparator<TextSnippet>
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
private static java.lang.String getWordMarked(java.lang.String word, java.util.Set<byte[]> queryHashes)
word
- the word to markqueryHashes
- hashes of the words to mark#getLineMarked(Set)
private static void removeMatchingHashes(java.lang.String sentence, HandleSet queryhashes)