Skip to content

Commit 005d838

Browse files
committed
Added missing constant disambiguation for inputs
1 parent 94a5876 commit 005d838

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

examples/pbe/transduction/knowledge_graph/preprocess_tasks.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,23 @@ def filter_constants(constants: List[str]) -> List[str]:
181181
print("\tFound no path for relationship level", d)
182182
print()
183183

184-
constants_in = task.metadata.get("constants_in", None) or filter_constants(
185-
find_constants(
186-
[
187-
pbe.examples[i].inputs[0]
188-
for i in range(min(MAX_EXAMPLES_ANALYSED, len(pbe.examples)))
189-
]
190-
)
191-
)
192-
if task.metadata.get("constants_in", None) is None:
184+
constants_in = task.metadata.get("constants_in", None)
185+
if constants_in is None:
186+
all_possibles = [
187+
filter_constants(
188+
find_constants(
189+
[
190+
pbe.examples[i + k].inputs[0]
191+
for i in range(
192+
min(MAX_EXAMPLES_ANALYSED, len(pbe.examples))
193+
)
194+
]
195+
)
196+
)
197+
for k in range(max(1, len(pbe.examples) - MAX_EXAMPLES_ANALYSED))
198+
]
199+
t = sorted([(len(l), l) for l in all_possibles])
200+
constants_in = t[0][1]
193201
task.metadata["constants_in"] = constants_in
194202
dataset.save(dataset_file)
195203
print("Constants Input:", constants_in)

0 commit comments

Comments
 (0)