Score RTypeMany scriptspan into doc_tote and vec, updating scoringcontext We have a scriptspan with all lowercase text in one script. Look up quadgrams and octagrams, saving the hits in three parallel vectors. Score from those vectors in chunks, toting each chunk to get a single language, and combining into the overall document score. The hit vectors in general are not big enough to handle and ent
| 1229 | // Returns updated doc_tote |
| 1230 | // If vec != NULL, appends to that vector of ResultChunk's |
| 1231 | void ScoreQuadScriptSpan(const LangSpan& scriptspan, |
| 1232 | ScoringContext* scoringcontext, |
| 1233 | DocTote* doc_tote, |
| 1234 | ResultChunkVector* vec) { |
| 1235 | // Allocate three parallel arrays of scoring hits |
| 1236 | ScoringHitBuffer* hitbuffer = new ScoringHitBuffer; |
| 1237 | hitbuffer->init(); |
| 1238 | hitbuffer->ulscript = scriptspan.ulscript; |
| 1239 | |
| 1240 | scoringcontext->prior_chunk_lang = UNKNOWN_LANGUAGE; |
| 1241 | scoringcontext->oldest_distinct_boost = 0; |
| 1242 | |
| 1243 | // Incoming scriptspan has a single leading space at scriptspan.text[0] |
| 1244 | // and three trailing spaces then NUL at scriptspan.text[text_bytes + 0/1/2/3] |
| 1245 | |
| 1246 | int letter_offset = 1; // Skip initial space |
| 1247 | hitbuffer->lowest_offset = letter_offset; |
| 1248 | int letter_limit = scriptspan.text_bytes; |
| 1249 | while (letter_offset < letter_limit) { |
| 1250 | // |
| 1251 | // Fill up one hitbuffer, possibly splicing onto previous fragment |
| 1252 | // |
| 1253 | // NOTE: GetQuadHits deals with close repeats |
| 1254 | // NOTE: After last chunk there is always a hitbuffer entry with an offset |
| 1255 | // just off the end of the text = next_offset. |
| 1256 | int next_offset = GetQuadHits(scriptspan.text, letter_offset, letter_limit, |
| 1257 | scoringcontext, hitbuffer); |
| 1258 | // If true, there is more text to process in this scriptspan |
| 1259 | // NOTE: GetOctaHitVectors deals with close repeats, |
| 1260 | // does one hash and two lookups (delta and distinct) per word |
| 1261 | GetOctaHits(scriptspan.text, letter_offset, next_offset, |
| 1262 | scoringcontext, hitbuffer); |
| 1263 | |
| 1264 | // |
| 1265 | // Score one hitbuffer in chunks to summarybuffer |
| 1266 | // |
| 1267 | bool more_to_come = next_offset < letter_limit; |
| 1268 | bool score_cjk = false; |
| 1269 | ProcessHitBuffer(scriptspan, letter_offset, scoringcontext, doc_tote, vec, |
| 1270 | more_to_come, score_cjk, hitbuffer); |
| 1271 | SpliceHitBuffer(hitbuffer, next_offset); |
| 1272 | |
| 1273 | letter_offset = next_offset; |
| 1274 | } |
| 1275 | |
| 1276 | delete hitbuffer; |
| 1277 | } |
| 1278 | |
| 1279 | |
| 1280 | // Score one scriptspan into doc_tote and vec, updating scoringcontext |
no test coverage detected