-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmerge.py
42 lines (37 loc) · 969 Bytes
/
merge.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
30
31
32
33
34
35
36
37
38
39
40
41
42
class Word:
"""docstring for Word."""
def __init__(self, lexical_item):
super(Word, self).__init__()
self.name = name
self.category = "TBD"
lexicon = {
"house" : ["N", "sg"],
"to be" : ["V"],
"red" : ["ADJ", "color"]
}
def merge(a, *args):
sequence = ""
if args:
sequence += a
for word in args:
sequence += " " + word
return sequence
else:
return a
def get_category(word):
try:
pos = lexicon.get(word)[0]
except:
return "The Lexicon has not yet learned " + word.upper()
result = "Grammatical category for " + word.upper() + ": "
if pos == "V":
return result + "verb"
elif pos == "N":
return result + "noun"
elif pos == "ADJ":
return result + "adjective"
print(merge("house", "hey"))
# print(get_category("to be"))
# print(get_category("house"))
# print(get_category("red"))
# print(get_category("blue"))