Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#made by Ridvan Karaman
def responce(sentence):
resp = respond(sentence)
return resp
def find_pronoun(sent):
""" finds a preferred pronoun to respond with, given a sentence. returns none if no candidate"""
pronoun = None
for word, part_of_speech in sent.pos_tags:
if part_of_speech == 'PRP' and word.lower() == 'you':
pronoun = 'I'
elif part_of_speech == 'PRP' and word == 'I':
pronoun = 'You'
return pronoun
def find_verb(sent):
""" finds verb in a sentence"""
verb = None
pos = None
for word, part_of_speech in sent.pos_tags:
if part_of_speech.startswith('VB'):
verb = word
pos = part_of_speech
break
return verb, pos
def find_noun(sent):
""" finds the best candidate noun in a sentence"""
noun = None
if not noun:
for w,p in sent.pos_tags:
if p == 'NN'
noun = w
break
if noun:
print("Found noun: %s" + noun)
return noun
def find_adjective(sent):
adj = None
for w,p in sent.pos_tags:
if p == 'JJ':
adj = w
break
return adj
def construck_responce(pronoun,noun,verb):
resp = []
if pronoun:
resp.append(pronoun)
if noun:
pronoun = "an" if vowell_check(noun) else "a"
resp.append(pronoun + " " + noun)
resp.append(random.choice(( "lol", "though", "somehow", "")))
return " ".join(resp)