-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstructure.py
More file actions
53 lines (42 loc) · 850 Bytes
/
structure.py
File metadata and controls
53 lines (42 loc) · 850 Bytes
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os
""" Files """
CORPUS_FILE = os.path.join(os.path.dirname(os.getcwd()), "wiki_25")
DATA_FILE = os.path.join(os.getcwd(), "data")
DOCUMENTS_FILE = os.path.join(os.getcwd(), "documents")
ENCODING = "utf-8"
""" Implementation data """
TOKENIZER_REGEX = r"\s|[“”’`~!@#$%^&_()\[\]{}|:;'\"<,>.?+-/*=]+"
DELIMITERS = {
"index" : ":",
"term" : ";",
"id" : "~",
}
""" Delimiter description
inverted_index = { word : { doc_id : frequency } } }
will be written in file as:
word{index}doc_id{id}frequency{term}doc_id{id}...
.
.
.
{} represents type of delimiter """
MAX_DOCS_TO_RETRIEVE = 10
""" Data structures """
# corpus
inverted_index = {
# word : {
# doc_id : frequency
# }
}
documents = [
# {
# "doc_id" : doc_id
# "title" : title
# }
]
# query
query = {
# word : frequency
}
scores = [
# [doc_id, score_cos]
]