Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

12.2 KB
Raw Blame
// Code generated by laya-go/scripts/gen_tables.py from laya/lang.py; DO NOT EDIT.
//
// Regenerate with: python laya-go/scripts/gen_tables.py

package lang

// The named non-Latin scripts, in the order lang.py declares them.
const (
	ScriptGreek      Script = "greek"
	ScriptCyrillic   Script = "cyrillic"
	ScriptArmenian   Script = "armenian"
	ScriptHebrew     Script = "hebrew"
	ScriptArabic     Script = "arabic"
	ScriptDevanagari Script = "devanagari"
	ScriptBengali    Script = "bengali"
	ScriptGurmukhi   Script = "gurmukhi"
	ScriptGujarati   Script = "gujarati"
	ScriptOriya      Script = "oriya"
	ScriptTamil      Script = "tamil"
	ScriptTelugu     Script = "telugu"
	ScriptKannada    Script = "kannada"
	ScriptMalayalam  Script = "malayalam"
	ScriptSinhala    Script = "sinhala"
	ScriptThai       Script = "thai"
	ScriptLao        Script = "lao"
	ScriptTibetan    Script = "tibetan"
	ScriptMyanmar    Script = "myanmar"
	ScriptGeorgian   Script = "georgian"
	ScriptEthiopic   Script = "ethiopic"
	ScriptKhmer      Script = "khmer"
	ScriptHangul     Script = "hangul"
	ScriptKana       Script = "kana"
	ScriptHan        Script = "han"
)

// scriptNames indexes those scripts by their position in lang.py's table.
var scriptNames = [...]Script{ScriptGreek, ScriptCyrillic, ScriptArmenian, ScriptHebrew, ScriptArabic, ScriptDevanagari, ScriptBengali, ScriptGurmukhi, ScriptGujarati, ScriptOriya, ScriptTamil, ScriptTelugu, ScriptKannada, ScriptMalayalam, ScriptSinhala, ScriptThai, ScriptLao, ScriptTibetan, ScriptMyanmar, ScriptGeorgian, ScriptEthiopic, ScriptKhmer, ScriptHangul, ScriptKana, ScriptHan}

// scriptLookup is every script range sorted by code point, as inclusive lo, hi
// pairs; scriptLookupIndex names the script each pair belongs to. They replace
// lang.py's ordered scan, which they equal because no two ranges overlap (the
// generator refuses an overlap).
var scriptLookup = [...]rune{
	880, 1023, 1024, 1327, 1328, 1423, 1424, 1535, 1536, 1791, 1872, 1919, 2208, 2303, 2304, 2431,
	2432, 2559, 2560, 2687, 2688, 2815, 2816, 2943, 2944, 3071, 3072, 3199, 3200, 3327, 3328, 3455,
	3456, 3583, 3584, 3711, 3712, 3839, 3840, 4095, 4096, 4255, 4256, 4351, 4352, 4607, 4608, 4991,
	6016, 6143, 7936, 8191, 11744, 11775, 12352, 12447, 12448, 12543, 12592, 12687, 12784, 12799,
	13312, 19903, 19968, 40959, 42560, 42655, 43232, 43263, 44032, 55215, 63744, 64255, 64336, 65023,
	65136, 65279,
}

var scriptLookupIndex = [...]uint8{
	0, 1, 2, 3, 4, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 22, 20, 21, 0, 1, 23,
	23, 22, 23, 24, 24, 1, 5, 22, 24, 4, 4,
}

const scriptMaxCodePoint = 0xfeff

