linpershey commited on
Commit
4a96867
1 Parent(s): 7cfd43a

move tests outside sheet

Browse files
Files changed (2) hide show
  1. sheet.py +0 -47
  2. test.py +65 -0
sheet.py CHANGED
@@ -43,16 +43,6 @@ def get_serp( query: str, google_domain: str, gl: str, lr: str) -> dict:
43
  # return result['organic_results'][0]
44
  return result
45
 
46
- def test_get_serp():
47
- # query = "原味商行"
48
- # query = "南投縣中寮鄉中寮村鄉林巷43號 和興商店"
49
- # query = "啓輝環管企業社"
50
- # query = "蘭陽客棧小吃店"
51
- # query = '韓笑味食品有限公司'
52
- # query = '小阿姨的店'
53
- query = '達米娜魚料理店'
54
- res = get_serp(query, google_domain='google.com.tw')
55
- print(res)
56
 
57
  def get_condensed_result(result):
58
  """
@@ -79,16 +69,6 @@ def get_condensed_result(result):
79
  # print( condensed_results )
80
  return condensed_result
81
 
82
- def test_get_condensed_result():
83
- # query = "原味商行"
84
- # query = "南投縣中寮鄉中寮村鄉林巷43號 和興商店"
85
- # query = "啓輝環管企業社"
86
- # query = "蘭陽客棧小吃店"
87
- # query = '韓笑味食品有限公司'
88
- # query = '小阿姨的店'
89
- query = '達米娜魚料理店'
90
- res = get_serp(query)
91
- cond_res = get_condensed_result(res)
92
 
93
  def compose_analysis( client, query, search_results, classes: list, model: str = 'gpt-3.5-turbo-0125'):
94
  """
