youssef1214 commited on
Commit
b96fdbc
·
1 Parent(s): a9859a7

Update Database.py

Browse files
Files changed (1) hide show
  1. 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","==",False)
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
- for feedback in feedbacks:
68
- words_in_feedback=" ".join(feedback)
69
- words_in_feedback = Cleaning.txt_preprocess(words_in_feedback)
70
- most_common_words=Counter(words_in_feedback)
 
 
 
 
 
 
 
 
 
 
 
71
  return dict(most_common_words)
72
 
73
  def get_most_common_places():
74
- dic_place_count={}
75
- governorates=all_reviews.governorate
76
- for gov in governorates:
77
- if gov not in dic_place_count.keys():
78
- dic_place_count[gov]=0
79
- else :
80
- dic_place_count[gov]+=1
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