Spaces:
Runtime error
Runtime error
changed elif order
Browse files
app.py
CHANGED
|
@@ -41,15 +41,14 @@ def extract_features(tokens, labels):
|
|
| 41 |
|
| 42 |
if label == 'LABEL_1':
|
| 43 |
# Check for partial date fragments (like '12' or '/')
|
| 44 |
-
if re.match(
|
| 45 |
-
print(f"Debug -- Potentially building date: Token Start {token} After Token")
|
| 46 |
-
current_date += token # Append token to the current entity
|
| 47 |
-
|
| 48 |
-
# If the accumulated entity matches a full date
|
| 49 |
-
elif re.match(date_pattern, current_date):
|
| 50 |
merged_entities.append((current_date, 'date'))
|
| 51 |
print(f"Debug -- Complete date added: {token}")
|
| 52 |
current_date = "" # Reset for next entity
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
else:
|
| 54 |
# No partial or completed patterns are detected, but it's still LABEL_1
|
| 55 |
# If there were any accumulated data so far
|
|
|
|
| 41 |
|
| 42 |
if label == 'LABEL_1':
|
| 43 |
# Check for partial date fragments (like '12' or '/')
|
| 44 |
+
if re.match(date_pattern, current_date):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
merged_entities.append((current_date, 'date'))
|
| 46 |
print(f"Debug -- Complete date added: {token}")
|
| 47 |
current_date = "" # Reset for next entity
|
| 48 |
+
# If the accumulated entity matches a full date
|
| 49 |
+
elif re.match(partial_date_pattern, token):
|
| 50 |
+
print(f"Debug -- Potentially building date: Token Start {token} After Token")
|
| 51 |
+
current_date += token # Append token to the current entity
|
| 52 |
else:
|
| 53 |
# No partial or completed patterns are detected, but it's still LABEL_1
|
| 54 |
# If there were any accumulated data so far
|