Use this one. Hints are collected into a struct. Flags are passed in (normally zero). Also returns 3 internal language scores as a ratio to normal score for real text in that language. Scores close to 1.0 indicate normal text, while scores far away from 1.0 indicate badly-skewed text or gibberish Returns a vector of chunks in different languages, so that caller may spell-check, translate, or ot
| 315 | // bytes that are valid UTF-8. If this is < buffer_length, there is invalid |
| 316 | // input starting at the following byte. |
| 317 | Language ExtDetectLanguageSummaryCheckUTF8( |
| 318 | const char* buffer, |
| 319 | int buffer_length, |
| 320 | bool is_plain_text, |
| 321 | const CLDHints* cld_hints, |
| 322 | int flags, |
| 323 | Language* language3, |
| 324 | int* percent3, |
| 325 | double* normalized_score3, |
| 326 | ResultChunkVector* resultchunkvector, |
| 327 | int* text_bytes, |
| 328 | bool* is_reliable, |
| 329 | int* valid_prefix_bytes) { |
| 330 | *valid_prefix_bytes = SpanInterchangeValid(buffer, buffer_length); |
| 331 | if (*valid_prefix_bytes < buffer_length) { |
| 332 | *is_reliable = false; |
| 333 | return UNKNOWN_LANGUAGE; |
| 334 | } |
| 335 | |
| 336 | bool allow_extended_lang = true; |
| 337 | Language plus_one = UNKNOWN_LANGUAGE; |
| 338 | |
| 339 | Language lang = DetectLanguageSummaryV2( |
| 340 | buffer, |
| 341 | buffer_length, |
| 342 | is_plain_text, |
| 343 | cld_hints, |
| 344 | allow_extended_lang, |
| 345 | flags, |
| 346 | plus_one, |
| 347 | language3, |
| 348 | percent3, |
| 349 | normalized_score3, |
| 350 | resultchunkvector, |
| 351 | text_bytes, |
| 352 | is_reliable); |
| 353 | // Do not default to English |
| 354 | return lang; |
| 355 | } |
| 356 | |
| 357 | // Use this one ONLY if you can prove the the input text is valid UTF-8 by |
| 358 | // design because it went through a known-good conversion program. |