Datasets:
Download code/patches/morphology.patch from Chapimenge/amharic-gemination-lexicon: direct link, hf CLI and curl.
- Browser
- Download file 1.94 kB
-
https://huggingface.co/datasets/Chapimenge/amharic-gemination-lexicon/resolve/main/code/patches/morphology.patch
- Command line
-
hf download hf://datasets/Chapimenge/amharic-gemination-lexicon/code/patches/morphology.patch
-
curl -L -o morphology.patch https://huggingface.co/datasets/Chapimenge/amharic-gemination-lexicon/resolve/main/code/patches/morphology.patch
1.94 kB
| --- a/hm/morpho/morphology.py | |
| +++ b/hm/morpho/morphology.py | |
| # Files where unanalyzed words and abbreviations (surface forms) are found. | |
| WORDS1 = "words1.srf" | |
| WORDSM = "wordsM.srf" | |
| + | |
| + @staticmethod | |
| + def _ortho_phon(lines): | |
| + """First two whitespace fields of each real line, as ortho -> phon.""" | |
| + out = {} | |
| + for line in lines: | |
| + line = line.strip() | |
| + if not line or line.startswith("#"): | |
| + continue | |
| + parts = line.split() | |
| + if len(parts) >= 2: | |
| + out[parts[0]] = parts[1] | |
| + return out | |
| ABBREVS = "abbrev.srf" | |
| def __init__(self, pos_morphs=[], punctuation='', characters='', abbrev_chars='.'): | |
| self.words1 = dict([(w[0].strip(), w[1:]) for w in pairs]) | |
| else: | |
| # Read in ortho:phon pairs as a dict | |
| - self.words_phon1 = dict([w.strip().split() for w in file]) | |
| + # words1.srf is `ortho phon POS`, three fields, and | |
| + # carries `#` comment lines. dict() of the raw split | |
| + # therefore raised on the first real entry, which took | |
| + # the whole phonetic path down for Amharic. | |
| + self.words_phon1 = Morphology._ortho_phon(file) | |
| else: | |
| self.words1 = [] | |
| self.words_phon1 = {} | |
| self.wordsM = dict([(w[0].strip(), w[1:]) for w in pairs]) | |
| else: | |
| # Read in ortho:phon pairs as a dict | |
| - self.words_phonM = dict([w.strip().split() for w in file]) | |
| + self.words_phonM = Morphology._ortho_phon(file) | |
| else: | |
| self.wordsM = [] | |
| self.words_phonM = {} | |