def main(): text_path = sys.argv[1] seq_len = int(sys.argv[2]) header = sys.argv[3] test_size = int(sys.argv[4]) if len(sys.argv) > 4 else 10 text = md.load_text(text_path) train_size = int((len(text) - seq_len - 1) * (100 - test_size) / 100) dict_path = os.path.splitext(text_path)[0] + ".pkl" md.make_dict(text,dict_path) char_table = md.load_dict(dict_path) text_ids = char_table.str2ids(text) lines = make_data(text_ids,seq_len) headline = make_headline(seq_len) create_train_data(lines, headline, header, train_size)
def test_same_size(): """ Test that it can make dictionaries from lists of same size. """ list1 = ['a', 'b', 'c'] list2 = [1, 3, 3] assert make_dict(list1, list2) == {'a': 1, 'b': 3, 'c': 3}
def test_large_list1(): """ Test that it can make dictionaries when list of keys is larger than list of values. """ list1 = ['a', 'b', 'c', 'd'] list2 = [1, 3, 4] assert make_dict(list1, list2) == {'a': 1, 'b': 3, 'c': 4, 'd': None}
def chulbal(test=True): chul_ma = False test = test while not chul_ma: now = datetime.today().strftime(format='%H:%M') today = datetime.today().strftime("%Y%m%d") dict_made = make_dict()['jisu_dict_s'] chul_ma = True #코스피 art = article.kos_pi_daq(jisu_dict_s=dict_made, pi_daq='kospi', chul_ma=chul_ma) post.do_temp(title=art['title'], article=art['article']) post.do_mbot(title=art['title'], article=art['article'], rcept_no=str(today) + '11', rm="출발") # c: # 출발 , # a: 순서 print(art['title']) #코스닥 art = article.kos_pi_daq(jisu_dict_s=dict_made, pi_daq='kosdaq', chul_ma=chul_ma) post.do_temp(title=art['title'], article=art['article']) post.do_mbot(title=art['title'], article=art['article'], rcept_no=str(today) + '12', rm="출발") bot('c', "출발 기사 올렸습니다!\n" + "http://testbot.ddns.net:5231/bot_v3") #환율 dict_made['원/달러'] = yon_data() # print("연합 환율 작성. 1분뒤 업로드") # time.sleep(60) art = article.dol_won(jisu_dict_s=dict_made, chul_ma=chul_ma) post.do_temp(title=art['title'], article=art['article']) post.do_mbot(title=art['title'], article=art['article'], rcept_no=str(today) + '13', rm="출발") #2보 art = article.second_bo(jisu_dict_s=dict_made, chul_ma=chul_ma) post.do_temp(title=art['title'], article=art['article']) post.do_mbot(title=art['title'], article=art['article'], rcept_no=str(today) + '14', rm="출발") bot('c', "환율, 2보 올렸습니다!\n" + "http://testbot.ddns.net:5231/bot_v3") print('출발')
def magam(test=True, be_0=None): chul_ma = True test = test while chul_ma: now = datetime.today().strftime(format='%H:%M') today = datetime.today().strftime("%Y%m%d") dict_made = make_dict(be_0=be_0)['jisu_dict_s'] chul_ma = False #코스피 art = article.kos_pi_daq(jisu_dict_s=dict_made, pi_daq='kospi', chul_ma=chul_ma) post.do_temp(title=art['title'], article=art['article']) post.do_mbot(title=art['title'], article=art['article'], rcept_no=str(today) + '31', rm="마감") print(art['title']) #코스닥 art = article.kos_pi_daq(jisu_dict_s=dict_made, pi_daq='kosdaq', chul_ma=chul_ma) post.do_temp(title=art['title'], article=art['article']) post.do_mbot(title=art['title'], article=art['article'], rcept_no=str(today) + '32', rm="마감") bot('c', "마감 기사 올렸습니다!\n" + "http://testbot.ddns.net:5231/bot_v3") #환율 dict_made['원/달러'] = yon_data() # print("연합 환율 작성. 1분뒤 업로드") # time.sleep(20) art = article.dol_won(jisu_dict_s=dict_made, chul_ma=chul_ma) post.do_temp(title=art['title'], article=art['article']) post.do_mbot(title=art['title'], article=art['article'], rcept_no=str(today) + '33', rm="마감") #2보 art = article.second_bo(jisu_dict_s=dict_made, chul_ma=chul_ma) post.do_temp(title=art['title'], article=art['article']) post.do_mbot(title=art['title'], article=art['article'], rcept_no=str(today) + '34', rm="마감") bot('c', "환율, 2보 올렸습니다!\n" + "http://testbot.ddns.net:5231/bot_v3") print('마감')
# -*- coding: utf-8 -*- from scrapper import get_reviews from save import save_to_file from wordclouding import tabelog_wordcloud from make_dict import make_dict data = get_reviews() # 워드클라우드로 표현 tabelog_wordcloud(make_dict(data)) # 크롤링한 리뷰정보를 스프레드시트로 저장 save_to_file(data)