// stopLists are the function words per language, in the order lang.py declares them:
// the language that wins a tied score is the first one listed.
var stopLists = [...]stopList{
	{"en", newSet("after", "already", "always", "and", "any", "are", "aren", "as", "at", "be", "because", "been", "before", "being", "between", "both", "but", "can", "could", "couldn", "didn", "didnt", "does", "doesn", "doesnt", "doing", "done", "dont", "down", "during", "each", "ever", "every", "few", "for", "from", "has", "hasn", "have", "haven", "havent", "here", "him", "his", "how", "i", "if", "in", "into", "is", "isn", "isnt", "it", "ive", "many", "might", "much", "must", "never", "nor", "not", "of", "on", "only", "onto", "our", "please", "shall", "she", "should", "some", "than", "that", "thats", "the", "their", "them", "then", "there", "these", "they", "this", "those", "through", "to", "too", "until", "very", "was", "wasn", "wasnt", "we", "were", "weren", "what", "whats", "when", "where", "which", "while", "who", "whom", "why", "will", "with", "within", "without", "won", "wont", "would", "wouldn", "yet", "you", "your", "youre", "yours")},
	{"fr", newSet("alors", "au", "aux", "avec", "bien", "bonjour", "ce", "ces", "cette", "comment", "dans", "des", "deux", "dois", "doit", "donc", "du", "elle", "elles", "est", "et", "fait", "fois", "il", "ils", "je", "jour", "jours", "la", "le", "les", "ma", "mais", "merci", "mes", "mois", "mon", "nous", "ont", "ou", "pas", "peut", "peux", "plus", "pour", "pourquoi", "quand", "que", "qui", "sa", "ses", "sont", "sur", "ta", "tes", "ton", "tous", "tout", "toute", "trois", "très", "tu", "une", "veut", "veux", "vous", "être")},
	{"de", newSet("aber", "auch", "auf", "aus", "bei", "bitte", "das", "dem", "den", "der", "dich", "die", "diese", "diesen", "dieser", "dieses", "dir", "ein", "eine", "einem", "einen", "einer", "für", "gibt", "habe", "haben", "heute", "ich", "im", "in", "ist", "jetzt", "kann", "kannst", "mein", "meine", "meinem", "meinen", "meiner", "mich", "mir", "mit", "nach", "nicht", "noch", "oder", "sich", "sind", "und", "uns", "von", "wann", "was", "welche", "werden", "wie", "wir", "wird", "wo", "wurde", "zu", "zum", "zur")},
	{"es", newSet("al", "algo", "aquí", "aunque", "como", "con", "cuando", "del", "donde", "dos", "el", "entre", "es", "esa", "ese", "eso", "esta", "este", "esto", "está", "fue", "fueron", "gracias", "han", "hay", "hemos", "hoy", "la", "las", "le", "les", "lo", "los", "mi", "muy", "más", "nada", "necesito", "ni", "nos", "para", "pero", "por", "porque", "puede", "pueden", "que", "quiero", "se", "ser", "sobre", "son", "su", "sus", "también", "tengo", "tiene", "tienen", "todo", "tres", "tu", "un", "una", "y", "ya")},
	{"pt", newSet("agora", "ainda", "alguem", "alguém", "ali", "antes", "ao", "aos", "aqui", "as", "até", "boa", "cadê", "com", "como", "consigo", "da", "das", "depois", "deu", "do", "dois", "dos", "e", "em", "entao", "então", "era", "esta", "estamos", "estava", "este", "estou", "está", "eu", "ficou", "fiz", "foi", "gostaria", "hoje", "isso", "isto", "ja", "já", "mais", "mas", "meu", "meus", "minha", "minhas", "muito", "na", "nada", "nao", "nas", "nenhum", "nenhuma", "ninguem", "ninguém", "noite", "nos", "nossa", "nosso", "não", "o", "obrigada", "obrigado", "olá", "onde", "ontem", "os", "para", "pela", "pelo", "pode", "podem", "por", "porque", "pra", "preciso", "quando", "que", "quero", "sao", "se", "ser", "seu", "sou", "sua", "são", "tambem", "também", "tarde", "tem", "tenho", "três", "tudo", "tá", "um", "uma", "vc", "vcs", "voce", "voces", "você", "vocês", "é")},
	{"it", newSet("abbiamo", "adesso", "agli", "alla", "alle", "anche", "ancora", "avete", "che", "ci", "ciao", "col", "come", "con", "da", "dagli", "dal", "dalla", "dallo", "degli", "dei", "del", "della", "delle", "dello", "deve", "devo", "devono", "di", "dove", "e", "ed", "era", "fra", "già", "gli", "grazie", "ha", "hai", "hanno", "ho", "ieri", "il", "la", "le", "lo", "mai", "mi", "mia", "mio", "molto", "ne", "negli", "nel", "nell", "nella", "non", "o", "oggi", "per", "perche", "più", "poco", "quando", "questa", "questo", "scusa", "sempre", "si", "sono", "stata", "stato", "su", "sua", "sul", "sulla", "sulle", "tra", "tuo", "un", "una", "uno", "voglio", "vorrei", "è")},
	{"nl", newSet("aan", "dat", "deze", "door", "een", "het", "is", "maar", "met", "naar", "niet", "ook", "op", "te", "van", "voor", "worden", "wordt", "zijn")},
	{"sv", newSet("appen", "aterbetala", "aterbetalning", "att", "behover", "behöver", "blivit", "debiterade", "dessa", "detta", "faktura", "fel", "från", "får", "ganger", "gång", "gånger", "gör", "göra", "hittar", "hjalp", "hjalpa", "hjälp", "hjälpa", "här", "installningarna", "installningen", "inställningarna", "inställningen", "inte", "jag", "kommer", "kraschar", "kvittot", "losenord", "lösenord", "mig", "min", "mitt", "måste", "nar", "när", "nästa", "och", "också", "om", "oppnar", "paket", "ska", "skicka", "skulle", "sparningen", "spårningen", "säger", "till", "tva", "två", "upp", "uppdaterats", "utan", "vi", "vill", "är", "återbetala", "återbetalning", "öppnar")},
	{"ro", newSet("aceasta", "această", "acest", "acesta", "acum", "ale", "care", "dar", "din", "după", "este", "foarte", "fost", "fără", "lui", "mi", "nu", "pentru", "până", "sunt", "să", "trebuie", "vreau", "vă", "în", "și", "ți")},
	{"bn", newSet("abar", "ajke", "akhon", "amader", "amake", "amar", "ami", "amra", "apnake", "apnar", "apnara", "apni", "ar", "asbe", "bhai", "bhalo", "bolte", "bolun", "chai", "chaina", "dhonnobad", "dilam", "dite", "diye", "diyechi", "dorkar", "duibar", "ei", "eita", "ekbar", "ekhon", "ekhono", "ekta", "ferot", "geche", "gese", "hobe", "hocche", "hoise", "hoye", "hoyeche", "hoyni", "jabe", "jodi", "jonno", "kalke", "keno", "keu", "kharap", "khub", "ki", "kibhabe", "kichu", "kintu", "kivabe", "kobe", "kokhon", "korbo", "korchi", "kore", "koreche", "korechi", "koren", "korlam", "korsi", "korte", "korun", "kothay", "koto", "lagbe", "moddhe", "nai", "niye", "oi", "oita", "onek", "ota", "pabo", "paini", "parben", "parbo", "parchi", "parchina", "peyechi", "sathe", "shathe", "shob", "shomossa", "somossa", "tader", "tahole", "taka", "theke", "tomake", "tomar", "tomra", "tumi", "valo")},
	{"az", newSet("amma", "ancaq", "artiq", "artıq", "bir", "biz", "bu", "cox", "daha", "deyil", "də", "eger", "görə", "həm", "hər", "ile", "ilə", "isə", "kimi", "lakin", "mən", "nə", "olan", "olmasa", "olub", "onlar", "siz", "sonra", "sən", "ucun", "var", "ve", "və", "yalniz", "yalnız", "yox", "yoxdur", "çox", "üçün", "əgər")},
}

