Skip to content

Commit ad083e0

Browse files
authored
Add option HAS_WORD_TRIPLES for qlever index command (#221)
This complements ad-freiburg/qlever#2579
1 parent 1b17e35 commit ad083e0

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55
[project]
66
name = "qlever"
77
description = "Command-line tool for using the QLever graph database"
8-
version = "0.5.34"
8+
version = "0.5.35"
99
authors = [
1010
{ name = "Hannah Bast", email = "bast@cs.uni-freiburg.de" }
1111
]

src/qlever/commands/index.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def relevant_qleverfile_arguments(self) -> dict[str : list[str]]:
4545
"only_pso_and_pos_permutations",
4646
"ulimit",
4747
"use_patterns",
48+
"add_has_word_triples",
4849
"text_index",
4950
"stxxl_memory",
5051
"parser_buffer_size",
@@ -100,8 +101,7 @@ def get_input_options_for_json(self, args) -> str:
100101
# Check that `input_spec` is a dictionary.
101102
if not isinstance(input_spec, dict):
102103
raise self.InvalidInputJson(
103-
f"Element {i} in `MULTI_INPUT_JSON` must be a JSON "
104-
"object",
104+
f"Element {i} in `MULTI_INPUT_JSON` must be a JSON object",
105105
input_spec,
106106
)
107107
# For each `input_spec`, we must have a command.
@@ -222,13 +222,14 @@ def execute(self, args) -> bool:
222222
index_cmd += " --only-pso-and-pos-permutations"
223223
if args.use_patterns == "no":
224224
index_cmd += " --no-patterns"
225+
if args.add_has_word_triples:
226+
index_cmd += " --add-has-word-triples"
225227
if args.text_index in [
226228
"from_text_records",
227229
"from_text_records_and_literals",
228230
]:
229231
index_cmd += (
230-
f" -w {args.name}.wordsfile.tsv"
231-
f" -d {args.name}.docsfile.tsv"
232+
f" -w {args.name}.wordsfile.tsv -d {args.name}.docsfile.tsv"
232233
)
233234
if args.text_index in [
234235
"from_literals",
@@ -306,8 +307,7 @@ def execute(self, args) -> bool:
306307
):
307308
if Containerize.is_running(args.system, args.index_container):
308309
log.info(
309-
"Another index process is running, trying to stop "
310-
"it ..."
310+
"Another index process is running, trying to stop it ..."
311311
)
312312
log.info("")
313313
try:

src/qlever/qleverfile.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@ def arg(*args, **kwargs):
203203
"processing of queries like SELECT ?p (COUNT(DISTINCT ?s) AS ?c) "
204204
"WHERE { ?s ?p [] ... } GROUP BY ?p",
205205
)
206+
index_args["add_has_word_triples"] = arg(
207+
"--add-has-word-triples",
208+
action="store_true",
209+
default=False,
210+
help="Whether to add `ql:has-word` triples for text literals "
211+
"(which can then be used for custom text search queries)",
212+
)
206213
index_args["text_index"] = arg(
207214
"--text-index",
208215
choices=[

test/qlever/commands/test_index_execute.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def test_execute_successful_indexing_without_extras(
3535
args.only_pso_and_pos_permutations = False
3636
args.use_patterns = True
3737
args.parallel_parsing = False
38+
args.add_has_word_triples = False
3839
args.text_index = "Test Index"
3940
args.stxxl_memory = False
4041
args.system = "native"
@@ -116,6 +117,7 @@ def test_execute_indexing_with_already_existing_files(
116117
args.input_files = "*.nt"
117118
args.only_pso_and_pos_permutations = False
118119
args.use_patterns = True
120+
args.add_has_word_triples = False
119121
args.text_index = None
120122
args.stxxl_memory = None
121123
args.system = "native"
@@ -177,6 +179,7 @@ def test_execute_fails_if_no_indexing_binary_is_found(
177179
args.input_files = "*.nt"
178180
args.only_pso_and_pos_permutations = False
179181
args.use_patterns = True
182+
args.add_has_word_triples = False
180183
args.text_index = None
181184
args.stxxl_memory = None
182185
args.system = "native"
@@ -241,6 +244,7 @@ def test_execute_total_file_size_greater_than_ten_gb(
241244
args.only_pso_and_pos_permutations = False
242245
args.use_patterns = True
243246
args.parallel_parsing = False
247+
args.add_has_word_triples = False
244248
args.text_index = None
245249
args.stxxl_memory = None
246250
args.system = "native"
@@ -351,6 +355,7 @@ def test_execute_successful_indexing_with_extras_and_show(
351355
args.cat_input_files = False
352356
args.only_pso_and_pos_permutations = True
353357
args.use_patterns = "no"
358+
args.add_has_word_triples = False
354359
args.text_index = "from_text_records_and_literals"
355360
args.stxxl_memory = True
356361
args.input_files = "*.nt"

test/qlever/commands/test_index_other_methods.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def test_relevant_qleverfile_arguments(self):
4242
"only_pso_and_pos_permutations",
4343
"ulimit",
4444
"use_patterns",
45+
"add_has_word_triples",
4546
"text_index",
4647
"stxxl_memory",
4748
"parser_buffer_size",

0 commit comments

Comments
 (0)