Skip to content

Instantly share code, notes, and snippets.

@timokoola
Created July 6, 2017 11:43
Show Gist options
  • Select an option

  • Save timokoola/3f4bd3140a0497f28496f041d3ce5168 to your computer and use it in GitHub Desktop.

Select an option

Save timokoola/3f4bd3140a0497f28496f041d3ce5168 to your computer and use it in GitHub Desktop.
Function to check if a word is an adjective in its baseform in Finnish using libvoikko
from libvoikko import Voikko
v = Voikko("fi")
def adjective(w):
analyzed = v.analyze(w)
for item in analyzed:
if "CLASS" in item and "laatusana" in item["CLASS"] and "SIJAMUOTO" in item and item[
"SIJAMUOTO"] == "nimento" and w == item["BASEFORM"]:
return True
return False
@timokoola
Copy link
Author

Example of Voikko output

In [54]: v.analyze("tiine")
Out[54]:
[{'BASEFORM': 'tiine',
  'CLASS': 'laatusana',
  'COMPARISON': 'positive',
  'FSTOUTPUT': '[Ll][Xp]tiine[X]tiine[Sn][Ny]',
  'NUMBER': 'singular',
  'SIJAMUOTO': 'nimento',
  'STRUCTURE': '=ppppp',
  'WORDBASES': '+tiine(tiine)'}]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment