youssef1214
commited on
Commit
·
b96fdbc
1
Parent(s):
a9859a7
Update Database.py
Browse files- Database.py +23 -13
Database.py
CHANGED
@@ -26,7 +26,7 @@ all_reviews = db.collection("complaints")
|
|
26 |
# Create a query against the collection
|
27 |
today_date = current_milli_time()
|
28 |
documents_to_summarize = all_reviews.get()
|
29 |
-
feedbacks = db.collection("feedbacks").where("feedbacks","
|
30 |
|
31 |
|
32 |
documents=[]
|
@@ -59,24 +59,34 @@ def shakwa_common_words():
|
|
59 |
else:
|
60 |
most_common_words[word] = 1
|
61 |
most_common_words = sorted(most_common_words.items(), key=lambda x: x[1])
|
62 |
-
print(most_common_words)
|
63 |
return dict(most_common_words)
|
64 |
|
65 |
|
66 |
def feedback_common_words():
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
return dict(most_common_words)
|
72 |
|
73 |
def get_most_common_places():
|
74 |
-
dic_place_count={}
|
75 |
-
|
76 |
-
|
77 |
-
if
|
78 |
-
dic_place_count[
|
79 |
-
else
|
80 |
-
dic_place_count[
|
81 |
return dic_place_count
|
82 |
|
|
|
26 |
# Create a query against the collection
|
27 |
today_date = current_milli_time()
|
28 |
documents_to_summarize = all_reviews.get()
|
29 |
+
feedbacks = db.collection("feedbacks").where("feedbacks","!=",'').get()
|
30 |
|
31 |
|
32 |
documents=[]
|
|
|
59 |
else:
|
60 |
most_common_words[word] = 1
|
61 |
most_common_words = sorted(most_common_words.items(), key=lambda x: x[1])
|
|
|
62 |
return dict(most_common_words)
|
63 |
|
64 |
|
65 |
def feedback_common_words():
|
66 |
+
allfeedbacks= []
|
67 |
+
most_common_words = {}
|
68 |
+
for doc in feedbacks:
|
69 |
+
document = Classes.Feedback.from_dict(source=doc.to_dict())
|
70 |
+
allcomplaints.append(document.feedback )
|
71 |
+
# print(allcomplaints)
|
72 |
+
words_in_docs = " ".join(allfeedbacks)
|
73 |
+
words_in_docs = Cleaning.txt_preprocess(words_in_docs)
|
74 |
+
words_in_docs = words_in_docs.split(" ")
|
75 |
+
for word in words_in_docs:
|
76 |
+
if word in most_common_words:
|
77 |
+
most_common_words[word] += 1
|
78 |
+
else:
|
79 |
+
most_common_words[word] = 1
|
80 |
+
most_common_words = sorted(most_common_words.items(), key=lambda x: x[1])
|
81 |
return dict(most_common_words)
|
82 |
|
83 |
def get_most_common_places():
|
84 |
+
dic_place_count = {}
|
85 |
+
for doc in all_reviews.get():
|
86 |
+
document = Classes.Shakwa.from_dict(source=doc.to_dict())
|
87 |
+
if document.governorate not in dic_place_count.keys():
|
88 |
+
dic_place_count[document.governorate] = 1
|
89 |
+
else:
|
90 |
+
dic_place_count[document.governorate] += 1
|
91 |
return dic_place_count
|
92 |
|