-
Notifications
You must be signed in to change notification settings - Fork 0
/
step3_use_index.py
31 lines (21 loc) · 1.13 KB
/
step3_use_index.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from mmkfeatures.fusion.mm_features_lib import MMFeaturesLib
mmf_file=f"datasets/birds.mmf"
print("loading mmf files...")
birds_lib=MMFeaturesLib(file_path=mmf_file)
print("creating plain text index...")
birds_lib.to_index_file("text","datasets/text.index",index_type="brutal_force")
print("creating inverted index....")
birds_lib.to_index_file("text","datasets/text_inverted.index",index_type="inverted_index")
print("creating positional text...")
birds_lib.to_index_file("text","datasets/text_positional.index",index_type="positional_index")
# start to perform search test
query_str="yellow breast"
print("searching plain index test....")
result_bf=birds_lib.search_index(index_file_path="datasets/text.index",query=query_str,search_type="brutal_force")
print(result_bf)
print("searching inverted index test....")
result_bf=birds_lib.search_index(index_file_path="datasets/text_inverted.index",query=query_str,search_type="inverted_index")
print(result_bf)
print("searching positional index test....")
result_bf=birds_lib.search_index(index_file_path="datasets/text_positional.index",query=query_str,search_type="positional_index")
print(result_bf)