Skip to main content

detect_code_switching

Function detect_code_switching 

Source
pub fn detect_code_switching(text: &str) -> Vec<(Language, usize, usize)>
Expand description

Detect code-switching (mixed languages) in text.

Returns a vector of language segments with their positions. Useful for processing multilingual text where languages switch mid-sentence.

§Example

use anno::lang::{detect_code_switching, Language};

let segments = detect_code_switching("Dr. 田中 presented at MIT's conference.");
// Returns: [(Language::English, 0, 4), (Language::Japanese, 5, 7), (Language::English, 8, 40)]