MCPcopy Create free account
hub / github.com/acking-you/static_flow / detect_language

Function detect_language

crates/embedding/src/text.rs:136–142  ·  view source on GitHub ↗

Detect language with a lightweight heuristic. If the input contains any CJK character, we treat it as Chinese; otherwise default to English. This avoids external dependencies and keeps decisions local and deterministic.

(text: &str)

Source from the content-addressed store, hash-verified

134/// default to English. This avoids external dependencies and keeps decisions
135/// local and deterministic.
136pub fn detect_language(text: &str) -> TextEmbeddingLanguage {
137 if text.chars().any(is_cjk) {
138 TextEmbeddingLanguage::Chinese
139 } else {
140 TextEmbeddingLanguage::English
141 }
142}
143
144fn is_cjk(ch: char) -> bool {
145 matches!(

Callers 8

search_songs_semanticMethod · 0.85
backfill_song_vectorsMethod · 0.85
runFunction · 0.85
runFunction · 0.85
sync_notesFunction · 0.85

Calls

no outgoing calls