e search trên gg nhưng ko ra xin a/c chỉ giúp
def get attributes(input,context,attributes):
'''This function marks the entities in user input, and update
the attributes dictionary'''
#Can use context to to context specific attribute fetching
if context.name.startswith('IntentComplete'):
return attributes, uinput
else:
files = os.listdir('./entities/')
entities = {}
for fil in files:
lines = open('./entities/'+fil).readlines()
for i, line in enumerate(lines):
lines[i] = line[:-1]
entities[fil[:-4]] = '|'.join(lines)
for entity in entities:
for i in entities[entity].split('|'):
if i.lower() in uinput.lower():
attributes[entity] = i
for entity in entities:
uinput = re.sub(entities[entity], r'$'+entity,uinput,flags=re.IGNORECASE)
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?