-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlexibank_chaconcolumbian.py
144 lines (133 loc) · 4.34 KB
/
lexibank_chaconcolumbian.py
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import attr
import lingpy
import pylexibank
from clldutils.misc import slug
from clldutils.path import Path
@attr.s
class CustomConcept(pylexibank.Concept):
Spanish = attr.ib(default=None)
Category = attr.ib(default=None)
Gloss_in_source = attr.ib(default=None)
class Dataset(pylexibank.Dataset):
dir = Path(__file__).parent
id = "chaconcolumbian"
concept_class = CustomConcept
writer_options = dict(keep_languages=False, keep_parameters=False)
def cmd_makecldf(self, args):
# Read the raw data
wl_filename = self.raw_dir / "Huber_filtered_130_basic_cult_voc"
wl = lingpy.Wordlist(wl_filename.as_posix())
# Write sources
args.writer.add_sources()
# Write languages
languages = args.writer.add_languages(lookup_factory="Name")
# Write concepts
concepts = {}
for concept in self.conceptlists[0].concepts.values():
concept_cldf_id = "%s_%s"% (concept.id.split("-")[-1], slug(concept.english))
args.writer.add_concept(
ID=concept_cldf_id,
Name=concept.english,
Concepticon_ID=concept.concepticon_id,
Concepticon_Gloss=concept.concepticon_gloss,
Spanish=concept.attributes["spanish"],
Gloss_in_source=", ".join(concept.attributes["lexibank_gloss"]),
Category=concept.attributes["category"],
)
concepts[", ".join(concept.attributes["lexibank_gloss"])] = concept_cldf_id
# Hard-coded fixes to segment errors in raw source
segments = {
"#": "+",
"ks": "k s",
"ms": "m s",
"ᵑg": "ⁿg",
"bs": "b s",
"gs": "g s",
"#h": "+ h",
"#s": "+ s",
"a:": "aː",
"ãã": "ãː",
"aⁱ": "ai",
"aᵘ": "au",
"bb": "bː",
"bh": "bʱ",
"ch": "tʃ",
"ʤ": "dʒ",
"e:": "eː",
"ee": "eː",
"ẽẽ": "ẽː",
"eee": "eː",
"eⁱ": "ei",
"ɛɛ": "ɛː",
"gg": "gː",
"hh": "h + h",
"hs": "h + s",
"i̵:": "ɨː",
"ĩ̵:": "ɨ̃ː",
"i:": "iː",
"i̵": "ɨ",
"ĩ̵": "ɨ̃",
"i̵i̵": "ɨː",
"ĩ̵ĩ̵": "ɨ̃ː",
"ii": "iː",
"ĩĩ": "ĩː",
"i̵i̵i̵": "ɨː",
"ɩ": "ɪ",
"ɩɩ": "ɪː",
"jh": "jh/j",
"kh": "kʰ",
"kʰʲ": "kʲʰ",
"kk": "kː",
"kw": "kʷ",
"ll": "lː",
"ls": "l s",
"mh": "m h",
"mm": "mː",
"nh": "n̥",
"nn": "nː",
"ns": "n s",
"nss": "n + s",
"ŋh": "ŋ h",
"ŋŋ": "ŋː",
"õ:": "oː",
"oo": "oː",
"oᵘ": "ou",
"ph": "pʰ",
"pp": "pː",
"rh": "rh/r̥",
"rr": "r r",
"rs": "r s",
"ɾh": "ɾ̥",
"ɾs": "ɾ s",
"sh": "s h",
"ss": "sː",
"th": "tʰ",
"tʰʲ": "tʲʰ",
"tʲh": "tʲʰ",
"ʧ": "tʃ",
"ʧʰ": "tʃʰ",
"tt": "tː",
"uu": "uː",
"ũũ": "ũː",
"ɯɯ": "ɯː",
"ɯ̃ɯ̃": "ɯ̃ː",
"vh": "vh/v",
"vhs": "vh/v s",
"xh": "xh/x",
"ʔh": "ʔʰ",
"ʔs": "ʔ s",
}
# write lexemes
for idx in pylexibank.progressbar(wl, desc="makecldf"):
if wl[idx, "concept"]:
lex = args.writer.add_form_with_segments(
Language_ID=languages[wl[idx, "doculect"]],
Parameter_ID=concepts[wl[idx, "concept"]],
Value=wl[idx, "counterpart"],
Form=wl[idx, "counterpart"],
Segments=" ".join([segments.get(x, x) for x in wl[idx, "tokens"]]).split(),
Source=["Huber1992"],
)
args.writer.add_cognate(
lexeme=lex, Cognateset_ID=wl[idx, "cogid"], Source=["Chacon2017"]
)