yulongchen commited on
Commit
602a998
·
1 Parent(s): e30c3ac

Add system

Browse files
system/augmented_searching.py CHANGED
@@ -45,7 +45,7 @@ def ensure_directory_exists(path):
45
  raise ValueError(f"[ERROR] Unsafe path: {dir_path}")
46
  dir_path.mkdir(parents=True, exist_ok=True)
47
 
48
- def run_augmented_searching(qa_file, pipeline_base_dir, suggestion_meta, pledge_author, start_date, end_date, user_id, claim_id):
49
  if suggestion_meta==None:
50
  qa_lines = open(f"{qa_file}","r").read()
51
  qa_lines = json.loads(qa_lines)
@@ -95,5 +95,5 @@ def run_augmented_searching(qa_file, pipeline_base_dir, suggestion_meta, pledge_
95
  urls = list(dict.fromkeys(urls))
96
 
97
  save_tsv(str(tsv_file_path), [0] * len(urls), string_values, urls, queries)
98
- print(f"[SYSTEM] Saved {len(urls)} URLs for claim {claim_id} to {tsv_file_path}")
99
  return str(tsv_file_path)
 
45
  raise ValueError(f"[ERROR] Unsafe path: {dir_path}")
46
  dir_path.mkdir(parents=True, exist_ok=True)
47
 
48
+ def run_augmented_searching(qa_file, pipeline_base_dir, suggestion_meta, pledge_author, start_date, end_date):
49
  if suggestion_meta==None:
50
  qa_lines = open(f"{qa_file}","r").read()
51
  qa_lines = json.loads(qa_lines)
 
95
  urls = list(dict.fromkeys(urls))
96
 
97
  save_tsv(str(tsv_file_path), [0] * len(urls), string_values, urls, queries)
98
+ print(f"[SYSTEM] Saved {len(urls)} URLs for claim {idx} to {tsv_file_path}")
99
  return str(tsv_file_path)
system/pledge_tracking.py CHANGED
@@ -104,9 +104,10 @@ def run_pipeline(claim, pledge_date, pledge_author, start_date, timestamp, user_
104
  repo_type="dataset",
105
  token=os.environ["HF_TOKEN"]
106
  )
107
- with open(qa_file_path, "r", encoding="utf-8") as f:
108
- questions = {line["question"] for line in json.load(f)["evidence"]}
109
- line_count = len(questions)
 
110
  if update_fn:
111
  update_fn(step_id, f"relevant queries are generated, for example:\n"
112
  f"{questions[0]}\n"
@@ -124,9 +125,10 @@ def run_pipeline(claim, pledge_date, pledge_author, start_date, timestamp, user_
124
  start_date=start_date,
125
  suggestion_meta=suggestion_meta,
126
  end_date="",
127
- user_id=user_id,
128
- claim_id=0,
129
  )
 
 
 
130
  with open(augmented_tsv_file, "r", encoding="utf-8") as f:
131
  line_count = sum(1 for line in f)
132
  if update_fn:
 
104
  repo_type="dataset",
105
  token=os.environ["HF_TOKEN"]
106
  )
107
+ idx = suggestion_meta["index"]
108
+ qa_lines = open(f"{qa_file_path}","r").readlines()[idx]
109
+ questions = {line["question"] for line in json.load(qa_lines)["evidence"]}
110
+ line_count = len(questions)
111
  if update_fn:
112
  update_fn(step_id, f"relevant queries are generated, for example:\n"
113
  f"{questions[0]}\n"
 
125
  start_date=start_date,
126
  suggestion_meta=suggestion_meta,
127
  end_date="",
 
 
128
  )
129
+
130
+
131
+
132
  with open(augmented_tsv_file, "r", encoding="utf-8") as f:
133
  line_count = sum(1 for line in f)
134
  if update_fn:
test.html CHANGED
@@ -387,7 +387,7 @@
387
  const author = "Labour";
388
  const date = "2024-07-04";
389
  suggestionBox.innerHTML =
390
- "<div class='font-semibold mb-1'>💡 Are you fact-checking ... </div>" +
391
  "<ul class='list-disc ml-6 mt-1'>" +
392
  suggestions.map(s => `
393
  <li class="mb-2">
 
387
  const author = "Labour";
388
  const date = "2024-07-04";
389
  suggestionBox.innerHTML =
390
+ "<div class='font-semibold mb-1'>💡 Are you fact-checking this pledge? </div>" +
391
  "<ul class='list-disc ml-6 mt-1'>" +
392
  suggestions.map(s => `
393
  <li class="mb-2">