@@ -138,18 +118,6 @@ def compose_analysis( client, query, search_results, classes: list, model: str =
138
  response = chat_completion.choices[0].message.content
139
  return response
140
 
141
- def test_compose_analysis():
142
- # query = "原味商行"
143
- # query = "南投縣中寮鄉中寮村鄉林巷43號 和興商店"
144
- # query = "啓輝環管企業社"
145
- # query = "蘭陽客棧小吃店"
146
- # query = '韓笑味食品有限公司'
147
- # query = '小阿姨的店'
148
- query = '達米娜魚料理店'
149
- res = get_serp(query)
150
- cond_res = get_condensed_result(res)
151
- resp = compose_analysis( client, query = query, search_results = cond_res)
152
- print( resp )
153
 
154
  def compose_classication(
155
  client,
@@ -202,12 +170,6 @@ def compose_classication(
202
  response = chat_completion.choices[0].message.content
203
  return response
204
 
205
- def test_compose_classification( evidence):
206
- """
207
- """
208
- evidence = '[{"title": "年年有魚餐飲有限公司- 店家介紹", "snippet": "統一編號. 93769370 · 公司狀況. 營業中 · 公司名稱. 年年有魚餐飲有限公司 · 公司類型. 有限公司 · 資本總額. 6000000 · 所在地. 臺中市西區民龍里臺灣大道2段159號1樓."}, {"title": "年年有魚餐飲有限公司", "snippet": "營業地址, 臺中市西區民龍里臺灣大道2段159號1樓 ; 統編, 93769370 ; 營業名稱, 年年有魚餐飲有限公司 ; 資本額, 6,000,000 ; 設立日期, 1120713."}, {"title": "年年有魚餐飲有限公司", "snippet": "公司名稱, 年年有魚餐飲有限公司 ; 資本總額(元), 6,000,000 ; 負責人, 江敏 ; 登記地址, 看地圖 臺中市西區民龍里臺灣大道二段159號1樓 郵遞區號查詢 ; 設立 ..."}, {"title": "年年有魚餐飲有限公司", "snippet": "年年有魚餐飲有限公司 ; 負責人, 江敏 ; 登記地址, 台中市西區民龍里台灣大道二段159號1樓 ; 公司狀態, 核准設立 ; 資本額, 6,000,000元 ; 所在縣市, 台中市 西區 民龍里."}, {"title": "江_敏-年年有魚餐飲有限公司", "snippet": "負責人:江_敏·公司名:年年有魚餐飲有限公司·統一編號:93769370·公司地址:臺中市西區民龍里臺灣大道二段159號1樓·資本額:6000000·公司狀況:核准設立·核准設立 ..."}, {"title": "年年有魚餐飲有限公司/負責人:江_敏", "snippet": "公司名稱:年年有魚餐飲有限公司·代表人姓名:江_敏·公司所在地:臺中市西區民龍里臺灣大道二段159號1樓·統編:93769370資本總額:6000000·公司狀況:核准設立·核准設立 ..."}, {"title": "貓吃魚餐飲有限公司|工作徵才簡介", "snippet": "貓吃魚餐飲有限公司. 台中市西屯區. 時薪186元. 應徵人數:1 ~ 5人. 排休; 晚班; 工作經驗不拘; 學歷不拘. 1.佈置及清理餐桌2.為顧客帶位或安排座位3.上菜並提供有關用餐的 ..."}, {"title": "食力餐飲_食力國際有限公司|公司簡介", "snippet": "「食力國際有限公司」正式成立於2023年4月,目前短短時間已成立了四個品牌~ 一、【食力據點】 1:食力咖哩- 台中遠百店(台中市西屯區臺灣大道三段251號大遠百12樓大食 ..."}, {"title": "112 年臺中市優質餐飲店家分級評核獲獎名單", "snippet": "112 年臺中市優質餐飲店家分級評核獲獎名單-. 臺中市餐廳飲食店低碳認證書20 家. 1 築間幸福鍋物-臺中市政二店臺中市西屯區文心路二段213 號. 2 有之和牛-臺中文心店."}, {"title": "年年有魚水族館", "snippet": "營業地址, 臺中市西屯區何安里西屯路2段101-2號1樓 ; 統編, 21833774 ; 營業名稱, 年年有魚水族館 ; 資本額, 60,000 ; 設立日期, 0940502."}, {"title": "類似的店", "snippet": "[\'設計公司\']\\t[\'餐廳\']"}, {"telephone_number": "04 2376 6318"}]'
209
- x = compose_classication( evidence )
210
- print( x )
211
 
212
  def classify_results(
213
  analysis_results: pd.DataFrame,
@@ -281,9 +243,6 @@ def classify_results_mp( extracted_results: pd.DataFrame, classified_file_path,
281
  print( f"total time: {time.time() - st}")
282
  return classified_results
283
 
284
- def test_get_evidence_classification():
285
- analysis_results = classify_results( analysis_results)
286
- patch_analysis_results = classify_results( patch_analysis_results)
287
 
288
  def compose_query( address, name, with_index: bool = True, exclude: str = "-inurl:twincn.com -inurl:findcompany.com.tw -inurl:iyp.com.tw -inurl:twypage.com -inurl:alltwcompany.com -inurl:zhupiter.com -inurl:twinc.com.tw"):
289
  """
@@ -432,9 +391,6 @@ def extract_results_mp( crawled_results, extracted_file_path, classes: list):
432
  print( f"total time: {time.time() - st}")
433
  return extracted_results
434
 
435
- def test_get_analysis_results():
436
- data = pd.read_csv("data/餐廳類型分類.xlsx - 測試清單.csv")
437
- analysis_results, empty_indices = extract_results( data )
438
 
439
  def postprocess_result( results: pd.DataFrame, postprocessed_results_path, category_hierarchy: dict, column_name: str = 'category'):
440
  """
@@ -467,9 +423,6 @@ def postprocess_result( results: pd.DataFrame, postprocessed_results_path, categ
467
  postprocessed_results = joblib.load(f)
468
  return postprocessed_results
469
 
470
- def test_postprocess_result():
471
- analysis_result = ""
472
- pos_res = postprocess_result( analysis_result)
473
 
474
  def combine_results( results: pd.DataFrame, combined_results_path: str, src_column: str = 'classified_category', tgt_column: str = 'category', strategy: str = 'replace'):
475
  """
 
43
  # return result['organic_results'][0]
44
  return result
45
 
 
 
 
 
 
 
 
 
 
 
46
 
47
  def get_condensed_result(result):
48
  """
 
69
  # print( condensed_results )
70
  return condensed_result
71
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  def compose_analysis( client, query, search_results, classes: list, model: str = 'gpt-3.5-turbo-0125'):
74
  """
 
118
  response = chat_completion.choices[0].message.content
119
  return response
120
 
 
 
 
 
 
 
 
 
 
 
 
 
121
 
122
  def compose_classication(
123
  client,
 
170
  response = chat_completion.choices[0].message.content
171
  return response
172
 
 
 
 
 
 
 
173
 
174
  def classify_results(
175
  analysis_results: pd.DataFrame,
 
243
  print( f"total time: {time.time() - st}")
244
  return classified_results
245
 
 
 
 
246
 
247
  def compose_query( address, name, with_index: bool = True, exclude: str = "-inurl:twincn.com -inurl:findcompany.com.tw -inurl:iyp.com.tw -inurl:twypage.com -inurl:alltwcompany.com -inurl:zhupiter.com -inurl:twinc.com.tw"):
248
  """
 
391
  print( f"total time: {time.time() - st}")
392
  return extracted_results
393
 
 
 
 
394
 
395
  def postprocess_result( results: pd.DataFrame, postprocessed_results_path, category_hierarchy: dict, column_name: str = 'category'):
396
  """
 
423
  postprocessed_results = joblib.load(f)
424
  return postprocessed_results
425
 
 
 
 
426
 
427
  def combine_results( results: pd.DataFrame, combined_results_path: str, src_column: str = 'classified_category', tgt_column: str = 'category', strategy: str = 'replace'):
428
  """
test.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import pandas as pd
3
+
4
+ from sheet import (get_serp, get_condensed_result, compose_analysis,
5
+ compose_classication, classify_results, extract_results,
6
+ postprocess_result)
7
+
8
+
9
+ def test_get_serp():
10
+ # query = "原味商行"
11
+ # query = "南投縣中寮鄉中寮村鄉林巷43號 和興商店"
12
+ # query = "啓輝環管企業社"
13
+ # query = "蘭陽客棧小吃店"
14
+ # query = '韓笑味食品有限公司'
15
+ # query = '小阿姨的店'
16
+ query = '達米娜魚料理店'
17
+ res = get_serp(query, google_domain='google.com.tw')
18
+ print(res)
19
+
20
+
21
+ def test_get_condensed_result():
22
+ # query = "原味商行"
23
+ # query = "南投縣中寮鄉中寮村鄉林巷43號 和興商店"
24
+ # query = "啓輝環管企業社"
25
+ # query = "蘭陽客棧小吃店"
26
+ # query = '韓笑味食品有限公司'
27
+ # query = '小阿姨的店'
28
+ query = '達米娜魚料理店'
29
+ res = get_serp(query)
30
+ cond_res = get_condensed_result(res)
31
+
32
+
33
+ def test_compose_analysis():
34
+ # query = "原味商行"
35
+ # query = "南投縣中寮鄉中寮村鄉林巷43號 和興商店"
36
+ # query = "啓輝環管企業社"
37
+ # query = "蘭陽客棧小吃店"
38
+ # query = '韓笑味食品有限公司'
39
+ # query = '小阿姨的店'
40
+ query = '達米娜魚料理店'
41
+ res = get_serp(query)
42
+ cond_res = get_condensed_result(res)
43
+ resp = compose_analysis( query = query, search_results = cond_res)
44
+ print( resp )
45
+
46
+ def test_compose_classification( evidence):
47
+ """
48
+ """
49
+ evidence = '[{"title": "年年有魚餐飲有限公司- 店家介紹", "snippet": "統一編號. 93769370 · 公司狀況. 營業中 · 公司名稱. 年年有魚餐飲有限公司 · 公司類型. 有限公司 · 資本總額. 6000000 · 所在地. 臺中市西區民龍里臺灣大道2段159號1樓."}, {"title": "年年有魚餐飲有限公司", "snippet": "營業地址, 臺中市西區民龍里臺灣大道2段159號1樓 ; 統編, 93769370 ; 營業名稱, 年年有魚餐飲有限公司 ; 資本額, 6,000,000 ; 設立日期, 1120713."}, {"title": "年年有魚餐飲有限公司", "snippet": "公司名稱, 年年有魚餐飲有限公司 ; 資本總額(元), 6,000,000 ; 負責人, 江敏 ; 登記地址, 看地圖 臺中市西區民龍里臺灣大道二段159號1樓 郵遞區號查詢 ; 設立 ..."}, {"title": "年年有魚餐飲有限公司", "snippet": "年年有魚餐飲有限公司 ; 負責人, 江敏 ; 登記地址, 台中市西區民龍里台灣大道二段159號1樓 ; 公司狀態, 核准設立 ; 資本額, 6,000,000元 ; 所在縣市, 台中市 西區 民龍里."}, {"title": "江_敏-年年有魚餐飲有限公司", "snippet": "負責人:江_敏·公司名:年年有魚餐飲有限公司·統一編號:93769370·公司地址:臺中市西區民龍里臺灣大道二段159號1樓·資本額:6000000·公司狀況:核准設立·核准設立 ..."}, {"title": "年年有魚餐飲有限公司/負責人:江_敏", "snippet": "公司名稱:年年有魚餐飲有限公司·代表人姓名:江_敏·公司所在地:臺中市西區民龍里臺灣大道二段159號1樓·統編:93769370資本總額:6000000·公司狀況:核准設立·核准設立 ..."}, {"title": "貓吃魚餐飲有限公司|工作徵才簡介", "snippet": "貓吃魚餐飲有限公司. 台中市西屯區. 時薪186元. 應徵人數:1 ~ 5人. 排休; 晚班; 工作經驗不拘; 學歷不拘. 1.佈置及清理餐桌2.為顧客帶位或安排座位3.上菜並提供有關用餐的 ..."}, {"title": "食力餐飲_食力國際有限公司|公司簡介", "snippet": "「食力國際有限公司」正式成立於2023年4月,目前短短時間已成立了四個品牌~ 一、【食力據點】 1:食力咖哩- 台中遠百店(台中市西屯區臺灣大道三段251號大遠百12樓大食 ..."}, {"title": "112 年臺中市優質餐飲店家分級評核獲獎名單", "snippet": "112 年臺中市優質餐飲店家分級評核獲獎名單-. 臺中市餐廳飲食店低碳認證書20 家. 1 築間幸福鍋物-臺中市政二店臺中市西屯區文心路二段213 號. 2 有之和牛-臺中文心店."}, {"title": "年年有魚水族館", "snippet": "營業地址, 臺中市西屯區何安里西屯路2段101-2號1樓 ; 統編, 21833774 ; 營業名稱, 年年有魚水族館 ; 資本額, 60,000 ; 設立日期, 0940502."}, {"title": "類似的店", "snippet": "[\'設計公司\']\\t[\'餐廳\']"}, {"telephone_number": "04 2376 6318"}]'
50
+ x = compose_classication( evidence )
51
+ print( x )
52
+
53
+
54
+ def test_classify_results():
55
+ analysis_results = classify_results( analysis_results)
56
+ patch_analysis_results = classify_results( patch_analysis_results)
57
+
58
+
59
+ def test_get_analysis_results():
60
+ data = pd.read_csv("data/餐廳類型分類.xlsx - 測試清單.csv")
61
+ analysis_results, empty_indices = extract_results( data )
62
+
63
+ def test_postprocess_result():
64
+ analysis_result = ""
65
+ pos_res = postprocess_result( analysis_result)