Mail::...TextCat(3pm)

πŸ’– NAME πŸ’–

okay so bestie, meet Mail::SpamAssassin::Plugin::TextCat β€” the TextCat language guesser πŸ¦‹, which lives in the User Contributed Perl Documentation under Mail::...TextCat(3pm). she reads your mail and goes "hmm what language is this" and honestly? she's usually right. slay.


🌸 SYNOPSIS 🌸

loadplugin     Mail::SpamAssassin::Plugin::TextCat

✨ DESCRIPTION ✨

This plugin will try to guess the language used in the message body text. lowkey a polyglot icon tbh πŸ—£οΈ

you can use the ok_languages directive to set which languages are considered okay for incoming mail, and if the guessed language is not okay, UNWANTED_LANGUAGE_BODY is triggered πŸ”₯. alternatively you can use the X-Languages metadata header directly in rules, if that's more your vibe.

it will always add the results to a X-Languages name-value pair in the message metadata data structure. this may be useful as Bayes tokens and can also be used in rules for scoring πŸ’…. the results can also be added to marked-up messages using add_header, with the _LANGUAGES_ tag. see Mail::SpamAssassin::Conf for details.

Note: the language cannot always be recognized with sufficient confidence. In that case, no action is taken. 😭 she's not gonna guess, she's gonna mind her business.

you can use the _TEXTCATRESULTS_ tag to view the internal ngram-scoring, it might help fine-tuning settings πŸ”.

examples of using X-Languages header directly in rules:

 header OK_LANGS X-Languages =~ /\ben\b/
 score OK_LANGS -1

 header BAD_LANGS X-Languages =~ /\b(?:ja|zh)\b/
 score BAD_LANGS 1

πŸŽ€ USER SETTINGS πŸŽ€


πŸ’œ ok_languages xx [ yy zz ... ] β€” default: all

This option is used to specify which languages are considered okay for incoming mail. SpamAssassin will try to detect the language used in the message body text.

Note that the language cannot always be recognized with sufficient confidence. In that case, no action is taken. no drama, no false accusations πŸ’€

The rule UNWANTED_LANGUAGE_BODY is triggered if none of the languages detected are in the "ok" list. note that this is the only effect of the "ok" list. it does not act as a welcomelist against any other form of spam scanning. she's not your bodyguard, she's just the language bouncer πŸšͺ

In your configuration, you must use the two or three letter language specifier in lowercase, not the English name for the language. you may also specify all if a desired language is not listed, or if you want to allow any language. the default setting is all.

Examples:

 ok_languages all         (allow all languages)
 ok_languages en          (only allow English)
 ok_languages en ja zh    (allow English, Japanese, and Chinese)
Note: if there are multiple ok_languages lines, only the last one is used. the others? ghosted. πŸ‘»

Select the languages to allow from the list below:

  • af β€” Afrikaans
  • am β€” Amharic
  • ar β€” Arabic
  • be β€” Byelorussian
  • bg β€” Bulgarian
  • bs β€” Bosnian
  • ca β€” Catalan
  • cs β€” Czech
  • cy β€” Welsh
  • da β€” Danish
  • de β€” German
  • el β€” Greek
  • en β€” English
  • eo β€” Esperanto
  • es β€” Spanish
  • et β€” Estonian
  • eu β€” Basque
  • fa β€” Persian
  • fi β€” Finnish
  • fr β€” French
  • fy β€” Frisian
  • ga β€” Irish Gaelic
  • gd β€” Scottish Gaelic
  • he β€” Hebrew
  • hi β€” Hindi
  • hr β€” Croatian
  • hu β€” Hungarian
  • hy β€” Armenian
  • id β€” Indonesian
  • is β€” Icelandic
  • it β€” Italian
  • ja β€” Japanese
  • ka β€” Georgian
  • ko β€” Korean
  • la β€” Latin
  • lt β€” Lithuanian
  • lv β€” Latvian
  • mr β€” Marathi
  • ms β€” Malay
  • ne β€” Nepali
  • nl β€” Dutch
  • no β€” Norwegian
  • pl β€” Polish
  • pt β€” Portuguese
  • qu β€” Quechua
  • rm β€” Rhaeto-Romance
  • ro β€” Romanian
  • ru β€” Russian
  • sa β€” Sanskrit
  • sco β€” Scots
  • sk β€” Slovak
  • sl β€” Slovenian
  • sq β€” Albanian
  • sr β€” Serbian
  • sv β€” Swedish
  • sw β€” Swahili
  • ta β€” Tamil
  • th β€” Thai
  • tl β€” Tagalog
  • tr β€” Turkish
  • uk β€” Ukrainian
  • vi β€” Vietnamese
  • yi β€” Yiddish
  • zh β€” Chinese (both Traditional and Simplified)
  • zh.big5 β€” Chinese (Traditional only)
  • zh.gb2312 β€” Chinese (Simplified only)

πŸ¦‹ inactive_languages xx [ yy zz ... ] β€” default: see below

This option is used to specify which languages will not be considered when trying to guess the language. for performance reasons, supported languages that have fewer than about 5 million speakers are disabled by default 🚫. note that listing a language in ok_languages automatically enables it for that user β€” so if you name it, she'll run it. ✨

The default setting is:

 bs cy eo et eu fy ga gd is la lt lv rm sa sco sl yi

That list is Bosnian, Welsh, Esperanto, Estonian, Basque, Frisian, Irish Gaelic, Scottish Gaelic, Icelandic, Latin, Lithuanian, Latvian, Rhaeto-Romance, Sanskrit, Scots, Slovenian, and Yiddish.


πŸ’… textcat_max_languages N β€” default: 3

The maximum number of languages any one message can simultaneously match before its classification is considered unknown. you can try reducing this to 2 or possibly even 1 for more confident results, as it's unusual for a message to contain multiple languages 🀨.

Read description for textcat_acceptable_score also, as these settings are closely related. scoring affects how many languages might be matched and here we set the "false positive limit" where we think the engine can't decide what languages message really contain. she's like "girl pick a language" 😭


🌈 textcat_optimal_ngrams N β€” default: 0

If the number of ngrams is lower than this number then they will be removed. this can be used to speed up the program for longer inputs ⚑. for shorter inputs, this should be set to 0.


πŸ“ textcat_max_ngrams N β€” default: 400

The maximum number of ngrams that should be compared with each of the languages models (note that each of those models is used completely). no shortcuts, full model, every time πŸ’―


πŸ‘‘ textcat_acceptable_score N β€” default: 1.02

Include any language that scores at least textcat_acceptable_score in the returned list of languages.

This setting is basically a percentile range. any language having internal ngram-score within N-percent of the best score is included into results. larger values than 1.05 are not recommended as it can generate many false matches 🚨. a setting of 1.00 would mean a single best scoring language is always forcibly selected, but this is not recommended as then textcat_max_languages can't do its job classifying language as uncertain.

Read the description for textcat_max_languages, as these are settings are closely related.

You can use the _TEXTCATRESULTS_ tag to view the internal ngram-scoring, it might help fine-tuning settings πŸ”.


and that's the whole page bestie, no cap, every flag accounted for 🫢 this icon was documented as part of perl v5.40.1, dated 2026-07-23 β€” Mail::...TextCat(3pm), signing off πŸ’–βœ¨

πŸ“¦ where this page comes from