I. Termhashperfield.add () method
This chapter goes on to the above, and in the previous chapter the Termhashperfield.add () method is the process of adding a term to the posting table, so I'll analyze the Add () method from the perspective of the algorithm:
final char[] tokenText = termAtt.termBuffer();;
final int tokenTextLen = termAtt.termLength();
The main thing to do in these two lines is to get the content and length of the words that are currently being parsed.
int downto = tokentextlen
int code = 0;
while (Downto > 0) {
Char ch = tokentext[--downto];
if (ch >= unicodeutil.uni_sur_low_start && ch <= unicodeutil.uni_sur_low_end) {
if (0 = down To) {
//unpaired
ch = tokentext[downto] = Unicodeutil.uni_replacement_char;
else {
Final char CH2 = tokentext[downto-1];
if (CH2 >= unicodeutil.uni_sur_high_start && CH2 <= unicodeutil.uni_sur_high_end) {
//Ok:high fol Lowed by the low. This is a valid
//surrogate pair.
Code = ((code*31) + ch) *31+ch2;
downto--;
Continue;
} else {
//unpaired
ch = tokentext[downto] = Unicodeutil.uni_replacement_char;
'
}
' Else if (ch >= unicodeutil.uni_sur_high_start && (ch <= unicodeutil.uni_sur_high_end | |
ch = = 0xFFFF)) {
//unpaired or 0xffff
ch = tokentext[Downto] = Unicodeutil.uni_replacement_char;
}
Code = (code*31) + ch;
}