mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-10 23:54:14 +01:00
b62ee3c6a9
## About The Pull Request So, partial language understanding scaled the % chance to translate something based on the ranking in the most common words list But the ranking isn't real the list is in alphabetical order So, adds a new list of the 1000 most common words sorted by *frequency*, which I found on a random github page. Is it scientifically found? I have no idea, but it looks good enough to work. This list doesn't share the same 1000 words as our existing one, so I added all the differing words (amounted to ~400) to the original list. So now partial language understanding correctly translates words based on frequency. ## Changelog 🆑 Melbert fix: Partial language understanding now correctly has a higher chance of translating more common words. qol: Aphasia got slightly more words to work with /🆑
58 lines
2.4 KiB
Plaintext
58 lines
2.4 KiB
Plaintext
/// List of language prototypes to reference, assoc [type] = prototype
|
|
GLOBAL_LIST_INIT_TYPED(language_datum_instances, /datum/language, init_language_prototypes())
|
|
/// List if all language typepaths learnable, IE, those with keys
|
|
GLOBAL_LIST_INIT(all_languages, init_all_languages())
|
|
/// /List of language prototypes to reference, assoc "name" = typepath
|
|
GLOBAL_LIST_INIT(language_types_by_name, init_language_types_by_name())
|
|
/// ~1400 element long list containing the 1000 most common words in the English language in alphabetical order.
|
|
/// Indexed by word, value is the rank of the word in the list. So accessing it is fasta.
|
|
GLOBAL_LIST_INIT(most_common_words_alphabetical, init_common_words_by_alphabetical())
|
|
/// ~1000 element long list containing the 1000 most common words in the English language in frequency order.
|
|
/// Indexed by word, value is the rank of the word in the list. So accessing it is fasta.
|
|
GLOBAL_LIST_INIT(most_common_words_frequency, init_common_words_by_frequency())
|
|
|
|
/proc/init_language_prototypes()
|
|
var/list/lang_list = list()
|
|
for(var/datum/language/lang_type as anything in typesof(/datum/language))
|
|
if(!initial(lang_type.key))
|
|
continue
|
|
|
|
lang_list[lang_type] = new lang_type()
|
|
return lang_list
|
|
|
|
/proc/init_all_languages()
|
|
var/list/lang_list = list()
|
|
for(var/datum/language/lang_type as anything in typesof(/datum/language))
|
|
if(!initial(lang_type.key))
|
|
continue
|
|
lang_list += lang_type
|
|
return lang_list
|
|
|
|
/proc/init_language_types_by_name()
|
|
var/list/lang_list = list()
|
|
for(var/datum/language/lang_type as anything in typesof(/datum/language))
|
|
if(!initial(lang_type.key))
|
|
continue
|
|
lang_list[initial(lang_type.name)] = lang_type
|
|
return lang_list
|
|
|
|
/proc/init_common_words_by_alphabetical()
|
|
var/list/word_to_commonness_list = list()
|
|
var/i = 1
|
|
for(var/word in world.file2list("strings/1400_most_common_alpha.txt"))
|
|
word_to_commonness_list[word] = i
|
|
i += 1
|
|
return word_to_commonness_list
|
|
|
|
/proc/init_common_words_by_frequency()
|
|
var/list/word_to_commonness_list = list()
|
|
var/i = 1
|
|
for(var/word in world.file2list("strings/1000_most_common_frequency.txt"))
|
|
word_to_commonness_list[word] = i
|
|
i += 1
|
|
// alphabetical list has a few more entries than the frequency list, so
|
|
// if there are any words we're missing, add them with a default "commonness" of 500
|
|
for(var/word in world.file2list("strings/1400_most_common_alpha.txt"))
|
|
word_to_commonness_list[word] ||= 500
|
|
return word_to_commonness_list
|