Spaces:
Runtime error
Runtime error
Commit
·
8196d0d
1
Parent(s):
eff22c3
Update Database.py
Browse files- Database.py +24 -5
Database.py
CHANGED
@@ -93,7 +93,9 @@ def get_most_common_places():
|
|
93 |
dic_place_count[document.governorate] += 1
|
94 |
return dic_place_count
|
95 |
queuedUnSummurizedShawkas = []
|
|
|
96 |
semphoreShakwas=threading.Semaphore(0)
|
|
|
97 |
def summrizedshakwas():
|
98 |
global queuedUnSummurizedShawkas
|
99 |
global semphoreShakwas
|
@@ -101,16 +103,24 @@ def summrizedshakwas():
|
|
101 |
while True:
|
102 |
semphoreShakwas.acquire()
|
103 |
shawka=queuedUnSummurizedShawkas.pop(0)
|
104 |
-
tmpdict= models.modelsummary(shawka.complaintbody)
|
105 |
-
|
106 |
shawka.summary=tmpdict['summary']
|
107 |
db.collection("complaints").document(shawka.id).update({"summary":shawka.summary})
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
thread = threading.Thread(target=summrizedshakwas)
|
110 |
thread.start()
|
111 |
|
112 |
#lithening to changes of documnts
|
113 |
callback_done = threading.Event()
|
|
|
114 |
def on_snapshot(doc_snapshot, changes, read_time):
|
115 |
global queuedUnSummurizedShawkas
|
116 |
global semphoreShakwas
|
@@ -131,6 +141,15 @@ def on_snapshot(doc_snapshot, changes, read_time):
|
|
131 |
threadofcommonwords = threading.Thread(target=shakwa_common_words)
|
132 |
threadofcommonwords.start()
|
133 |
callback_done.set()
|
134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
docwatch= db.collection("complaints").on_snapshot(on_snapshot,)
|
136 |
-
|
|
|
93 |
dic_place_count[document.governorate] += 1
|
94 |
return dic_place_count
|
95 |
queuedUnSummurizedShawkas = []
|
96 |
+
queuedUnLabeledFeedbacks=[]
|
97 |
semphoreShakwas=threading.Semaphore(0)
|
98 |
+
semphoreFeedback=threading.Semaphore(0)
|
99 |
def summrizedshakwas():
|
100 |
global queuedUnSummurizedShawkas
|
101 |
global semphoreShakwas
|
|
|
103 |
while True:
|
104 |
semphoreShakwas.acquire()
|
105 |
shawka=queuedUnSummurizedShawkas.pop(0)
|
106 |
+
tmpdict= models.modelsummary(shawka.complaintbody)
|
|
|
107 |
shawka.summary=tmpdict['summary']
|
108 |
db.collection("complaints").document(shawka.id).update({"summary":shawka.summary})
|
109 |
+
def LabelingFeedback():
|
110 |
+
global queuedUnLabeledFeedbacks
|
111 |
+
global semphoreFeedback
|
112 |
+
global db
|
113 |
+
while True:
|
114 |
+
semphoreFeedback.acquire()
|
115 |
+
feedback=queuedUnLabeledFeedbacks.pop(0)
|
116 |
+
tmpdict=models.getlabelfeedback(feedback.feedback)
|
117 |
+
|
118 |
thread = threading.Thread(target=summrizedshakwas)
|
119 |
thread.start()
|
120 |
|
121 |
#lithening to changes of documnts
|
122 |
callback_done = threading.Event()
|
123 |
+
callback_donefeedback=threading.Event()
|
124 |
def on_snapshot(doc_snapshot, changes, read_time):
|
125 |
global queuedUnSummurizedShawkas
|
126 |
global semphoreShakwas
|
|
|
141 |
threadofcommonwords = threading.Thread(target=shakwa_common_words)
|
142 |
threadofcommonwords.start()
|
143 |
callback_done.set()
|
144 |
+
def on_snapshotfeedback(doc_snapshot, changes, read_time):
|
145 |
+
global queuedUnLabeledFeedbacks
|
146 |
+
global semphoreFeedback
|
147 |
+
for doc in doc_snapshot:
|
148 |
+
feedback=Classes.Feedback.from_dict(source=doc.to_dict())
|
149 |
+
if(feedback.label==None):
|
150 |
+
queuedUnLabeledFeedbacks.append(feedback)
|
151 |
+
semphoreFeedback.release()
|
152 |
+
|
153 |
+
callback_donefeedback.set()
|
154 |
docwatch= db.collection("complaints").on_snapshot(on_snapshot,)
|
155 |
+
docwatch2=db.collection("feedbacks") .on_snapshot(on_snapshotfeedback,)
|