Skip to content

Commit 524fb5c

Browse files
committed
don't hardcode corpus_philo_id lengths
1 parent d1c881e commit 524fb5c

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

python/philologic/runtime/Query.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,14 @@ def filter_philo_ids(corpus_file, philo_ids) -> np.ndarray:
179179
matching_indices = __filter_philo_ids_on_void(corpus_philo_ids[:, :object_level], philo_ids[:, :object_level])
180180
return philo_ids[matching_indices]
181181
else:
182-
max_philo_path_len = 5 # max length of philo_id path part for metadata
182+
unique_lengths = np.unique(actual_corpus_lengths) # get unique lengths
183183
num_philo_rows = philo_ids.shape[0]
184184
overall_match_mask = np.zeros(num_philo_rows, dtype=bool)
185185

186-
for current_len in range(1, max_philo_path_len + 1):
186+
for current_len in unique_lengths:
187187
# Create a mask for the corpus_philo_ids that match the current length
188188
corpus_rows_for_this_len_mask = (actual_corpus_lengths == current_len)
189189

190-
if not np.any(corpus_rows_for_this_len_mask):
191-
continue # No corpus prefixes of this specific actual length
192190
# Extract these actual corpus prefixes (all are of length current_len)
193191
relevant_corpus_prefixes = corpus_philo_ids[corpus_rows_for_this_len_mask, :current_len]
194192
philo_ids_prefixes = philo_ids[:, :current_len]

0 commit comments

Comments
 (0)