Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.