Spaces:
Build error
Build error
Update translation_utils.py
Browse files
llm_toolkit/translation_utils.py
CHANGED
|
@@ -23,7 +23,7 @@ comet = evaluate.load("comet")
|
|
| 23 |
|
| 24 |
|
| 25 |
def extract_answer(text, debug=False):
|
| 26 |
-
if text:
|
| 27 |
# Remove the begin and end tokens
|
| 28 |
text = re.sub(
|
| 29 |
r".*?(assistant|\[/INST\]).+?\b", "", text, flags=re.DOTALL | re.MULTILINE
|
|
@@ -240,6 +240,9 @@ def detect_repetition_scores(row, col, debug=False):
|
|
| 240 |
|
| 241 |
|
| 242 |
def count_chinese_characters(text):
|
|
|
|
|
|
|
|
|
|
| 243 |
# Define a regular expression pattern for Chinese characters
|
| 244 |
chinese_char_pattern = r"[\u4e00-\u9fff]"
|
| 245 |
|
|
|
|
| 23 |
|
| 24 |
|
| 25 |
def extract_answer(text, debug=False):
|
| 26 |
+
if text and isinstance(text, str):
|
| 27 |
# Remove the begin and end tokens
|
| 28 |
text = re.sub(
|
| 29 |
r".*?(assistant|\[/INST\]).+?\b", "", text, flags=re.DOTALL | re.MULTILINE
|
|
|
|
| 240 |
|
| 241 |
|
| 242 |
def count_chinese_characters(text):
|
| 243 |
+
if isinstance(text, str) is False:
|
| 244 |
+
return 0
|
| 245 |
+
|
| 246 |
# Define a regular expression pattern for Chinese characters
|
| 247 |
chinese_char_pattern = r"[\u4e00-\u9fff]"
|
| 248 |
|