more_content
This commit is contained in:
parent
3b143e0f73
commit
e705b0498c
|
@ -88,9 +88,9 @@ class ResponseGenerator:
|
|||
return self.db[db_type].iloc[[I[0]][0]].reset_index(drop=True).loc[0]
|
||||
|
||||
|
||||
def gen_response(self, action, utterance=None, username=None, state=None, consec_history=None, chitchat_history=None):
|
||||
def gen_response(self, action, utterance=None, username=None, vrename=None, state=None, consec_history=None, chitchat_history=None):
|
||||
if action == "Help":
|
||||
return "Hey it's Janet! I am here to help you make use of the datasets and papers in the catalogue. I can answer questions whose answers may be inside the papers. I can summarize papers for you. I can also chat with you. So, whichever it is, I am ready to chat!"
|
||||
return "Hey it's Janet! I am here to help you make use of the datasets and papers in the catalogue of the " + vrename +" VRE. I can answer questions whose answers may be inside the papers. I can summarize papers for you. I can also chat with you. So, whichever it is, I am ready to chat!"
|
||||
elif action == "Recommend":
|
||||
prompt = self.recommender.make_recommendation(username)
|
||||
if prompt != "":
|
||||
|
|
30
VRE.py
30
VRE.py
|
@ -186,8 +186,19 @@ class VRE:
|
|||
self.db['paper_db'] = paper_df.sort_values(by='metadata_created', ascending=True)
|
||||
self.db['dataset_db'] = dataset_df.sort_values(by='metadata_created', ascending=True)
|
||||
self.db['post_db'] = post_df.sort_values(by='time', ascending=True)
|
||||
self.db['content_db'] = content_df
|
||||
|
||||
|
||||
other_content_df = pd.DataFrame(columns=['id', 'paperid', 'content'])
|
||||
for i, post in post_df.iterrows():
|
||||
self.content_counter+=1
|
||||
other_content_df.loc[str(self.content_counter)] = [self.content_counter, -1, post['author'] + ' posted: ' + post['content'] + ' It is about ' + ', '.join(post['tags'])]
|
||||
for i, description in dataset_df.iterrows():
|
||||
self.content_counter+=1
|
||||
other_content_df.loc[str(self.content_counter)] = [self.content_counter, -2, description['title'] + ' is a dataset. ' + description['notes'] + ' It is about ' + ', '.join(description['tags']) ]
|
||||
for i, description in paper_df.iterrows():
|
||||
self.content_counter+=1
|
||||
other_content_df.loc[str(self.content_counter)] = [self.content_counter, -3, description['title'] + ' is a paper. ' + description['notes'] + ' It is about ' + ', '.join(description['tags']) ]
|
||||
|
||||
self.db['content_db'] = pd.concat(content_df, other_content_df)
|
||||
self.db['paper_db'].to_json(self.directory + self.name + '_paper.json')
|
||||
self.db['dataset_db'].to_json(self.directory + self.name + '_dataset.json')
|
||||
|
||||
|
@ -271,9 +282,21 @@ class VRE:
|
|||
self.db['post_db'] = pd.concat([self.db['post_db'], post_df.sort_values(by='time', ascending=True)])
|
||||
self.db['post_db'].to_json(self.directory+self.name+'_post.json')
|
||||
|
||||
other_content_df = pd.DataFrame(columns=['id', 'paperid', 'content'])
|
||||
for i, post in post_df.iterrows():
|
||||
self.content_counter+=1
|
||||
other_content_df.loc[str(self.content_counter)] = [self.content_counter, -1, post['author'] + ' posted: ' + post['content'] + ' It is about ' + ', '.join(post['tags'])]
|
||||
for i, description in dataset_df.iterrows():
|
||||
self.content_counter+=1
|
||||
other_content_df.loc[str(self.content_counter)] = [self.content_counter, -2, description['title'] + ' is a dataset. ' + description['notes'] + ' It is about ' + ', '.join(description['tags']) ]
|
||||
for i, description in paper_df.iterrows():
|
||||
self.content_counter+=1
|
||||
other_content_df.loc[str(self.content_counter)] = [self.content_counter, -3, description['title'] + ' is a paper. ' + description['notes'] + ' It is about ' + ', '.join(description['tags']) ]
|
||||
|
||||
|
||||
self.db['paper_db'].to_json(self.directory + self.name + '_paper.json')
|
||||
self.db['dataset_db'].to_json(self.directory + self.name + '_dataset.json')
|
||||
self.db['content_db'] = pd.concat([self.db['content_db'], content_df])
|
||||
self.db['content_db'] = pd.concat([self.db['content_db'], content_df, other_content_df])
|
||||
self.db['content_db'].to_json(self.directory + self.name + '_content.json')
|
||||
if not paper_df.empty or not dataset_df.empty or not content_df.empty or not post_df.empty:
|
||||
self.new_income = True
|
||||
|
@ -297,6 +320,7 @@ class VRE:
|
|||
continue
|
||||
modline+=line[i]
|
||||
modline = re.sub(r'\.+', ".", modline)
|
||||
modline = re.sub("\[.*?\]","", modline)
|
||||
return modline
|
||||
|
||||
def check_if_sentence(self, sentence):
|
||||
|
|
6
main.py
6
main.py
|
@ -90,13 +90,13 @@ def predict():
|
|||
state = {'help': True, 'inactive': False, 'modified_query':"", 'intent':""}
|
||||
dm.update(state)
|
||||
action = dm.next_action()
|
||||
response = rg.gen_response(action)
|
||||
response = rg.gen_response(action, vrename=vre.name)
|
||||
message = {"answer": response}
|
||||
elif text == "<RECOMMEND_ON_IDLE>":
|
||||
state = {'help': False, 'inactive': True, 'modified_query':"recommed: ", 'intent':""}
|
||||
dm.update(state)
|
||||
action = dm.next_action()
|
||||
response = rg.gen_response(action, username=user.username)
|
||||
response = rg.gen_response(action, username=user.username, vrename=vre.name)
|
||||
message = {"answer": response}
|
||||
new_state = {'modified_query': response}
|
||||
dm.update(new_state)
|
||||
|
@ -117,7 +117,7 @@ def predict():
|
|||
rec.generate_recommendations(username, new_user_interests, new_vre_material)
|
||||
dm.update(state)
|
||||
action = dm.next_action()
|
||||
response = rg.gen_response(action=action, utterance=state['modified_query'], state=dm.get_recent_state(), consec_history=dm.get_consec_history(), chitchat_history=dm.get_chitchat_history())
|
||||
response = rg.gen_response(action=action, utterance=state['modified_query'], state=dm.get_recent_state(), consec_history=dm.get_consec_history(), chitchat_history=dm.get_chitchat_history(), vrename=vre.name)
|
||||
message = {"answer": response, "query": text, "cand": "candidate", "history": dm.get_consec_history(), "modQuery": state['modified_query']}
|
||||
if state['intent'] == "QA":
|
||||
response = response.split("_______ \n The answer is: ")[1]
|
||||
|
|
Loading…
Reference in New Issue