Repository navigation
Expand file tree
/
Copy pathlanguages.py
More file actions
124 lines (109 loc) · 3 KB
/
Copy pathlanguages.py
File metadata and controls
124 lines (109 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
"""
languages
---------
Module for organizing language dependencies for text cleaning.
The following languages have been selected because their stopwords can be removed via https://github.com/stopwords-iso/stopwords-iso/tree/master/python.
Contents:
lem_abbr_dict,
stem_abbr_dict,
sw_abbr_dict
"""
def lem_abbr_dict():
"""
Calls a dictionary of languages and their abbreviations for lemmatization.
Notes
-----
These languages can be lemmatized via https://spacy.io/usage/models, and are also those that can have their words ordered by parts of speech.
Returns
-------
lem_abbr_dict : dict
A dictionary with languages as keys and their abbreviations as items.
"""
return {
"chinese": "zh",
"danish": "da",
"dutch": "nl",
"english": "en",
"french": "fr",
"german": "de",
"greek": "el",
"italian": "it",
"japanese": "ja",
"lithuanian": "lt",
"norwegian": "nb",
"polish": "pl",
"portuguese": "pt",
"romanian": "ro",
"spanish": "es",
}
def stem_abbr_dict():
"""
Calls a dictionary of languages and their abbreviations for stemming.
Notes
-----
These languages don't have good lemmatizers, and will thus be stemmed via https://www.nltk.org/api/nltk.stem.html.
Returns
-------
stem_abbr_dict : dict
A dictionary with languages as keys and their abbreviations as items.
"""
return {
"arabic": "ar",
"finnish": "fi",
"hungarian": "hu",
"swedish": "sv",
}
def sw_abbr_dict():
"""
Calls a dictionary of languages and their abbreviations for stop word removal.
Notes
-----
These languages can only have their stopwords removed via https://github.com/stopwords-iso/stopwords-iso).
Returns
-------
sw_abbr_dict : dict
A dictionary with languages as keys and their abbreviations as items.
"""
return {
"afrikaans": "af",
"bulgarian": "bg",
"bengali": "bn",
"breton": "br",
"catalan": "ca",
"czech": "cs",
"esperanto": "eo",
"estonian": "et",
"basque": "eu",
"farsi": "fa",
"persian": "fa",
"irish": "ga",
"galician": "gl",
"gujarati": "gu",
"hausa": "ha",
"hebrew": "he",
"hindi": "hi",
"croatian": "hr",
"armenian": "hy",
"indonesian": "id",
"korean": "ko",
"kurdish": "ku",
"latin": "la",
"latvian": "lv",
"marathi": "mr",
"malay": "ms",
"norwegian": "no",
"russian": "ru",
"slovak": "sk",
"slovenian": "sl",
"somali": "so",
"sotho": "st",
"swahili": "sw",
"thai": "th",
"tagalog": "tl",
"turkish": "tr",
"ukrainian": "uk",
"urdu": "ur",
"vietnamese": "vi",
"yoruba": "yo",
"zulu": "zu",
}