Spaces:
Running
on
Zero
Running
on
Zero
Update motif_tagging.py
Browse files- motif_tagging.py +4 -3
motif_tagging.py
CHANGED
|
@@ -9,7 +9,7 @@ MOTIF_PATTERNS = {
|
|
| 9 |
r"\b(i'll|i will) put you in a (grave|hole|rose garden)\b",
|
| 10 |
r"\bsleep with one eye open( you'll see what happens)?\b",
|
| 11 |
r"\b(i'll|i will) make you disappear\b",
|
| 12 |
-
r"\b(i'll|i will|ill) put you in a rose garden\b"
|
| 13 |
],
|
| 14 |
"extreme_control": [
|
| 15 |
r"\b(i decide|i control) who you (see|talk to|text|spend time with)\b",
|
|
@@ -34,9 +34,10 @@ def detect_motifs(text):
|
|
| 34 |
|
| 35 |
for label, patterns in MOTIF_PATTERNS.items():
|
| 36 |
for pattern in patterns:
|
| 37 |
-
|
|
|
|
| 38 |
tags.append(label)
|
| 39 |
-
matched_phrases.append((label,
|
| 40 |
break
|
| 41 |
|
| 42 |
return tags, matched_phrases
|
|
|
|
| 9 |
r"\b(i'll|i will) put you in a (grave|hole|rose garden)\b",
|
| 10 |
r"\bsleep with one eye open( you'll see what happens)?\b",
|
| 11 |
r"\b(i'll|i will) make you disappear\b",
|
| 12 |
+
r"\b(i'll|i will|ill) put you in (a|the) rose garden\b"
|
| 13 |
],
|
| 14 |
"extreme_control": [
|
| 15 |
r"\b(i decide|i control) who you (see|talk to|text|spend time with)\b",
|
|
|
|
| 34 |
|
| 35 |
for label, patterns in MOTIF_PATTERNS.items():
|
| 36 |
for pattern in patterns:
|
| 37 |
+
match = re.search(pattern, text_lower)
|
| 38 |
+
if match:
|
| 39 |
tags.append(label)
|
| 40 |
+
matched_phrases.append((label, match.group()))
|
| 41 |
break
|
| 42 |
|
| 43 |
return tags, matched_phrases
|