Commit f5b6672a authored by Gijs Hendriksen's avatar Gijs Hendriksen

Final changes to the command line interface

parent 4f63d3cc
......@@ -146,6 +146,8 @@ class DuckDBIndex(Index):
print('[!] Invalid input file!')
return
print('Indexing...')
dict_table = self.cursor.execute('SELECT * FROM dict').fetchdf()
term_table = self.cursor.execute('SELECT * FROM terms').fetchdf()
doc_table = self.cursor.execute('SELECT * FROM docs').fetchdf()
......@@ -285,6 +287,8 @@ class MonetDBIndex(Index):
print('[!] Invalid input file!')
return
print('Indexing...')
self.cursor.execute('SELECT * FROM dict')
dict_table = pd.DataFrame(self.cursor.fetchall(), columns=['termid', 'term', 'df'])
......
......@@ -8,7 +8,7 @@ from search import Search
def bulk_index(args: argparse.Namespace):
index = Index.get_index(args.engine, args.database)
filename = args.data
filename = args.input
index.bulk_index(filename)
......@@ -128,13 +128,13 @@ def main():
parser_benchmark.set_defaults(func=benchmark)
parser_dump = subparsers.add_parser('dump')
parser_dump.add_argument('--database', help='The database file to use', required=True)
parser_dump.add_argument('database', help='The database file to use')
parser_dump.add_argument('-e', '--engine', help='The database engine to use',
choices=('duckdb', 'monetdb'), default='duckdb')
parser_dump.set_defaults(func=dump_index)
parser_clear = subparsers.add_parser('clear')
parser_clear.add_argument('--database', help='The database file to use', required=True)
parser_clear.add_argument('database', help='The database file to use')
parser_clear.add_argument('-e', '--engine', help='The database engine to use',
choices=('duckdb', 'monetdb'), default='duckdb')
parser_clear.set_defaults(func=clear_index)
......
......@@ -9,9 +9,10 @@ class Search:
self.index = index
def search(self, terms, method='bm25'):
terms = self.index.get_terms(' '.join(terms)).keys()
terms = list(self.index.get_terms(' '.join(terms)).keys())
if method == 'bm25':
sql_query = query.bm25(terms)
sql_query = query.bm25(terms, False)
else:
raise NotImplementedError(f'Search method "{method}" was not implemented')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment