Skip to content

Commit a94c3ce

Browse files
committed
add documents for query
1 parent 542e0a5 commit a94c3ce

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

db_manager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ def get_similarity_search_results(doclist: str, db_dir: str, terms: str, top_k:
4747
num=int(sys.argv[4])
4848

4949
docs = get_similarity_search_results(doclist, db_dir, terms, num)
50-
print(docs)
50+
for entry in docs:
51+
print(entry)

tools/do_query.bash

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ then
1818
else
1919
mkdir test/result
2020
fi
21+
22+
function get_docs()
23+
{
24+
local query="${1}"
25+
local json_file=${2}
26+
TERMS=`bash tools/get_terms.bash test/result/${json_file}`
27+
python3 db_manager.py ../documents/dbs ../documents/document.list "${query}, ${TERMS}" 10 | tee tmp.list
28+
}
29+
2130
query_dir=$1
2231
background_file=$2
2332
query="`cat ${query_dir}/query.txt`"
@@ -35,11 +44,17 @@ do
3544
rm -rf test/*.json
3645
echo "INFO: CRITICAL THINKING"
3746
python3 critical_thinking.py "$query" ${background_file}
47+
echo "INFO: GETTING DOCUMENTS"
48+
get_docs "${query}" critical_thinking.json
49+
documents=`cat tmp.list`
3850
echo "INFO: PLANNING"
39-
python3 planner.py "$query" ../documents/document.list ${background_file} test/result/critical_thinking.json
51+
python3 planner.py "$query\n: Please research focusing on the following document:\n ${documents} " ../documents/document.list ${background_file} test/result/critical_thinking.json
4052
else
4153
echo "INFO: PLANNING"
42-
python3 planner.py "$query" ../documents/document.list ${background_file} test/result/reflection.json
54+
echo "INFO: GETTING DOCUMENTS"
55+
get_docs "${query}" reflection.json
56+
documents=`cat tmp.list`
57+
python3 planner.py "$query\n: Please research focusing on the following document:\n ${documents}" ../documents/document.list ${background_file} test/result/reflection.json
4358
fi
4459
else
4560
echo "INFO: PLANNING"

tools/get_terms.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ fi
88

99
reflection_path=${1}
1010

11-
grep Term ${reflection_path} | awk -F: '{print $2}' | sed 's/\"//g'| sed ':a;N;$!ba;s/\n//g'
11+
grep Term ${reflection_path} | awk -F: '{print $2}' | sort | uniq | sed 's/\"//g'| sed ':a;N;$!ba;s/\n//g'

0 commit comments

Comments
 (0)