-
Notifications
You must be signed in to change notification settings - Fork 2
/
TextSearch.py
80 lines (61 loc) · 1.9 KB
/
TextSearch.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
import CFileRead as fr
import CTextSearch as ts
from collections import defaultdict
import CNaiveBayes as nb
import CRecommendation as cr
#import CClassification as clf
def TextSearch():
SearchObj = ts.CTextSearch()
FileHandlingObj = SearchObj.getFileReadObj()
naivebObj = nb.CNaivebase()
naivebObj.setFileReadObj(FileHandlingObj)
naivebObj.Initialize()
naivebObj.CalculateClassProbability()
classres = naivebObj.CalculateTermProbablity('gun bomb explode kill gun gun')
print(classres)
naivebObj.CalculateTraingAccuracy()
naivebObj.CalculateTestAccuracy()
'''
RecObj = cr.CRecommendation()
RecObj.Initialize()
RecObj.CreateModel()
RecObj.CalculateSimilarity()
RecObj.Predict()
retrive_data = RecObj.GetPredictedMovie()
print(retrive_data)
'''
'''
ClassObj = clf.CClassification()
ClassObj.setFileReadObj(FileHandlingObj)
ClassObj.Initialize()
ClassObj.CreateTraingData()
ClassObj.TrainingClassification()
[data,actual_label,index] = ClassObj.getTestData()
print(data)
print(actual_label)
PredictedClass = ClassObj.PredictedClass(data,index)
print(PredictedClass)
'''
TextSearch()
'''
Myword = "hello world"
Myword1 = "xcr trivedi"
postings = defaultdict(dict)
document_token = SearchObj.tokenize(Myword)
for index in range(1):
for term in document_token:
postings[term][index] = document_token.count(term)
document_token = SearchObj.tokenize(Myword1)
for term in document_token:
postings[term][3] = document_token.count(term)
query = " hello "
query_token = SearchObj.tokenize(query)
print(postings)
for q_token in query_token:
if q_token in postings:
if 0 in postings[q_token]:
print(postings[q_token][0])
#SearchObj.DisplayData()
#SearchObj.Read_and_initialise_document()
'''
#print(np.arange(2))