}
if (!ret) {
- if (part->nwords < default_short_text_limit) {
+ if (part->utf_words->len < default_short_text_limit) {
r = rs_detect_none;
msg_debug_lang_det ("text is too short for trigramms detection: "
"%d words; at least %d words required",
- (int)part->nwords,
+ (int)part->utf_words->len,
(int)default_short_text_limit);
- rspamd_language_detector_set_language (task, part, "en");
+ switch (cat) {
+ case RSPAMD_LANGUAGE_CYRILLIC:
+ rspamd_language_detector_set_language (task, part, "ru");
+ break;
+ case RSPAMD_LANGUAGE_DEVANAGARI:
+ rspamd_language_detector_set_language (task, part, "hi");
+ break;
+ case RSPAMD_LANGUAGE_ARAB:
+ rspamd_language_detector_set_language (task, part, "ar");
+ break;
+ default:
+ case RSPAMD_LANGUAGE_LATIN:
+ rspamd_language_detector_set_language (task, part, "en");
+ break;
+ }
+ msg_debug_lang_det ("set %s language based on symbols category",
+ part->language);
+
candidates = kh_init (rspamd_candidates_hash);
}
else {