Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

option to add macrons and breves in collected.json #12

Open
mcorne opened this issue Sep 15, 2021 · 1 comment
Open

option to add macrons and breves in collected.json #12

mcorne opened this issue Sep 15, 2021 · 1 comment

Comments

@mcorne
Copy link

mcorne commented Sep 15, 2021

it would be nice to add an option to build https://github.com/cltk/lat_models_cltk/blob/master/lemmata/collatinus/collected.json with macrons and breves in models, lemmas (except keys) and maps keys so the decliner could generate accentuated words
for example:

"uita": {
    "R": {"1": [ "1", "" ] }, 
    "abs": [], 
    "des": {
        "1": [[ "1", [ "ă" ]]], 
        "2": [[ "1", [ "ă" ]]], 
        "3": [[ "1", [ "ăm" ]]], 
        "4": [[ "1", [ "āe" ]]], 
        "5": [[ "1", [ "āe" ]]], 
        "6": [[ "1", [ "ā" ]]], 
        "7": [[ "1", [ "āe" ]]], 
        "8": [[ "1", [ "āe" ]]], 
        "9": [[ "1", [ "ās" ]]], 
        "10": [[ "1", [ "ārŭm" ]]], 
        "11": [[ "1", [ "īs" ]]], 
        "12": [[ "1", [ "īs" ]]] }, 
        "suf": [], 
        "sufd": [] 
}
@mcorne
Copy link
Author

mcorne commented Sep 15, 2021

possible fix in https://github.com/cltk/lat_models_cltk/blob/master/lemmata/collatinus/__convert.py:

  • import regex as re so regex rules continue to work
  • normalize strings according to the new ascii option:
def normalize_unicode(lines, ascii=True):
    if ascii:
        lines = unicodedata.normalize('NFKD', lines)
        lines = lines.encode('ASCII', 'ignore').decode()
    else:
        lines = unicodedata.normalize('NFC', lines)
    return lines
  • fix subsequent calls accordingly (this is really a quick fix):
with open("./src/modeles.la", encoding="utf-8") as f:
    lines = normalize_unicode(f.read(), ascii=False).split("\n")
lemmas[normalize_unicode(result["lemma"], ascii=True)] = result
with open("./src/lemmes.la", encoding="utf-8") as f:
    lines = normalize_unicode(f.read(), ascii=False).split("\n")
with open("./src/lem_ext.la", encoding="utf-8") as f:
    lines = normalize_unicode(f.read(), ascii=False).split("\n")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant