-
Notifications
You must be signed in to change notification settings - Fork 3
/
morph.py
29 lines (25 loc) · 914 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
29
"""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
self.syntax_role = None
def __str__(self):
return "{}, {}, {}, {}, {}".format(self.word, self.id, self.ending, self.role, self.syntax_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):]