chatbot update
parent
317a515b55
commit
cf7c875cfc
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,37 @@
|
||||
import sys
|
||||
from sys import stdin, stdout
|
||||
|
||||
|
||||
def seven(text):
|
||||
fpath = open('91K nouns.txt')
|
||||
nouns = fpath.readlines()
|
||||
separated = text.split() #use nltk tokenize instead
|
||||
#print(separated)
|
||||
new_separated = []
|
||||
for word in separated:
|
||||
word = word.lower() + '\n'
|
||||
if word in nouns:
|
||||
position = nouns.index(word)
|
||||
new_word = nouns[position + 7]
|
||||
#print(" replacing", new_position)
|
||||
new_separated.append(new_word.strip())
|
||||
else:
|
||||
#print("notinlist")
|
||||
#print("adding to new_separated ", word)
|
||||
new_separated.append(word.strip())
|
||||
#print(new_separated)
|
||||
return ' '.join(new_separated)
|
||||
|
||||
text = stdin.read()
|
||||
output = seven(text)
|
||||
print(output)
|
||||
|
||||
#sentence = input('What is your sentence? ')
|
||||
#print(seven(sentence))
|
||||
|
||||
|
||||
# pytest requires that you name your tests with test_<your-name>
|
||||
# run with the 'pytest' command in your terminal
|
||||
#def test_seven():
|
||||
# assert seven('Baboons') == 'babushkas'
|
||||
# assert seven('Baboons,') == 'babushkas'
|
Loading…
Reference in New Issue