Created
February 1, 2019 18:46
-
-
Save eddieantonio/5ce36b574b96204f5e711ed357d66d74 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: UTF-8 -*- | |
# Install `fst_lookup` using pip: | |
# | |
# $ pip install fst-lookup | |
# | |
# Or, if you're using pipenv: | |
# | |
# $ pipenv install fst-lookup | |
# For more documentation see | |
# https://github.com/eddieantonio/fst-lookup | |
from fst_lookup import FST | |
print("Loading the FSTs...") | |
analyzer = FST.from_file('crk-analyzer.fomabin') | |
generator = FST.from_file('crk-generator.fomabin') | |
def print_analysis(wordform): | |
print('', wordform, "could be", end=' ') | |
print(*analyzer.analyze(wordform), sep=' or ') | |
def print_generation(analysis): | |
print('', analysis, "is realized as", end=' ') | |
print(*generator.generate(analysis), sep=' or ') | |
print("Analyze some words:") | |
print_analysis('tipiskâsin') # VII | |
print_analysis('ay-api') # VAI | |
print_analysis('mitâs') # NA/NI | |
print_analysis('kohkom') # NAD | |
print_analysis('mitêh') # NDI | |
print_analysis('nipihk') # super ambiguous form | |
print() | |
print("Generate some words:") | |
print_generation('tipiskâsin+V+II+Ind+Prt+3Sg') # What is tipiskâsin in past tense? | |
print_generation('apiw+V+AI+Ind+Prs+1Sg') # What is "I sit"? | |
print_generation('mitâs+N+A+D+Px1Sg+Pl') # What is "my pants"? | |
print_generation('nôhkom+N+A+D+Der/Dim+N+A+D+Px1Sg+Sg') # What is "my grannie"? | |
print_generation('mitêh+N+I+D+Px2Sg+Sg') # what is "your heart"? | |
print_generation('nipiy+N+I+Loc') # What is "at/on the water"? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment