Python LMF library
 All Classes Namespaces Files Functions Variables
mdf.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 """! @package config
4 """
5 
6 ## To define languages
7 import config
8 
9 ## Functions to process some MDF fields (input)
10 def set_bw(bw, lexical_entry):
11  # Retrieve if there is a written form following the borrowed word (e.g. "Portuguese fi:meirinho")
12  borrowed_word = bw.split()[0]
13  written_form = ""
14  for item in bw.split()[1:]:
15  written_form += item
16  # Set borrowed word, and written form if any
17  lexical_entry.set_borrowed_word(borrowed_word)
18  if len(written_form) > 0:
19  lexical_entry.set_written_form(written_form)
20 
21 ## Mapping between MDF markers and LMF representation (input)
22 mdf_lmf = dict({
23  "lx" : lambda lx, lexical_entry: lexical_entry.set_lexeme(lx),
24  "hm" : lambda hm, lexical_entry: lexical_entry.set_homonymNumber(hm),
25  "lc" : lambda lc, lexical_entry: lexical_entry.set_citation_form(lc), # or lexical_entry.set_contextual_variation(lc)
26  "ph" : lambda ph, lexical_entry: lexical_entry.set_phonetic_form(ph), # or lexical_entry.set_transliteration(ph)
27  "se" : lambda se, lexical_entry: lexical_entry.create_and_add_related_form(se, mdf_semanticRelation["se"]),
28  "ps" : lambda ps, lexical_entry: lexical_entry.set_partOfSpeech(ps),
29  "pn" : lambda pn, lexical_entry: None,
30  "sn" : lambda sn, lexical_entry: lexical_entry.create_and_add_sense(sn),
31  "gv" : lambda gv, lexical_entry: lexical_entry.set_gloss(gv, language=config.xml.vernacular),
32  "dv" : lambda dv, lexical_entry: lexical_entry.set_definition(dv, language=config.xml.vernacular),
33  "ge" : lambda ge, lexical_entry: lexical_entry.set_gloss(ge, language=config.xml.English),
34  "re" : lambda re, lexical_entry: lexical_entry.set_translation(re, language=config.xml.English),
35  "we" : lambda we, lexical_entry: None,
36  "de" : lambda de, lexical_entry: lexical_entry.set_definition(de, language=config.xml.English),
37  "gn" : lambda gn, lexical_entry: lexical_entry.set_gloss(gn, language=config.xml.national),
38  "rn" : lambda rn, lexical_entry: lexical_entry.set_translation(rn, language=config.xml.national),
39  "wn" : lambda wn, lexical_entry: None,
40  "dn" : lambda dn, lexical_entry: lexical_entry.set_definition(dn, language=config.xml.national),
41  "gr" : lambda gr, lexical_entry: lexical_entry.set_gloss(gr, language=config.xml.regional),
42  "rr" : lambda rr, lexical_entry: lexical_entry.set_translation(rr, language=config.xml.regional),
43  "wr" : lambda wr, lexical_entry: None,
44  "dr" : lambda dr, lexical_entry: lexical_entry.set_definition(dr, language=config.xml.regional),
45  "lt" : lambda lt, lexical_entry: None,
46  "sc" : lambda sc, lexical_entry: lexical_entry.set_scientific_name(sc),
47  "rf" : lambda rf, lexical_entry: lexical_entry.create_example(rf),
48  "xv" : lambda xv, lexical_entry: lexical_entry.create_and_add_example(xv, language=config.xml.vernacular),
49  "xe" : lambda xe, lexical_entry: lexical_entry.add_example(xe, language=config.xml.English),
50  "xn" : lambda xn, lexical_entry: lexical_entry.add_example(xn, language=config.xml.national),
51  "xr" : lambda xr, lexical_entry: lexical_entry.add_example(xr, language=config.xml.regional),
52  "xg" : lambda xg, lexical_entry: None,
53  "uv" : lambda uv, lexical_entry: lexical_entry.set_usage_note(uv, language=config.xml.vernacular),
54  "ue" : lambda ue, lexical_entry: lexical_entry.set_usage_note(ue, language=config.xml.English),
55  "un" : lambda un, lexical_entry: lexical_entry.set_usage_note(un, language=config.xml.national),
56  "ur" : lambda ur, lexical_entry: lexical_entry.set_usage_note(ur, language=config.xml.regional),
57  "ev" : lambda ev, lexical_entry: lexical_entry.set_encyclopedic_information(ev, language=config.xml.vernacular),
58  "ee" : lambda ee, lexical_entry: lexical_entry.set_encyclopedic_information(ee, language=config.xml.English),
59  "en" : lambda en, lexical_entry: lexical_entry.set_encyclopedic_information(en, language=config.xml.national),
60  "er" : lambda er, lexical_entry: lexical_entry.set_encyclopedic_information(er, language=config.xml.regional),
61  "ov" : lambda ov, lexical_entry: lexical_entry.set_restriction(ov, language=config.xml.vernacular),
62  "oe" : lambda oe, lexical_entry: lexical_entry.set_restriction(oe, language=config.xml.English),
63  "on" : lambda on, lexical_entry: lexical_entry.set_restriction(on, language=config.xml.national),
64  "or" : lambda OR, lexical_entry: lexical_entry.set_restriction(OR, language=config.xml.regional), # 'or' is a keyword in Python
65  "lf" : lambda lf, lexical_entry: None,
66  "lv" : lambda lv, lexical_entry: None,
67  "le" : lambda le, lexical_entry: None,
68  "ln" : lambda ln, lexical_entry: None,
69  "lr" : lambda lr, lexical_entry: None,
70  "sy" : lambda sy, lexical_entry: lexical_entry.create_and_add_related_form(sy, mdf_semanticRelation["sy"]),
71  "an" : lambda an, lexical_entry: lexical_entry.create_and_add_related_form(an, mdf_semanticRelation["an"]),
72  "mr" : lambda mr, lexical_entry: lexical_entry.set_morphology(mr),
73  "cf" : lambda cf, lexical_entry: lexical_entry.create_and_add_related_form(cf, mdf_semanticRelation["cf"]),
74  "ce" : lambda ce, lexical_entry: None,
75  "cn" : lambda cn, lexical_entry: None,
76  "cr" : lambda cr, lexical_entry: None,
77  "mn" : lambda mn, lexical_entry: lexical_entry.create_and_add_related_form(mn, mdf_semanticRelation["mn"]),
78  "va" : lambda va, lexical_entry: lexical_entry.set_variant_form(va, type="phonetics"), # or lexical_entry.set_geographical_variant(va)
79  "ve" : lambda ve, lexical_entry: lexical_entry.set_variant_comment(ve, language=config.xml.English), # or lexical_entry.set_dialect(ve)
80  "vn" : lambda vn, lexical_entry: lexical_entry.set_variant_comment(vn, language=config.xml.national),
81  "vr" : lambda vr, lexical_entry: lexical_entry.set_variant_comment(vr, language=config.xml.regional),
82  "bw" : lambda bw, lexical_entry: set_bw(bw, lexical_entry),
83  "et" : lambda et, lexical_entry: lexical_entry.set_etymology(et),
84  "eg" : lambda eg, lexical_entry: lexical_entry.set_etymology_gloss(eg),
85  "es" : lambda es, lexical_entry: lexical_entry.set_etymology_source(es),
86  "ec" : lambda ec, lexical_entry: lexical_entry.set_etymology_comment(ec),
87  "pd" : lambda pd, lexical_entry: lexical_entry.set_paradigm(pd),
88  "pdl": lambda pdl, lexical_entry: lexical_entry.set_paradigm_label(pdl),
89  "pdv": lambda pdv, lexical_entry: lexical_entry.set_paradigm_form(pdv, language=config.xml.vernacular),
90  "pde": lambda pde, lexical_entry: lexical_entry.set_paradigm_form(pde, language=config.xml.English),
91  "pdn": lambda pdn, lexical_entry: lexical_entry.set_paradigm_form(pdn, language=config.xml.national),
92  "pdr": lambda pdr, lexical_entry: lexical_entry.set_paradigm_form(pdr, language=config.xml.regional),
93  "sg" : lambda sg, lexical_entry: lexical_entry.set_paradigm(sg, grammatical_number=pd_grammaticalNumber["sg"]),
94  "pl" : lambda pl, lexical_entry: lexical_entry.set_paradigm(pl, grammatical_number=pd_grammaticalNumber["pl"]),
95  "rd" : lambda rd, lexical_entry: None,
96  "1s" : lambda a1s, lexical_entry: lexical_entry.set_paradigm(a1s, person=pd_person[1], grammatical_number=pd_grammaticalNumber['s']),
97  "2s" : lambda a2s, lexical_entry: lexical_entry.set_paradigm(a2s, person=pd_person[2], grammatical_number=pd_grammaticalNumber['s']),
98  "3s" : lambda a3s, lexical_entry: lexical_entry.set_paradigm(a3s, person=pd_person[3], grammatical_number=pd_grammaticalNumber['s']),
99  "4s" : lambda a4s, lexical_entry: lexical_entry.set_paradigm(a4s, anymacy=pd_anymacy[4], grammatical_number=pd_grammaticalNumber['s']),
100  "1d" : lambda a1d, lexical_entry: lexical_entry.set_paradigm(a1d, person=pd_person[1], grammatical_number=pd_grammaticalNumber['d']),
101  "2d" : lambda a2d, lexical_entry: lexical_entry.set_paradigm(a2d, person=pd_person[2], grammatical_number=pd_grammaticalNumber['d']),
102  "3d" : lambda a3d, lexical_entry: lexical_entry.set_paradigm(a3d, person=pd_person[3], grammatical_number=pd_grammaticalNumber['d']),
103  "4d" : lambda a4d, lexical_entry: lexical_entry.set_paradigm(a4d, anymacy=pd_anymacy[4], grammatical_number=pd_grammaticalNumber['d']),
104  "1p" : lambda a1p, lexical_entry: lexical_entry.set_paradigm(a1p, person=pd_person[1], grammatical_number=pd_grammaticalNumber['p']),
105  "1e" : lambda a1e, lexical_entry: lexical_entry.set_paradigm(a1e, person=pd_person[1], grammatical_number=pd_grammaticalNumber['p'], clusivity=pd_clusivity['e']),
106  "1i" : lambda a1i, lexical_entry: lexical_entry.set_paradigm(a1i, person=pd_person[1], grammatical_number=pd_grammaticalNumber['p'], clusivity=pd_clusivity['i']),
107  "2p" : lambda a2p, lexical_entry: lexical_entry.set_paradigm(a2p, person=pd_person[2], grammatical_number=pd_grammaticalNumber['p']),
108  "3p" : lambda a3p, lexical_entry: lexical_entry.set_paradigm(a3p, person=pd_person[3], grammatical_number=pd_grammaticalNumber['p']),
109  "4p" : lambda a4p, lexical_entry: lexical_entry.set_paradigm(a4p, anymacy=pd_anymacy[4], grammatical_number=pd_grammaticalNumber['p']),
110  "tb" : lambda tb, lexical_entry: None,
111  "sd" : lambda sd, lexical_entry: lexical_entry.set_semantic_domain(sd),
112  "is" : lambda IS, lexical_entry: lexical_entry.set_semantic_domain(IS), # 'is' is a keyword in Python
113  "th" : lambda th, lexical_entry: lexical_entry.set_semantic_domain(th),
114  "bb" : lambda bb, lexical_entry: lexical_entry.set_bibliography(bb),
115  "pc" : lambda pc, lexical_entry: None,
116  "nt" : lambda nt, lexical_entry: lexical_entry.set_note(nt, type="general"),
117  "np" : lambda np, lexical_entry: lexical_entry.set_note(np, type="phonology"),
118  "ng" : lambda ng, lexical_entry: lexical_entry.set_note(ng, type="grammar"),
119  "nd" : lambda nd, lexical_entry: lexical_entry.set_note(nd, type="discourse"),
120  "na" : lambda na, lexical_entry: lexical_entry.set_note(na, type="anthropology"),
121  "ns" : lambda ns, lexical_entry: lexical_entry.set_note(ns, type="sociolinguistics"),
122  "nq" : lambda nq, lexical_entry: lexical_entry.set_note(nq, type="question"),
123  "so" : lambda so, lexical_entry: None,
124  "st" : lambda st, lexical_entry: lexical_entry.set_status(st),
125  "dt" : lambda dt, lexical_entry: lexical_entry.set_date(dt)
126 })
127 
128 ## Order in which MDF markers must be written (output)
129 # This is the standard order defined in Appendix B of "Making Dictionaries. A guide to lexicography and the Multi-Dictionary Formatter",
130 # Software version 1.0, David F. Coward, Charles E. Grimes, SIL International, Waxhaw, North Carolina, 2000
131 mdf_order = [
132  "lx", # lexeme
133  "hm", # homonym number
134  "lc", # lexical citation
135  "ph", # phonetic
136  "se", # subentry
137  "ps", # part of speech
138  "pn", # part of speech-national language
139  [
140  "sn", # sense number
141  "gv", # gloss-vernacular
142  "dv", # definition-vernacular
143  "ge", # gloss-English
144  "re", # reverse-English
145  "we", # word level gloss-English
146  "de", # definition-English
147  "gn", # gloss-national language
148  "rn", # reverse-national language
149  "wn", # word level gloss-national language
150  "dn", # definition-national language
151  "gr", # gloss-regional lang. (with \gn)
152  "rr", # reverse-regional lang. (with \rn)
153  "wr", # word-level gloss-regional (with \wn)
154  "dr", # definition-regional lang. (with \dn)
155  "lt", # literal meaning
156  "sc", # scientific name
157  [
158  "rf", # reference for example
159  "xv", # example sentence-vernacular
160  "xe", # example sentence-English
161  "xn", # example sentence-national language
162  "xr", # example sent.-regional (with \xn)
163  "xg" # example sentence-interlinear gloss
164  ],
165  "uv", # usage-vernacular
166  "ue", # usage-English
167  "un", # usage-national language
168  "ur", # usage-regional (combines with \un)
169  "ev", # encyclopedic-vernacular
170  "ee", # encyclopedic-English
171  "en", # encyclopedic-national language
172  "er", # encyclopedic-regional language
173  "ov", # only (restrictions)-vernacular
174  "oe", # only (restrictions)-English
175  "on", # only (restrictions)-national language
176  "or" # only (restrictions)-regional (with \on)
177  ],
178  "lf", # lexical function label-English
179  "lv", # lexical function value-vernacular language
180  "le", # lexical function value-English
181  "ln", # lexical function value-national language
182  "lr", # lexical function value-regional language
183  "sy", # synonym
184  "an", # antonym
185  "mr", # morphemic representation
186  "cf", # cross-reference
187  "ce", # cross-reference-English gloss
188  "cn", # cross-reference-national gloss
189  "cr", # cross-reference-regional gloss
190  "mn", # main entry form
191  [
192  "va", # variant form
193  "ve", # variant comment-English
194  "vn", # variant comment-national language
195  "vr" # variant comment-regional language
196  ],
197  "bw", # borrowed word
198  "et", # etymology
199  "eg", # etymology-gloss
200  "es", # etymology-source
201  "ec", # etymology-comment
202  "pd", # paradigm
203  [
204  "pdl", # paradigm label-English
205  "pdv", # paradigm form-vernacular language
206  "pde", # paradigm form-English gloss
207  "pdn", # paradigm form-national gloss
208  "pdr" # paradigm form-regional gloss
209  ],
210  "sg", # singular form
211  "pl", # plural form
212  "rd", # reduplication
213  "1s", # 1st person singular
214  "2s", # 2nd person singular
215  "3s", # 3rd person singular
216  "4s", # singular non-human/non-animate
217  "1d", # 1st person dual
218  "2d", # 2nd person dual
219  "3d", # 3rd person dual
220  "4d", # dual non-human/non-animate
221  "1p", # 1st person plural-general
222  "1e", # 1st person plural-exclusive
223  "1i", # 1st person plural-inclusive
224  "2p", # 2nd person plural
225  "3p", # 3rd person plural
226  "4p", # plural non-human/non-animate
227  "tb", # table
228  "sd", # semantic domain
229  "is", # index of semantics
230  "th", # thesaurus
231  "bb", # bibliographic reference
232  "pc", # picture
233  "nt", # notes-general
234  "np", # notes-phonology
235  "ng", # notes-grammar
236  "nd", # notes-discourse
237  "na", # notes-anthropology
238  "ns", # notes-sociolinguistics
239  "nq", # notes-questions
240  "so", # source
241  "st", # status
242  "dt" # datestamp
243 ]
244 # bundles of related fields: ge, re, de, xv, ue, oe, ee
245 # bundles related to other entries: lf, nt, pd, et, cf, va
246 
247 ## Functions to process some MDF fields (output)
248 def get_bw(lexical_entry):
249  bw = lexical_entry.get_borrowed_word()
250  if lexical_entry.get_written_form() is not None:
251  bw += " " + lexical_entry.get_written_form()
252  return bw
253 
254 ## Mapping between LMF representation and MDF markers (output)
255 lmf_mdf = dict({
256  "lx" : lambda lexical_entry: lexical_entry.get_lexeme(),
257  "hm" : lambda lexical_entry: lexical_entry.get_homonymNumber(),
258  "lc" : lambda lexical_entry: lexical_entry.get_citation_forms(), # or lexical_entry.get_contextual_variations()
259  "ph" : lambda lexical_entry: lexical_entry.get_phonetic_forms(), # or lexical_entry.get_transliterations()
260  "se" : lambda lexical_entry: lexical_entry.find_related_forms(mdf_semanticRelation["se"]),
261  "ps" : lambda lexical_entry: lexical_entry.get_partOfSpeech(),
262  "pn" : lambda lexical_entry: None,
263  "snGroup" : lambda lexical_entry: lexical_entry.get_senses(),
264  "sn" : lambda sense: sense.get_senseNumber(),
265  "gv" : lambda sense: sense.find_glosses(config.xml.vernacular),
266  "dv" : lambda sense: sense.find_definitions(config.xml.vernacular),
267  "ge" : lambda sense: sense.find_glosses(config.xml.English),
268  "re" : lambda sense: sense.get_translations(config.xml.English),
269  "we" : lambda sense: None,
270  "de" : lambda sense: sense.find_definitions(config.xml.English),
271  "gn" : lambda sense: sense.find_glosses(config.xml.national),
272  "rn" : lambda sense: sense.get_translations(config.xml.national),
273  "wn" : lambda sense: None,
274  "dn" : lambda sense: sense.find_definitions(config.xml.national),
275  "gr" : lambda sense: sense.find_glosses(config.xml.regional),
276  "rr" : lambda sense: sense.get_translations(config.xml.regional),
277  "wr" : lambda sense: None,
278  "dr" : lambda sense: sense.find_definitions(config.xml.regional),
279  "lt" : lambda sense: None,
280  "sc" : lambda sense: sense.get_scientific_name(),
281  "rfGroup" : lambda sense: sense.get_contexts(),
282  "rf" : lambda context: None,
283  "xv" : lambda context: context.find_written_forms(config.xml.vernacular),
284  "xe" : lambda context: context.find_written_forms(config.xml.English),
285  "xn" : lambda context: context.find_written_forms(config.xml.national),
286  "xr" : lambda context: context.find_written_forms(config.xml.regional),
287  "xg" : lambda sense: None,
288  "uv" : lambda sense: sense.find_usage_notes(language=config.xml.vernacular),
289  "ue" : lambda sense: sense.find_usage_notes(language=config.xml.English),
290  "un" : lambda sense: sense.find_usage_notes(language=config.xml.national),
291  "ur" : lambda sense: sense.find_usage_notes(language=config.xml.regional),
292  "ev" : lambda sense: sense.find_encyclopedic_informations(language=config.xml.vernacular),
293  "ee" : lambda sense: sense.find_encyclopedic_informations(language=config.xml.English),
294  "en" : lambda sense: sense.find_encyclopedic_informations(language=config.xml.national),
295  "er" : lambda sense: sense.find_encyclopedic_informations(language=config.xml.regional),
296  "ov" : lambda sense: sense.find_restrictions(language=config.xml.vernacular),
297  "oe" : lambda sense: sense.find_restrictions(language=config.xml.English),
298  "on" : lambda sense: sense.find_restrictions(language=config.xml.national),
299  "or" : lambda sense: sense.find_restrictions(language=config.xml.regional),
300  "lf" : lambda lexical_entry: None,
301  "lv" : lambda lexical_entry: None,
302  "le" : lambda lexical_entry: None,
303  "ln" : lambda lexical_entry: None,
304  "lr" : lambda lexical_entry: None,
305  "sy" : lambda lexical_entry: lexical_entry.find_related_forms(mdf_semanticRelation["sy"]),
306  "an" : lambda lexical_entry: lexical_entry.find_related_forms(mdf_semanticRelation["an"]),
307  "mr" : lambda lexical_entry: lexical_entry.get_morphologies(),
308  "cf" : lambda lexical_entry: lexical_entry.find_related_forms(mdf_semanticRelation["cf"]),
309  "ce" : lambda lexical_entry: None,
310  "cn" : lambda lexical_entry: None,
311  "cr" : lambda lexical_entry: None,
312  "mn" : lambda lexical_entry: lexical_entry.find_related_forms(mdf_semanticRelation["mn"]),
313  "vaGroup" : lambda lexical_entry: lexical_entry.get_form_representations(),
314  "va" : lambda form_representation: form_representation.get_variantForm(), # or form_representation.get_geographicalVariant() or form_representation.get_spellingVariant()
315  "ve" : lambda form_representation: form_representation.get_comment(config.xml.English), # or form_representation.get_dialect()
316  "vn" : lambda form_representation: form_representation.get_comment(config.xml.national),
317  "vr" : lambda form_representation: form_representation.get_comment(config.xml.regional),
318  "bw" : lambda lexical_entry: get_bw(lexical_entry),
319  "et" : lambda lexical_entry: lexical_entry.get_etymology(),
320  "eg" : lambda lexical_entry: lexical_entry.get_etymology_gloss(),
321  "es" : lambda lexical_entry: lexical_entry.get_etymology_source(),
322  "ec" : lambda lexical_entry: lexical_entry.get_etymology_comment(),
323  "pd" : lambda lexical_entry: lexical_entry.find_paradigms(),
324  "pdlGroup": lambda lexical_entry: lexical_entry.get_paradigms(),
325  "pdl": lambda paradigm: paradigm.get_paradigmLabel(),
326  "pdv": lambda paradigm: paradigm.get_paradigm(language=config.xml.vernacular),
327  "pde": lambda paradigm: paradigm.get_paradigm(language=config.xml.English),
328  "pdn": lambda paradigm: paradigm.get_paradigm(language=config.xml.national),
329  "pdr": lambda paradigm: paradigm.get_paradigm(language=config.xml.regional),
330  "sg" : lambda lexical_entry: lexical_entry.find_paradigms(grammatical_number=pd_grammaticalNumber["sg"]),
331  "pl" : lambda lexical_entry: lexical_entry.find_paradigms(grammatical_number=pd_grammaticalNumber["pl"]),
332  "rd" : lambda lexical_entry: None,
333  "1s" : lambda lexical_entry: lexical_entry.find_paradigms(person=pd_person[1], grammatical_number=pd_grammaticalNumber['s']),
334  "2s" : lambda lexical_entry: lexical_entry.find_paradigms(person=pd_person[2], grammatical_number=pd_grammaticalNumber['s']),
335  "3s" : lambda lexical_entry: lexical_entry.find_paradigms(person=pd_person[3], grammatical_number=pd_grammaticalNumber['s']),
336  "4s" : lambda lexical_entry: lexical_entry.find_paradigms(anymacy=pd_anymacy[4], grammatical_number=pd_grammaticalNumber['s']),
337  "1d" : lambda lexical_entry: lexical_entry.find_paradigms(person=pd_person[1], grammatical_number=pd_grammaticalNumber['d']),
338  "2d" : lambda lexical_entry: lexical_entry.find_paradigms(person=pd_person[2], grammatical_number=pd_grammaticalNumber['d']),
339  "3d" : lambda lexical_entry: lexical_entry.find_paradigms(person=pd_person[3], grammatical_number=pd_grammaticalNumber['d']),
340  "4d" : lambda lexical_entry: lexical_entry.find_paradigms(anymacy=pd_anymacy[4], grammatical_number=pd_grammaticalNumber['d']),
341  "1p" : lambda lexical_entry: lexical_entry.find_paradigms(person=pd_person[1], grammatical_number=pd_grammaticalNumber['p']),
342  "1e" : lambda lexical_entry: lexical_entry.find_paradigms(person=pd_person[1], grammatical_number=pd_grammaticalNumber['p'], clusivity=pd_clusivity['e']),
343  "1i" : lambda lexical_entry: lexical_entry.find_paradigms(person=pd_person[1], grammatical_number=pd_grammaticalNumber['p'], clusivity=pd_clusivity['i']),
344  "2p" : lambda lexical_entry: lexical_entry.find_paradigms(person=pd_person[2], grammatical_number=pd_grammaticalNumber['p']),
345  "3p" : lambda lexical_entry: lexical_entry.find_paradigms(person=pd_person[3], grammatical_number=pd_grammaticalNumber['p']),
346  "4p" : lambda lexical_entry: lexical_entry.find_paradigms(anymacy=pd_anymacy[4], grammatical_number=pd_grammaticalNumber['p']),
347  "tb" : lambda lexical_entry: None,
348  "sd" : lambda lexical_entry: lexical_entry.get_semantic_domains(),
349  "is" : lambda lexical_entry: lexical_entry.get_semantic_domains(),
350  "th" : lambda lexical_entry: lexical_entry.get_semantic_domains(),
351  "bb" : lambda lexical_entry: lexical_entry.get_bibliography(),
352  "pc" : lambda lexical_entry: None,
353  "nt" : lambda lexical_entry: lexical_entry.find_notes(type="general"),
354  "np" : lambda lexical_entry: lexical_entry.find_notes(type="phonology"),
355  "ng" : lambda lexical_entry: lexical_entry.find_notes(type="grammar"),
356  "nd" : lambda lexical_entry: lexical_entry.find_notes(type="discourse"),
357  "na" : lambda lexical_entry: lexical_entry.find_notes(type="anthropology"),
358  "ns" : lambda lexical_entry: lexical_entry.find_notes(type="sociolinguistics"),
359  "nq" : lambda lexical_entry: lexical_entry.find_notes(type="question"),
360  "so" : lambda lexical_entry: None,
361  "st" : lambda lexical_entry: lexical_entry.get_status(),
362  "dt" : lambda lexical_entry: lexical_entry.get_date()
363 })
364 
365 ## Possible values allowed for 'ps' MDF marker
366 ps_range = set([
367  "ADJ", # Adjective
368  "ADJR", # Adjectivizer
369  "MDL", # Modal
370  "ADV", # Adverb
371  "ADVR", # Adverbializer
372  "NEG", # Negative
373  "AFFM", # Affirmative
374  "NEGimp", # Negative imperative
375  "AL", # Alienable
376  "NOM", # Nominative
377  "AN", # Animate
378  "NOMR", # Nominalizer
379  "APPL", # Applicative
380  "n", # Noun
381  "ART", # Article
382  "NUM", # Number
383  "ASP", # Aspect
384  "AUX", # Auxiliary
385  "PTCL", # Particle
386  "PART", # Participle
387  "CLASS", # Classifier
388  "PAUS", # Pause word
389  "CMPAR", # Comparative
390  "PL", # Plural
391  "CMPLR", # Complementizer
392  "POSS", # Possessive
393  "CNJ", # Conjunction
394  "POSSR", # Possessor
395  "COND", # Conditional
396  "POST", # Postposition
397  "CONF", # Confirmative
398  "PREP", # Preposition
399  "CONN", # Connective
400  "PRO", # Pronoun/pronominal
401  "COP", # Copula
402  "PropN", # Proper noun
403  "DECL", # Declarative
404  "Q", # Query/Question/Interrogative
405  "DEIC", # Deictic (spatial & temp.)
406  "QNT", # Quantifier
407  "DEM", # Demonstrative
408  "DIR", # Directional
409  "REC", # Reciprocal
410  "REL", # Relative(izer)
411  "EVID", # Evidential
412  "RFLX", # Reflexive
413  "EXASP", # Exasperative
414  "RLR", # Relater
415  "EXIST", # Existential
416  "TAM", # Tense-Aspect-Mood
417  "FOC", # Focus marker
418  "TIME", # Time expression
419  "TNS", # Tense
420  "HORT", # Hortative
421  "TR", # Transitive(izer)
422  "ID", # Idiom
423  "v", # Verb/verba
424  "IMP", # Imperative
425  "vi", # Intransitive verb
426  "INTJ", # Interjection
427  "vm", # Middle verb
428  "INT", # Interrogative (non-agentive passive)
429  "ITR", # Intransitive(izer)
430  "vn", # Non-active verb
431  "vp", # Passive verb (agentive)
432  "vr", # Reflexive/quasi-reflexive/intradirective
433  "LIG", # Ligature
434  "vt", # Transitive verb
435  "LOC", # Locative
436  "vt/i" # Ambitransitive verb
437 ])
438 
439 ## Mapping between 'ps' MDF marker value and LMF part of speech LexicalEntry attribute value (input)
440 # Source: http://www.isocat.org/rest/dcs/119
441 ps_partOfSpeech = dict({
442  "ADJ" : "adjective", # http://www.isocat.org/datcat/DC-1230
443  "ADJR" : "adjective", # http://www.isocat.org/datcat/DC-1230
444  "MDL" : "modal", # http://www.isocat.org/datcat/DC-1329
445  "ADV" : "adverb", # http://www.isocat.org/datcat/DC-1232
446  "ADVR" : "adverb", # http://www.isocat.org/datcat/DC-1232
447  "NEG" : "negative particle", # http://www.isocat.org/datcat/DC-1894
448  "AFFM" : "affirmative particle", # http://www.isocat.org/datcat/DC-1918
449  "NEGimp" : None,
450  "AL" : None,
451  "NOM" : None,
452  "AN" : None,
453  "NOMR" : None,
454  "APPL" : None,
455  "n" : "noun", # http://www.isocat.org/datcat/DC-1333
456  "ART" : "article", # http://www.isocat.org/datcat/DC-1892
457  "NUM" : "numeral", # http://www.isocat.org/datcat/DC-1334
458  "ASP" : None,
459  "AUX" : "auxiliary", # http://www.isocat.org/datcat/DC-1244
460  "PTCL" : "particle", # http://www.isocat.org/datcat/DC-1342
461  "PART" : "participle adjective", # http://www.isocat.org/datcat/DC-1598
462  "CLASS" : "classifier", # http://www.isocat.org/datcat/DC-2345
463  "PAUS" : None,
464  "CMPAR" : None,
465  "PL" : None,
466  "CMPLR" : "comparative particle", # http://www.isocat.org/datcat/DC-1922
467  "POSS" : "possessive pronoun", # http://www.isocat.org/datcat/DC-1359
468  "CNJ" : "conjunction", # http://www.isocat.org/datcat/DC-1260
469  "POSSR" : "possessive relative pronoun", # http://www.isocat.org/datcat/DC-3005
470  "COND" : "conditional particle", # http://www.isocat.org/datcat/DC-2230
471  "POST" : "postposition", # http://www.isocat.org/datcat/DC-1360
472  "CONF" : None,
473  "PREP" : "preposition", # http://www.isocat.org/datcat/DC-1366
474  "CONN" : None,
475  "PRO" : "pronoun", # http://www.isocat.org/datcat/DC-1370
476  "COP" : None,
477  "PropN" : "proper noun", # http://www.isocat.org/datcat/DC-1371
478  "DECL" : "declarative punctuation", # http://www.isocat.org/datcat/DC-2086
479  "Q" : "interrogative particle", # http://www.isocat.org/datcat/DC-1921
480  "DEIC" : None,
481  "QNT" : None,
482  "DEM" : "demonstrative determiner", # http://www.isocat.org/datcat/DC-1269
483  "DIR" : None,
484  "REC" : "reciprocal pronoun", # http://www.isocat.org/datcat/DC-1924
485  "REL" : "relative determiner", # http://www.isocat.org/datcat/DC-1379
486  "EVID" : None,
487  "RFLX" : "reflexive determiner", # http://www.isocat.org/datcat/DC-1377
488  "EXASP" : None,
489  "RLR" : None,
490  "EXIST" : "existential pronoun", # http://www.isocat.org/datcat/DC-3012
491  "TAM" : None,
492  "FOC" : None,
493  "TIME" : "time noun", # http://www.isocat.org/datcat/DC-3855
494  "TNS" : None,
495  "HORT" : None,
496  "TR" : None,
497  "ID" : None,
498  "v" : "verb", # http://www.isocat.org/datcat/DC-1424
499  "IMP" : None,
500  "vi" : "intransitive verb", # http://www.isocat.org/datcat/DC-1322
501  "INTJ" : "interjection", # http://www.isocat.org/datcat/DC-1318
502  "vm" : None,
503  "INT" : "interrogative determiner", # http://www.isocat.org/datcat/DC-1320
504  "ITR" : None,
505  "vn" : None,
506  "vp" : None,
507  "vr" : "reflexive verb", # http://www.isocat.org/datcat/DC-5592
508  "LIG" : None,
509  "vt" : "transitive verb", # http://www.isocat.org/datcat/DC-1405
510  "LOC" : "presentative pronoun", # http://www.isocat.org/datcat/DC-3015
511  "vt/i" : "bitransitive verb" # http://www.isocat.org/datcat/DC-1275
512 })
513 
514 ## Mapping between MDF markers and LMF semantic relation RelatedForm attribute value (input)
515 mdf_semanticRelation = dict({
516  "sy" : "synonym",
517  "an" : "antonym",
518  "hm" : "homonym",
519  "et" : "etymology",
520  "se" : "subentry",
521  "mn" : "main entry",
522  "cf" : "simple link",
523  "cp" : "complex predicate",
524  "lf" : None,
525  "ev" : None,
526  "ee" : None,
527  "en" : None,
528  "er" : None
529  # "derived form",
530  # "root",
531  # "stem",
532  # "collocation"
533 })
534 
535 ## Mapping between 'pd' MDF markers and LMF person WordForm attribute value (input)
536 pd_person = dict({
537  1 : "first person",
538  2 : "second person",
539  3 : "third person"
540 })
541 
542 ## Mapping between 'pd' MDF markers and LMF anymacy WordForm attribute value (input)
543 pd_anymacy = dict({
544  4 : "inanimate"
545 })
546 
547 ## Mapping between 'pd' MDF markers and LMF grammatical number WordForm attribute value (input)
548 pd_grammaticalNumber = dict({
549  'd' : "dual",
550  'p' : "plural",
551  "pl" : "plural",
552  's' : "singular",
553  "sg" : "singular"
554 })
555 
556 ## Mapping between 'pd' MDF markers and LMF clusivity WordForm attribute value (input)
557 pd_clusivity = dict({
558  'i' : "inclusive",
559  'e' : "exclusive"
560 })
561 
562 ## Mapping between 'pdl' MDF marker value and LMF paradigm label Paradigm attribute value (input)
563 pdl_paradigmLabel = dict({
564  "la" : "lexicalized affix",
565  "cc" : "conjugation class",
566  "past" : "past stem",
567  "comit" : "comitative",
568  "constr" : "construction",
569  "dir" : "directional",
570  "ir" : "irregularity",
571  "cl" : "classifier"
572 })
573 
574 ## Possible values allowed for 'sd' MDF marker
575 sd_range = set([
576  "Nagri", "nAgri", "Agriculture", # agriculture
577  "Nanim", # animal
578  "Nboat", # boat related
579  "Nbody", "nBody", "Body", # body part
580  "Ncult", # material culture
581  "Nfish", # fish related
582  "Nfood", # food related
583  "Ngovt", # government
584  "Nhouse", # house related
585  "Ninsect", # insect
586  "Ninstr", # instrument
587  "Nkin", # kinship
588  "Nloc", # locative noun
589  "Nnature", # nature/meteorological
590  "Npart", # part of a larger whole
591  "Nplant", # plant
592  "Nresult", # noun of result
593  "Nrit", # ritual
594  "Nsick", # sickness/medicine
595  "Nsocial", # social relations (non-kin)
596  "Ntime", # time
597  "Vaffect", # affect (hit, kick, knock, hammer)
598  "Vagri", # agriculture
599  "Vbody", # bodily function
600  "Vcarry", "vCarry", "Carry", # carry verb
601  "Vcog", # verb of cognition
602  "Vcolor", # color verb
603  "Vcut", "vCut", "Cut", # cutting verb
604  "Veffect", # verb of effect
605  "Vemot", # verb expressing emotion
606  "Vevent", # verb naming or characterizing a whole event
607  "Vexchange", # verb of exchange (give, receive, take, get)
608  "Vhit", # hitting verb
609  "Vhold", # holding verb
610  "Vhunt", # hunting related
611  "Vmotion", # verb of locomotion
612  "Vposture", # verb of posture or rest
613  "Vrit", # verb describing ritual
614  "Vsee", # verb of perception
615  "Vsize", # verb of dimension
616  "Vsocial", # verb expressing social relationship
617  "Vspeak", # speech-act verb
618  "Vspeed", # verb of speed
619  "Vtouch", # touching verb
620  "Vvalue", # verb expressing value
621  "Vweath", # weather verbs (rain, fog)
622  "Vweight", # verb expressing weight
623  "ADJage", # age
624  "ADJbodily", # bodily function
625  "ADJcol", # color adjective
626  "ADJemot", # emotion/human propensity
627  "ADJphys", # physical property (hard, clean, hot)
628  "ADJsize", "adjSize", "Size", # size/dimension
629  "ADJspeed", "adjSpeed", "Speed", # speed
630  "ADJtext", # texture
631  "ADJval" # value (good, bad, nice)
632 ])
633 
634 ## Possible values allowed for 'lf' MDF marker
635 lf_range = set([
636  "Ant", # Antonym
637  "Caus", # Causal
638  "Compound", # Lexicalized compound using headword not easily handled by other lexical functions
639  "Cpart", # Counterpart (complement, conversive)
640  "Degrad", # Degraded degree or state
641  "Feel", # Feeling or sensation associated with headword
642  "Gen", # Generic
643  "Group", # Collective/group
644  "Head", # Head or leader of group
645  "Idiom", # Idiom
646  "Mat", # Material used to make headword
647  "Max", # Superlative degree of headword
648  "Min", # Diminished degree of headword
649  "Nact", # Actor noun
650  "Nben", # Benefactee noun
651  "Ndev", # Deverbal noun
652  "Ninst", # Instrumental noun
653  "Ngoal", # Goal of action
654  "Nloc", # Locative noun
655  "Nug", # Undergoer noun
656  "ParS", # Parallelism representing Same as headword
657  "ParD", # Parallelism representing Different end of scale
658  "Part", # Part of headword
659  "Phase", # Phase of headword
660  "Prep", # Preparatory activity
661  "Res", # Consequence or resulting state
662  "Serial", # Conventionalized serial verb combination not clearly handled by other lexical functions
663  "Sim", # Similar type at same level of hierarchy
664  "Sit", # Situation or activity typically associated with headword
665  "Sound", # Sound associated with headword
666  "Spec", # Specific (kind of, type of, species)
667  "Start", # Beginning phase of headword (inceptive)
668  "Stop", # Final phase of headword (cessative)
669  "Syn", # Synonym (same range of meaning)
670  "SynD", # Synonym in another dialect of the same language
671  "SynL", # Loan synonym fully assimilated into language
672  "SynR", # Synonym in another register of same language
673  "SynT", # Taboo synonym
674  "Unit", # Single occurrence of headword
675  "Vwhole", # Verb of the whole
676  "Whole" # Whole of which the headword is a part
677 ])
def get_bw
Functions to process some MDF fields (output)
Definition: mdf.py:248
def set_bw
Functions to process some MDF fields (input)
Definition: mdf.py:10