-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocument_retrieval.py
83 lines (59 loc) · 3.22 KB
/
document_retrieval.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
'''
------------------------------------------------------------
Created on Oct 2015 by
Name = Gerardo Roa Dabike
University ID = acp15gr
Registration Number = 150105918
------------------------------------------------------------
'''
from command_line import CommandLine
from stop_list import StopList
from create_index import CreateIndex
from load_querie_TFIDF import LoadQuerie_TFIDF
from load_querie_TF import LoadQuerie_TF
from load_querie_B import LoadQuerie_B
from print_result import PrintResult
from querie_dict import QuerieDict
if __name__ == '__main__':
commandLine = CommandLine()
#################################
# Load StopList #
#################################
stop = StopList(commandLine.getStopListFile(),commandLine.getStem())
#################################
# Load IndexFile #
#################################
if (commandLine.getCreateIndex()):
index = CreateIndex(commandLine.getIndexFile(),stop.stops, commandLine.getCollection(),True,commandLine.getStem(), commandLine.getToken())
else:
index = CreateIndex(commandLine.getIndexFile())
if(commandLine.getWeigthMethod()!= None):
#################################
# Load Queries #
#################################
if (commandLine.getStringQuery() == None):
myQueryDict = QuerieDict(commandLine.getQuerieFile(),commandLine.getOneQuerie(),commandLine.getToken(),commandLine.getStem(),stop.stops, "",False )
else:
myQueryDict = QuerieDict(None,None,None,commandLine.getStem(),stop.stops,commandLine.getStringQuery() ,True )
#################################
# Vector Weigth Binay #
#################################
if (commandLine.getWeigthMethod() == 'B'):
if (commandLine.getQuerieFile() != None):
myLoadQuerie = LoadQuerie_B(myQueryDict.getQueryDict(),index.getIndex())
querie = myLoadQuerie.getResultDict()
#################################
# Vector Weigth TF #
#################################
elif (commandLine.getWeigthMethod() == 'F'):
if (commandLine.getQuerieFile() != None):
myLoadQuerie = LoadQuerie_TF(myQueryDict.getQueryDict(),index.getIndex(),index.getDocumentVector())
querie = myLoadQuerie.getResultDict()
#################################
# Vector Weigth TF.IDF #
#################################
elif (commandLine.getWeigthMethod() == 'D'):
#if (commandLine.getQuerieFile() != None):
myLoadQuerie = LoadQuerie_TFIDF(myQueryDict.getQueryDict(),index.getIDFDict() ,index.getDocumentVector(),index.getTFIDFDict() )
querie = myLoadQuerie.getSimilarity()
result = PrintResult(querie,commandLine.getResultAmount(),commandLine.getWeigthMethod(),commandLine.getResultFile() )