Score RTypeCJK scriptspan into doc_tote and vec, updating scoringcontext
| 1161 | |
| 1162 | // Score RTypeCJK scriptspan into doc_tote and vec, updating scoringcontext |
| 1163 | void ScoreCJKScriptSpan(const LangSpan& scriptspan, |
| 1164 | ScoringContext* scoringcontext, |
| 1165 | DocTote* doc_tote, |
| 1166 | ResultChunkVector* vec) { |
| 1167 | // Allocate three parallel arrays of scoring hits |
| 1168 | ScoringHitBuffer* hitbuffer = new ScoringHitBuffer; |
| 1169 | hitbuffer->init(); |
| 1170 | hitbuffer->ulscript = scriptspan.ulscript; |
| 1171 | |
| 1172 | scoringcontext->prior_chunk_lang = UNKNOWN_LANGUAGE; |
| 1173 | scoringcontext->oldest_distinct_boost = 0; |
| 1174 | |
| 1175 | // Incoming scriptspan has a single leading space at scriptspan.text[0] |
| 1176 | // and three trailing spaces then NUL at scriptspan.text[text_bytes + 0/1/2/3] |
| 1177 | |
| 1178 | int letter_offset = 1; // Skip initial space |
| 1179 | hitbuffer->lowest_offset = letter_offset; |
| 1180 | int letter_limit = scriptspan.text_bytes; |
| 1181 | while (letter_offset < letter_limit) { |
| 1182 | if (scoringcontext->flags_cld2_verbose) { |
| 1183 | fprintf(scoringcontext->debug_file, " ScoreCJKScriptSpan[%d,%d)<br>\n", |
| 1184 | letter_offset, letter_limit); |
| 1185 | } |
| 1186 | // |
| 1187 | // Fill up one hitbuffer, possibly splicing onto previous fragment |
| 1188 | // |
| 1189 | // NOTE: GetUniHits deals with close repeats |
| 1190 | // NOTE: After last chunk there is always a hitbuffer entry with an offset |
| 1191 | // just off the end of the text = next_offset. |
| 1192 | int next_offset = GetUniHits(scriptspan.text, letter_offset, letter_limit, |
| 1193 | scoringcontext, hitbuffer); |
| 1194 | // NOTE: GetBiHitVectors deals with close repeats, |
| 1195 | // does one hash and two lookups (delta and distinct) per word |
| 1196 | GetBiHits(scriptspan.text, letter_offset, next_offset, |
| 1197 | scoringcontext, hitbuffer); |
| 1198 | |
| 1199 | // |
| 1200 | // Score one hitbuffer in chunks to summarybuffer |
| 1201 | // |
| 1202 | bool more_to_come = next_offset < letter_limit; |
| 1203 | bool score_cjk = true; |
| 1204 | ProcessHitBuffer(scriptspan, letter_offset, scoringcontext, doc_tote, vec, |
| 1205 | more_to_come, score_cjk, hitbuffer); |
| 1206 | SpliceHitBuffer(hitbuffer, next_offset); |
| 1207 | |
| 1208 | letter_offset = next_offset; |
| 1209 | } |
| 1210 | |
| 1211 | delete hitbuffer; |
| 1212 | // Context across buffers is not connected yet |
| 1213 | scoringcontext->prior_chunk_lang = UNKNOWN_LANGUAGE; |
| 1214 | } |
| 1215 | |
| 1216 | |
| 1217 |
no test coverage detected