Skip to main content

detect_primary_script

Function detect_primary_script 

Source
pub fn detect_primary_script(text: &str) -> &'static str
Expand description

Detects the probable script of text based on the most common script

This is a simple heuristic approach that can be useful for adjusting text density calculations based on script properties

§Arguments

  • text - The text to analyze

§Returns

A string representing the most common script in the text

§Examples

use dom_content_extraction::unicode::detect_primary_script;

assert_eq!(detect_primary_script("Hello world"), "Latin");
assert_eq!(detect_primary_script("こんにちは世界"), "Han");