aliasgerovs commited on
Commit
c9c6240
1 Parent(s): 038d754

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +13 -13
utils.py CHANGED
@@ -217,19 +217,19 @@ def matchingScore(sentence, content):
217
  return len(matched) / len(ngrams)
218
 
219
 
220
- def matchingScoreWithTimeout(sentence, content):
221
- def timeout_handler():
222
- raise TimeoutError("Function timed out")
223
-
224
- timer = threading.Timer(10, timeout_handler) # Set a timer for 2 seconds
225
- timer.start()
226
- try:
227
- score = sentence_similarity(sentence, content)
228
- # score = matchingScore(sentence, content)
229
- timer.cancel() # Cancel the timer if calculation completes before timeout
230
- return score
231
- except TimeoutError:
232
- return 0
233
 
234
 
235
  # async def matchingScoreAsync(sentences, content, content_idx, ScoreArray):
 
217
  return len(matched) / len(ngrams)
218
 
219
 
220
+ # def matchingScoreWithTimeout(sentence, content):
221
+ # def timeout_handler():
222
+ # raise TimeoutError("Function timed out")
223
+
224
+ # timer = threading.Timer(10, timeout_handler) # Set a timer for 2 seconds
225
+ # timer.start()
226
+ # try:
227
+ # score = sentence_similarity(sentence, content)
228
+ # # score = matchingScore(sentence, content)
229
+ # timer.cancel() # Cancel the timer if calculation completes before timeout
230
+ # return score
231
+ # except TimeoutError:
232
+ # return 0
233
 
234
 
235
  # async def matchingScoreAsync(sentences, content, content_idx, ScoreArray):