text stringlengths 1 93.6k |
|---|
pids, scores = calculate_recommendation(tags, time_delta=args.time_delta)
|
if all(len(lst) == 0 for tag, lst in pids.items()):
|
print("skipping user %s, no recommendations were produced" % (user, ))
|
continue
|
# render the html
|
print("rendering top %d recommendations into a report for %s..." % (args.num_recommendations, user))
|
html = render_recommendations(user, tags, pids, scores)
|
# temporarily for debugging write recommendations to disk for manual inspection
|
if os.path.isdir('recco'):
|
with open('recco/%s.html' % (user, ), 'w') as f:
|
f.write(html)
|
# actually send the email
|
print("sending email...")
|
send_email(email, html)
|
num_sent += 1
|
# zzz?
|
# time.sleep(1 + random.uniform(0, 2))
|
print("done.")
|
print("sent %d emails" % (num_sent, ))
|
# <FILESEP>
|
from question_classifier import QuestionClassifier
|
from question_parser import QuestionParser
|
from answer_search import AnswerSearcher
|
from lib.errors import QuestionError
|
class CAChatBot:
|
def __init__(self, mode: str = 'cmd'):
|
assert mode in ('cmd', 'notebook', 'web')
|
self.classifier = QuestionClassifier()
|
self.parser = QuestionParser()
|
self.searcher = AnswerSearcher()
|
self.mode = mode
|
print("欢迎与小航对话,请问有什么可以帮助您的?")
|
self.default_answer = '抱歉!小航能力有限,无法回答您这个问题。可以联系开发者哟!'
|
self.goodbye = '小航期待与你的下次见面,拜拜!'
|
def query(self, question: str):
|
try:
|
final_ans = ''
|
# 开始查询
|
result = self.classifier.classify(question)
|
if result is None or result.is_qt_null():
|
return self.default_answer
|
result = self.parser.parse(result)
|
answers = self.searcher.search(result)
|
# 合并回答与渲染图表
|
for answer in answers:
|
final_ans += (answer.to_string().rstrip('。') + '。')
|
if answer.have_charts() and self.mode != 'web':
|
answer.combine_charts()
|
answer.render_chart(result.raw_question)
|
# 依不同模式返回
|
if self.mode == 'notebook':
|
return final_ans, answers[0].get_chart() # None or chart
|
elif self.mode == 'web':
|
return final_ans, answers[0].get_charts() # chart list
|
else: # default: 'cmd'
|
return final_ans
|
except QuestionError as err:
|
return err.args[0]
|
def run(self):
|
while 1:
|
question = input('[我]: ')
|
if question.lower() == 'q':
|
print(self.goodbye)
|
break
|
answer = self.query(question)
|
print('[小航]: ', answer)
|
# <FILESEP>
|
'''
|
* Copyright (c) 2023, Dachuan Shi.
|
* Copyright (c) 2022, salesforce.com, inc.
|
* All rights reserved.
|
* For full license text, see LICENSE.txt file in the repo root
|
* By Dachuan Shi
|
'''
|
import argparse
|
import os
|
from regex import B
|
import ruamel_yaml as yaml
|
import numpy as np
|
import random
|
import json
|
from pathlib import Path
|
import torch
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.