forked from Hirep/Sheva
-
Notifications
You must be signed in to change notification settings - Fork 1
/
morph.py
28 lines (24 loc) · 860 Bytes
/
morph.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""This module contains tools for our morphological analyzer.
"""
class Word:
"""This class stores info about word
__init__(
str word # is a word itself
int id # gets id from root dict
str begin # beginning of the word (word-ending)
str ending # ending of the word
)
"""
def __init__(self, word, id, begin, ending):
self.word = word
self.id = id
self.begin = begin
self.ending = ending
self.role = None
def __str__(self):
return "{}, {}, {}, {}".format(self.word, self.id, self.ending, self.role)
def get_word_ending(word):
""" str word # word to take ending from
returns str ending # just what's left after taking out word root found in dict
"""
return word[len(beg):]