Git Product home page Git Product logo

suomilog's Introduction

Suomilog

Suomilog is a toolkit for parsing context-free grammars that have embedded morphological information. It's intended use is parsing Finnish sentences and it includes a module that can parse and generate inflected Finnish sentences using libvoikko as back-end.

Context-free grammars

The suomilog.patternparser module is used for parsing context-free grammars. Suomilog grammars are context-free grammars that have additional morphological information. Below is an example.

.FEATURE ::= .HUMAN{omanto} nimi{$}
.FEATURE ::= .HUMAN{omanto} ikä{$}

.HUMAN ::= mies{$}
.HUMAN ::= nainen{$}
.HUMAN ::= ihminen{$}
.HUMAN ::= .ADJECTIVE{$} .HUMAN{$}

.ADJECTIVE ::= ahkera{$}
.ADJECTIVE ::= kaunis{$}
.ADJECTIVE ::= erittäin .ADJECTIVE{$}

In Suomilog grammars nonterminals are marked with a dot and all other symbols are terminals.

Morphological information is written in braces after a symbol. For example kaunis{omanto} would match the word kauniin. A dollar $ means that the morphological information is passed forward. So .HUMAN{omanto} for example mathes miehen, naisen, ihmisen, ahkeran miehen, and so on.

The braces can contain multiple form names separated with commas. For example, tehdä{-minen,omanto} would match tekemisen. In code these form names are called "bits".

For example usage, see the examples/ folder.

Finnish morphology

The suomilog.finnish module contains tools for Finnish morphological parsing and generation. It uses libvoikko as its back-end.

Supported forms are at least (there can be others as some are directly from Voikko's format and not all supported by Voikko are listed here):

Bit name Description Example
nimento nominative case kissa
omanto genitive case kissan
osanto partitive case kissaa
olento essive case kissana
tulento translative case kissaksi
ulkotulento allative case kissalle
ulkoolento adessive case kissalla
ulkoeronto ablative case kissalta
sisatulento illative case kissaan
sisaolento inessive case kissassa
sisaeronto elative case kissasta
vajanto abessive case kissatta
keinonto instructive case kissoin
seuranto comiitative case kissoineni
kerrontosti adverb kauniisti
yksikkö singular kissa
monikko plural kissat
nimisana noun kissa
laatusana adjective kaunis
teonsana verb nähdä
lukusana numeral kaksi
-minen MINEN-infinitive näkeminen
-ma MA-infinitive näkemä
-e E-infinitive nähden
-a A-infinitive nähdä
imperatiivi imperative näe
indikatiivi indicative näet
konditionaali conditional näkisit
potentiaali potential nähnet
1 first person näen
2 second person näet
3 third person näkee

The function suomilog.finnish.tokenize(text) is used to tokenize words:

import suomilog.finnish as f
print(f.tokenize("kissa käveli kadulla"))
# [Token('kissa', [('kissa', {'nimento', 'yksikkö', 'nimisana'})]), Token('käveli', [('kävellä', {'3', 'teonsana', 'yksikkö', 'indikatiivi'})]), Token('kadulla', [('katu', {'ulkoolento', 'yksikkö', 'nimisana'})])]

The function suomilog.finnish.inflect(word, case, plural) is used to inflect nouns, adjectives and numerals:

import suomilog.finnish as f
print(f.inflect("kissa", "osanto", True)) # kissoja

suomilog's People

Contributors

fergusq avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

simbaninja917

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.