Spaces:
Running
on
Zero
Running
on
Zero
Update motif_tagging.py
Browse files- motif_tagging.py +47 -48
motif_tagging.py
CHANGED
@@ -3,56 +3,55 @@
|
|
3 |
import re
|
4 |
|
5 |
MOTIF_PATTERNS = {
|
6 |
-
"physical_threat": [
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
],
|
26 |
-
"extreme_control": [
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
],
|
41 |
-
"suicidal_threat": [
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
]
|
53 |
}
|
54 |
|
55 |
-
|
56 |
def detect_motifs(text):
|
57 |
tags = []
|
58 |
matched_phrases = []
|
|
|
3 |
import re
|
4 |
|
5 |
MOTIF_PATTERNS = {
|
6 |
+
"physical_threat": [
|
7 |
+
r"\b(i['’]m|i am) going to (hurt|kill|break|ruin|destroy|end|bash|beat|smash|wreck) you\b",
|
8 |
+
r"\b(i['’]?ll|i will) (hurt|kill|ruin|wreck|end|destroy|obliterate|crush|eliminate|beat) you\b",
|
9 |
+
r"\b(i['’]?ll|i will) make you disappear\b",
|
10 |
+
r"\b(i['’]?ll|i will) put you in (a|the) (grave|hospital|ground|dirt|bodybag)\b",
|
11 |
+
r"\b(i['’]?ll|i will) snap your (neck|spine|arm|leg)\b",
|
12 |
+
r"\b(i['’]?ll|i will) break your (face|jaw|legs|arms|neck)\b",
|
13 |
+
r"\b(i['’]?ll|i will) beat the (shit|hell|crap) out of you\b",
|
14 |
+
r"\b(i['’]?ll|i will) f\*?ck you up\b",
|
15 |
+
r"\b(i['’]?ll|i will) (come for|find|hunt|get) you\b",
|
16 |
+
r"\b(i['’]?ll|i will) put you down\b",
|
17 |
+
r"\b(i['’]?ll|i will) end you\b",
|
18 |
+
r"\bi hope you (die|suffer|disappear)\b",
|
19 |
+
r"\byou better (run|hide|watch your back)\b",
|
20 |
+
r"\bsay goodbye\b.*\byou\b",
|
21 |
+
r"\bsleep with one eye open\b",
|
22 |
+
r"\b(i['’]?ll|i will) send you to (hell|the morgue)\b",
|
23 |
+
r"\b(i['’]?ll|i will) make sure you’re never seen again\b",
|
24 |
+
r"\b(i['’]?ll|i will|ill) put you in (a|the) rose garden\b"
|
25 |
+
],
|
26 |
+
"extreme_control": [
|
27 |
+
r"\b(i (won[’']?t|will not) let you (leave|go|talk to|see|text|spend time with) (him|her|them|anyone))\b",
|
28 |
+
r"\b(you (can[’']?t|are not allowed to|shouldn’t)) (go out|leave|talk to|see|text|spend time with|have friends)\b",
|
29 |
+
r"\b(i (decide|get to decide|control|own) what you (do|say|wear|eat|spend|see|talk to))\b",
|
30 |
+
r"\b(you['’]?re|you are) not allowed to (leave|talk to anyone|have your phone)\b",
|
31 |
+
r"\bi make the rules\b",
|
32 |
+
r"\bit’s my way or nothing\b",
|
33 |
+
r"\bi’ll take your (car|keys|money|phone)\b",
|
34 |
+
r"\byou don’t need anyone else\b",
|
35 |
+
r"\byou belong to me\b",
|
36 |
+
r"\bwithout me, you’re (nothing|no one)\b",
|
37 |
+
r"\byou do what i say\b",
|
38 |
+
r"\b(you better|you have to) do what i say\b",
|
39 |
+
r"\b(you['’]?re not going|you’re not leaving|i won’t let you go)\b"
|
40 |
+
],
|
41 |
+
"suicidal_threat": [
|
42 |
+
r"\b(i['’]?ll|i will) (kill|hurt) myself (if you leave|if you don’t come back|unless you stay)\b",
|
43 |
+
r"\bi (don’t|do not) want to live (without you|if you leave)\b",
|
44 |
+
r"\bi['’]?ll (die|disappear|end it) (if|unless) you (leave|go|don’t call)\b",
|
45 |
+
r"\b(if )?i['’]?ll make you watch me (suffer|bleed)\b",
|
46 |
+
r"\bi['’]?ll do something bad (to myself|if you leave)\b",
|
47 |
+
r"\bi['’]?ll regret it when i’m gone\b",
|
48 |
+
r"\bi can’t live without you\b",
|
49 |
+
r"\bmaybe (i should just die|it’d be better if i were dead)\b",
|
50 |
+
r"\bi’m better off dead\b",
|
51 |
+
r"\bi['’]?ll disappear forever if you walk out\b"
|
52 |
+
]
|
53 |
}
|
54 |
|
|
|
55 |
def detect_motifs(text):
|
56 |
tags = []
|
57 |
matched_phrases = []
|