fmatter / cldflex Goto Github PK
View Code? Open in Web Editor NEWConvert FLEx data to CLDF-ready CSV.
License: Apache License 2.0
Convert FLEx data to CLDF-ready CSV.
License: Apache License 2.0
I try to convert a file in script.
from cldflex.flex2csv import convert
flexinputfilepath = "ende.xml"
corpus = convert(flexinputfilepath)
works fine, as far as I can tell. But I want CLDF, so I say
from cldflex.flex2csv import convert
flexinputfilepath = "ende.xml"
corpus = convert(flexinputfilepath,cldf=True)
This gives me
KeyError: 'Config /home/snordhoff/.config/cldf/catalog.ini has no entry for glottolog'
https://github.com/fmatter/cldflex tells me "pass a dict to the convert methods." I have tried
convert(filename, conf={'Glottocode':'abcd1234'},cldf=True)
convert(filename, conf={'glottolog':'abcd1234'},cldf=True)
, to no avail.
I have also created a yaml file with the content Glottocode: abcd1234
, as asked for by https://github.com/fmatter/cldflex. However, the script complains that it does not find an ini file, and that there is no entry for "glottolog". So I wonder whether yaml or ini is required. In any case, I have also created an ini file in ~/.config.cldf
. I give the content below
[glottolog]
Glottocode = abcd1234
glottolog = abcd1234
This does not help either.
Could you share information how to provide the relevant glotto-information, or, otherwise, how to bypass the test (I do not need the glotto information for my use case).
For the attached input XML file, enclitics are outputted twice in both the vernacular line (=da,=peyang) and the gloss line (=NOM,=COM).
ause=da=da llɨg kälsre=peyang=peyang
...
old woman=NOM=NOM boy small=COM=COM
Expected:
ause=da llɨg kälsre=peyang
old woman=NOM boy small=COM
In the XML file, we find two instances of "da", but only one "NOM" in uppercase, suggesting that indeed certain fields are outputted twice.
<morph type="enclitic" guid="d7f713e1-e8cf-11d3-9764-00c04f186933">
<item type="txt" lang="kit">=da</item>
<item type="cf" lang="kit">=da</item>
<item type="gls" lang="en">=NOM</item>
<item type="msa" lang="en">nominal enclitic</item>
</morph>
<item type="gls" lang="en">nom</item>
<item type="pos" lang="en">nominal enclitic</item>
In line 406 of flex2csv.py
, you split an ID into sentence number (before period) and phrase number (after period). This fails if the sentence number had not been retrieved.
Be tolerant with records without sentence numbers. Users might still want to convert them.
As a quick fix, I used
if "." in rec.get("Sentence_Number", "noperiod"):
rec["Sentence_Number"], rec["Phrase_Number"] = rec["Sentence_Number"].split(".")
return rec
but try/catch or checking for "Sentence_Number" in rec should also work
In line 420 of flex2csv.py
you have
...
(f"segnum_{conf['gloss_lg']}_phrase", "Sentence_Number"),
...
I do not know how often there is a different "segnum" per language in flex files. In my case, the segnum language was set to French, and the value was "3.1", so not particularly localized. The program failed hard and produced no output.
I can of course prepare some yaml file to take care of this, but maybe one could in the case of only one segnum being present for a given sentence simply default to that segnum instead of requiring the language to be specified.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.