MCPcopy Create free account
hub / github.com/aboSamoor/pycld2 / ScoreOneScriptSpan

Function ScoreOneScriptSpan

cld2/internal/scoreonescriptspan.cc:1302–1333  ·  view source on GitHub ↗

Score one scriptspan into doc_tote and vec, updating scoringcontext Inputs: One scriptspan of perhaps 40-60KB, all same script lower-case letters and single ASCII spaces. First character is a space to allow simple begining-of-word detect. End of buffer has three spaces and NUL to allow easy scan-to-end-of-word. Scoring context of scoring tables flags running boosts Outputs: Updated doc_tote giving

Source from the content-addressed store, hash-verified

1300// the next-level-down routines.
1301//
1302void ScoreOneScriptSpan(const LangSpan& scriptspan,
1303 ScoringContext* scoringcontext,
1304 DocTote* doc_tote,
1305 ResultChunkVector* vec) {
1306 if (scoringcontext->flags_cld2_verbose) {
1307 fprintf(scoringcontext->debug_file, "<br>ScoreOneScriptSpan(%s,%d) ",
1308 ULScriptCode(scriptspan.ulscript), scriptspan.text_bytes);
1309 // Optionally print the chunk lowercase letters/marks text
1310 string temp(&scriptspan.text[0], scriptspan.text_bytes);
1311 fprintf(scoringcontext->debug_file, "'%s'",
1312 GetHtmlEscapedText(temp).c_str());
1313 fprintf(scoringcontext->debug_file, "<br>\n");
1314 }
1315 scoringcontext->prior_chunk_lang = UNKNOWN_LANGUAGE;
1316 scoringcontext->oldest_distinct_boost = 0;
1317 ULScriptRType rtype = ULScriptRecognitionType(scriptspan.ulscript);
1318 if (scoringcontext->flags_cld2_score_as_quads && (rtype != RTypeCJK)) {
1319 rtype = RTypeMany;
1320 }
1321 switch (rtype) {
1322 case RTypeNone:
1323 case RTypeOne:
1324 ScoreEntireScriptSpan(scriptspan, scoringcontext, doc_tote, vec);
1325 break;
1326 case RTypeCJK:
1327 ScoreCJKScriptSpan(scriptspan, scoringcontext, doc_tote, vec);
1328 break;
1329 case RTypeMany:
1330 ScoreQuadScriptSpan(scriptspan, scoringcontext, doc_tote, vec);
1331 break;
1332 }
1333}
1334
1335} // End namespace CLD2
1336

Callers 1

DetectLanguageSummaryV2Function · 0.85

Calls 6

ULScriptCodeFunction · 0.85
ULScriptRecognitionTypeFunction · 0.85
ScoreEntireScriptSpanFunction · 0.85
ScoreCJKScriptSpanFunction · 0.85
ScoreQuadScriptSpanFunction · 0.85
GetHtmlEscapedTextFunction · 0.70

Tested by

no test coverage detected