Spaces:
Runtime error
Runtime error
fix empty output when sentence has no period
Browse files
app.py
CHANGED
@@ -10,6 +10,11 @@ client = InferenceClient(model=hugging_face_model_path, token=os.getenv('HUGGING
|
|
10 |
def split_and_generate(modern_text):
|
11 |
# Split the input text into sentences for the model is trained on sentence pairs
|
12 |
sentences = re.findall(r'[^。!?]*[。!?]', modern_text)
|
|
|
|
|
|
|
|
|
|
|
13 |
responses = ""
|
14 |
for sentence in sentences:
|
15 |
input = "现代文:" + sentence + " 古文:"
|
|
|
10 |
def split_and_generate(modern_text):
|
11 |
# Split the input text into sentences for the model is trained on sentence pairs
|
12 |
sentences = re.findall(r'[^。!?]*[。!?]', modern_text)
|
13 |
+
|
14 |
+
# If no sentences are found, treat the entire input as one sentence
|
15 |
+
if not sentences:
|
16 |
+
sentences = [modern_text]
|
17 |
+
|
18 |
responses = ""
|
19 |
for sentence in sentences:
|
20 |
input = "现代文:" + sentence + " 古文:"
|