-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmorphology.py
More file actions
42 lines (32 loc) · 997 Bytes
/
Copy pathmorphology.py
File metadata and controls
42 lines (32 loc) · 997 Bytes
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
30
31
32
33
34
35
36
37
38
39
40
41
42
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
from fst import FST
class Parser():
def __init__(self):
pass
def generate(self, analysis):
"""Generate the morphologically correct word
e.g.
p = Parser()
analysis = ['p','a','n','i','c','+past form']
p.generate(analysis)
---> 'panicked'
"""
# Let's define our first FST
f1 = FST('morphology-generate')
output = ['p','a','n','i','c','k','e','d']
return ''.join(output)
def parse(self, word):
"""Parse a word morphologically
e.g.
p = Parser()
word = ['p','a','n','i','c','k','i','n','g']
p.parse(word)
---> 'panic+present participle form'
"""
# Ok so now let's do the second FST
f2 = FST('morphology-parse')
output = ['p','a','n','i','c','+present participle form']
return ''.join(output)