// shortSwedishWords Distinctive Swedish words that name the language from a short input.
var shortSwedishWords = newSet("abonnemanget", "aterbetalning", "atkomst", "behover", "behöver", "betalningen", "fakturan", "felmeddelande", "glomt", "glömt", "inloggningen", "installningen", "inställningen", "kvitto", "kvittot", "losenord", "lösenord", "sparningen", "spårningen", "återbetalning", "åtkomst")

// sharedWords Function words several lists hold, which therefore name no language.
var sharedWords = newSet("as", "como", "con", "da", "das", "del", "dois", "dos", "e", "era", "esta", "este", "está", "får", "hej", "il", "in", "is", "ja", "jo", "kommer", "la", "le", "les", "lo", "mais", "mi", "mig", "min", "nada", "nej", "nos", "o", "om", "para", "por", "porque", "quando", "que", "se", "ser", "skulle", "su", "sua", "tack", "tu", "un", "una", "vi", "was")

// nordicOverlapWords Markers shared by Swedish and Danish: evidence of non-English, not of which.
var nordicOverlapWords = newSet("får", "hej", "ja", "jo", "kommer", "mig", "min", "nej", "om", "skulle", "tack", "vi")

// enOnlyWords English function words no other list holds.
var enOnlyWords = newSet("after", "already", "always", "and", "any", "are", "aren", "at", "be", "because", "been", "before", "being", "between", "both", "but", "can", "could", "couldn", "didn", "didnt", "does", "doesn", "doesnt", "doing", "done", "dont", "down", "during", "each", "ever", "every", "few", "for", "from", "has", "hasn", "have", "haven", "havent", "here", "him", "his", "how", "i", "if", "into", "isn", "isnt", "it", "ive", "many", "might", "much", "must", "never", "nor", "not", "of", "on", "only", "onto", "our", "please", "shall", "she", "should", "some", "than", "that", "thats", "the", "their", "them", "then", "there", "these", "they", "this", "those", "through", "to", "too", "until", "very", "wasn", "wasnt", "we", "were", "weren", "what", "whats", "when", "where", "which", "while", "who", "whom", "why", "will", "with", "within", "without", "won", "wont", "would", "wouldn", "yet", "you", "your", "youre", "yours")

// enCollisionWords Words that collide with English, counted once however often they repeat.
var enCollisionWords = newSet("care", "come", "do", "im", "per", "plus", "son", "todo")

// nonEnDiacritics are the letters whose presence is evidence the text is not
// English, sorted by code point.
var nonEnDiacritics = [...]rune{
	223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 241, 242,
	243, 244, 245, 246, 248, 249, 250, 251, 252, 253, 255, 257, 259, 261, 263, 269, 271, 273, 275,
	281, 283, 287, 291, 299, 305, 311, 316, 322, 324, 326, 328, 337, 339, 345, 347, 351, 353, 355,
	357, 363, 367, 369, 378, 380, 382, 417, 432, 537, 539, 601, 7841, 7843, 7845, 7847, 7849, 7851,
	7853, 7855, 7857, 7859, 7861, 7863, 7865, 7867, 7869, 7871, 7873, 7875, 7877, 7879, 7881, 7883,
	7885, 7887, 7889, 7891, 7893, 7895, 7897, 7899, 7901, 7903, 7905, 7907, 7909, 7911, 7913, 7915,
	7917, 7919, 7921, 7923, 7925, 7927, 7929,
}

const (
	nonEnDiacriticRate         = 0.02
	englishRescueDiacriticRate = 0.06
	nonLatinFraction           = 0.2
	nonLatinMinFraction        = 0.1
	nonLatinMinLetters         = 10
)