Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -1278,15 +1278,21 @@ def CompoundSimplify(xml_sent):
|
|
| 1278 |
s = re.sub(r"\s+", " ", s).strip()
|
| 1279 |
s = re.sub(r"\s+([.,!?;:])", r"\1", s)
|
| 1280 |
s = re.sub(r"([.,!?;:])\s+", r"\1 ", s)
|
|
|
|
| 1281 |
# decimals: 8 . 2 → 8.2
|
| 1282 |
s = re.sub(r"(\d)\s*\.\s*(\d)", r"\1.\2", s)
|
| 1283 |
-
|
| 1284 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1285 |
if s and not s.endswith((".", "!", "?")):
|
| 1286 |
s += "."
|
| 1287 |
-
|
| 1288 |
-
|
| 1289 |
-
|
|
|
|
| 1290 |
|
| 1291 |
sent1 = tidy(sent1)
|
| 1292 |
sent2 = tidy(sent2)
|
|
|
|
| 1278 |
s = re.sub(r"\s+", " ", s).strip()
|
| 1279 |
s = re.sub(r"\s+([.,!?;:])", r"\1", s)
|
| 1280 |
s = re.sub(r"([.,!?;:])\s+", r"\1 ", s)
|
| 1281 |
+
|
| 1282 |
# decimals: 8 . 2 → 8.2
|
| 1283 |
s = re.sub(r"(\d)\s*\.\s*(\d)", r"\1.\2", s)
|
| 1284 |
+
|
| 1285 |
+
# list-coordinator debris: "43;." / "43,." / "43;;." → "43."
|
| 1286 |
+
s = re.sub(r"[,;:]+\s*\.", ".", s)
|
| 1287 |
+
# dangling separators at end before a period is added
|
| 1288 |
+
s = re.sub(r"[,;:]+\s*$", "", s)
|
| 1289 |
+
|
| 1290 |
if s and not s.endswith((".", "!", "?")):
|
| 1291 |
s += "."
|
| 1292 |
+
if s:
|
| 1293 |
+
s = s[0].upper() + s[1:]
|
| 1294 |
+
return s
|
| 1295 |
+
|
| 1296 |
|
| 1297 |
sent1 = tidy(sent1)
|
| 1298 |
sent2 = tidy(sent2)
|