cofeg commited on
Commit
ae504c8
·
verified ·
1 Parent(s): 4e2646a

fix empty output when sentence has no period

Browse files
Files changed (1) hide show
  1. app.py +5 -0
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 + " 古文:"