-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
136 lines (117 loc) · 3.53 KB
/
main.py
File metadata and controls
136 lines (117 loc) · 3.53 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import json
with open('words.txt', 'r') as outfile:
data = json.load(outfile)
def is_noun(x):
if x in data['nouns'][0]:
print(x + " is a noun.")
return True
else:
return False
def is_verb(x):
if x in data['verbs'][0]:
print(x + " is a verb.")
return True
else:
return False
def is_particle(x):
if x in data['particles'][0]:
print(x + " is a particle")
return True
else:
return False
def is_adverb(x):
if x in data['adverbs'][0]:
print(x + " is an adverb")
return True
else:
return False
def is_adjective(x):
if x in data['adjectives'][0]:
print(x + " is an adjective")
return True
else:
return False
def add_noun(x):
print(data['nouns'][0])
data['nouns'][0][x] = 0
print(data['nouns'][0])
def add_verb(x):
print(data['verbs'][0])
data['verbs'][0][x] = 0
print(data['verbs'][0])
def add_particle(x):
print(data['particles'][0])
data['particles'][0][x] = 0
print(data['particles'][0])
def add_adverb(x):
print(data['adverbs'][0])
data['adverbs'][0][x] = 0
print(data['adverbs'][0])
def add_adjective(x):
print(data['adjectives'][0])
data['adjectives'][0][x] = 0
print(data['adjectives'][0])
def find_word(x):
noun = is_noun(x)
verb = is_verb(x)
particle = is_particle(x)
adverb = is_adverb(x)
adjective = is_adjective(x)
if noun == True:
print("noun")
elif verb == True:
print("verb")
elif particle == True:
print("particle")
elif adverb == True:
print("particle")
elif adjective == True:
print("particle")
else:
print("I'm sorry, I don't understant " + x + ".")
print("Is this a real word or a typo?")
answer = (input(">> "))
if answer == "real word":
print("It is a real word.")
print("Is it a noun, a verb, adjective, adverb, or a particle?")
answer_wordtype = input(">> ")
answer_wordtype = answer_wordtype.lower()
if answer_wordtype == "noun":
add_noun(x)
if answer_wordtype == "verb":
add_verb(x)
if answer_wordtype == "particle":
add_particle(x)
if answer_wordtype == "adverb":
add_adverb(x)
if answer_wordtype == "adjective":
add_adjective(x)
elif answer == "type":
print("Could you correct the word for me?")
else:
print("I'm sorry, I don't understand.")
print("Please enter real word or type.")
#We've put the words into parts of speech,
#now we need to identify subjects and objects, etc.
#this is how we will form the sentence.
#script
count = 0
while count < 10:
print("Give me a sentence")
sentence = input(">> ")
sentence = sentence.split()
print(sentence)
for x in sentence:
x = x.lower()
find_word(x)
print("Would you like to continue?")
answer = input(">> ")
answer = answer.lower()
if answer == 'no':
break
#print("In your sentence, " + subj + " " + conjugated_verb + " " + particle + " " + obj + " " + location_particle + " " + location.
print(data)
outfile.close()
with open('words.txt', 'w') as outfile:
json.dump(data, outfile)
outfile.close()