Spaces:
Sleeping
Sleeping
Ryan
commited on
Commit
·
e4798a1
1
Parent(s):
c0e1d59
update
Browse files- ui/analysis_screen.py +8 -2
ui/analysis_screen.py
CHANGED
@@ -262,8 +262,8 @@ def compare_ngrams(text1, text2, n=2):
|
|
262 |
Compare n-grams between two texts.
|
263 |
|
264 |
Args:
|
265 |
-
text1 (str): First text
|
266 |
-
text2 (str): Second text
|
267 |
n (int or str): Size of n-grams
|
268 |
|
269 |
Returns:
|
@@ -277,6 +277,12 @@ def compare_ngrams(text1, text2, n=2):
|
|
277 |
if isinstance(n, str):
|
278 |
n = int(n)
|
279 |
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
# Make sure nltk resources are available
|
281 |
try:
|
282 |
tokens1 = nltk.word_tokenize(text1.lower())
|
|
|
262 |
Compare n-grams between two texts.
|
263 |
|
264 |
Args:
|
265 |
+
text1 (str or list): First text
|
266 |
+
text2 (str or list): Second text
|
267 |
n (int or str): Size of n-grams
|
268 |
|
269 |
Returns:
|
|
|
277 |
if isinstance(n, str):
|
278 |
n = int(n)
|
279 |
|
280 |
+
# Handle list inputs by converting to strings
|
281 |
+
if isinstance(text1, list):
|
282 |
+
text1 = ' '.join(str(item) for item in text1)
|
283 |
+
if isinstance(text2, list):
|
284 |
+
text2 = ' '.join(str(item) for item in text2)
|
285 |
+
|
286 |
# Make sure nltk resources are available
|
287 |
try:
|
288 |
tokens1 = nltk.word_tokenize(text1.lower())
|