reflexive 1.0.14__tar.gz → 1.0.16__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {reflexive-1.0.14/reflexive.egg-info → reflexive-1.0.16}/PKG-INFO +1 -1
- {reflexive-1.0.14 → reflexive-1.0.16}/reflexive/visualise.py +59 -9
- {reflexive-1.0.14 → reflexive-1.0.16/reflexive.egg-info}/PKG-INFO +1 -1
- {reflexive-1.0.14 → reflexive-1.0.16}/setup.cfg +1 -1
- {reflexive-1.0.14 → reflexive-1.0.16}/LICENSE +0 -0
- {reflexive-1.0.14 → reflexive-1.0.16}/LICENSE.txt +0 -0
- {reflexive-1.0.14 → reflexive-1.0.16}/MANIFEST.in +0 -0
- {reflexive-1.0.14 → reflexive-1.0.16}/README.md +0 -0
- {reflexive-1.0.14 → reflexive-1.0.16}/pyproject.toml +0 -0
- {reflexive-1.0.14 → reflexive-1.0.16}/reflexive/__init__.py +0 -0
- {reflexive-1.0.14 → reflexive-1.0.16}/reflexive/analyse.py +0 -0
- {reflexive-1.0.14 → reflexive-1.0.16}/reflexive/cfg.py +0 -0
- {reflexive-1.0.14 → reflexive-1.0.16}/reflexive/session.py +0 -0
- {reflexive-1.0.14 → reflexive-1.0.16}/reflexive/util.py +0 -0
- {reflexive-1.0.14 → reflexive-1.0.16}/reflexive.egg-info/SOURCES.txt +0 -0
- {reflexive-1.0.14 → reflexive-1.0.16}/reflexive.egg-info/dependency_links.txt +0 -0
- {reflexive-1.0.14 → reflexive-1.0.16}/reflexive.egg-info/top_level.txt +0 -0
- {reflexive-1.0.14 → reflexive-1.0.16}/tests/test_reflexive.py +0 -0
|
@@ -6,8 +6,36 @@ class Display:
|
|
|
6
6
|
config:cfg.Config = None
|
|
7
7
|
|
|
8
8
|
defaults = {
|
|
9
|
-
"priority_tags": [
|
|
10
|
-
|
|
9
|
+
"priority_tags": [
|
|
10
|
+
"VR_ER",
|
|
11
|
+
"AR",
|
|
12
|
+
"RR",
|
|
13
|
+
"EP_EV",
|
|
14
|
+
"AF_CN",
|
|
15
|
+
"EO",
|
|
16
|
+
"EA"
|
|
17
|
+
],
|
|
18
|
+
"colours": {
|
|
19
|
+
"VR_ER": "#ff6644",
|
|
20
|
+
"AR": "#00cc00",
|
|
21
|
+
"RR": "#6699ff",
|
|
22
|
+
"EP_EV": "#aacc33",
|
|
23
|
+
"AF_CN": "#dd44cc",
|
|
24
|
+
"EO":"#cccc00",
|
|
25
|
+
"EA":"#33cccc"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
# "VR_ER": "#ff6644", #Orange
|
|
30
|
+
# "AR": "#00cc00", #Green
|
|
31
|
+
# "RR": "#6699ff", #Blue
|
|
32
|
+
# "EP_EV": "#aacc33", #Lime
|
|
33
|
+
# "AF_CN": "#dd44cc", #magenta
|
|
34
|
+
# "EO":"#cccc00", #dark yellow
|
|
35
|
+
# "EA":"#33cccc" #dark Cyan
|
|
36
|
+
# {
|
|
37
|
+
# "priority_tags": ["VR_ER","AR","RR","EP_EV","AF_CN","KP"],
|
|
38
|
+
# "colours": {"VR_EV_CN": "#ff6644","ER_AF": "#dd44cc","AR": "#00cc00","EP": "#aacc33","RR": "#00aaff","KP":"#aaaacc"}}
|
|
11
39
|
|
|
12
40
|
def __init__(self,aws):
|
|
13
41
|
self.aws = aws
|
|
@@ -18,7 +46,7 @@ class Display:
|
|
|
18
46
|
def set_default_parameters(self):
|
|
19
47
|
priority_tags = self.defaults['priority_tags']
|
|
20
48
|
colours = self.defaults['colours']
|
|
21
|
-
options = {"ents": list(colours.keys()), "colors":
|
|
49
|
+
options = {"ents": list(colours.keys()), "colors": colours}
|
|
22
50
|
self.config.set_display_parameters(priority_tags,colours,options)
|
|
23
51
|
|
|
24
52
|
|
|
@@ -32,9 +60,15 @@ class Display:
|
|
|
32
60
|
temp_df['keyphrase_offsets'] = temp_df.KeyPhraseResults.apply(self.collect_keyphrase_offsets)
|
|
33
61
|
return temp_df
|
|
34
62
|
|
|
63
|
+
def add_syntax_offsets(self,df):
|
|
64
|
+
temp_df = df.copy()
|
|
65
|
+
temp_df['syntax_offsets'] = temp_df.SyntaxResults.apply(self.collect_syntax_offsets)
|
|
66
|
+
return temp_df
|
|
67
|
+
|
|
35
68
|
def add_offsets(self,df):
|
|
36
69
|
df = self.add_reflexive_offsets(df)
|
|
37
|
-
|
|
70
|
+
df = self.add_keyphrase_offsets(df)
|
|
71
|
+
return self.add_syntax_offsets(df)
|
|
38
72
|
|
|
39
73
|
def create_displacy(self,df):
|
|
40
74
|
all_ents = list(df.apply(self.render_record,axis=1))
|
|
@@ -53,12 +87,15 @@ class Display:
|
|
|
53
87
|
text = record['text']
|
|
54
88
|
reflexive_offsets = record['reflexive_offsets']
|
|
55
89
|
keyphrase_offsets = record['keyphrase_offsets']
|
|
90
|
+
syntax_offsets = record['syntax_offsets']
|
|
56
91
|
ents = []
|
|
57
92
|
taken = []
|
|
58
93
|
offsets = []
|
|
59
94
|
for tag in tags:
|
|
60
95
|
if tag in reflexive_offsets:
|
|
61
96
|
offsets = reflexive_offsets[tag]
|
|
97
|
+
elif tag in syntax_offsets:
|
|
98
|
+
offsets = syntax_offsets[tag]
|
|
62
99
|
elif tag in keyphrase_offsets:
|
|
63
100
|
offsets = keyphrase_offsets[tag]
|
|
64
101
|
|
|
@@ -100,11 +137,24 @@ class Display:
|
|
|
100
137
|
for rr in rrs:
|
|
101
138
|
if rr['Score']>0.5:
|
|
102
139
|
ent_type = rr['Type']
|
|
103
|
-
if ent_type in ['VR','
|
|
104
|
-
label = "
|
|
105
|
-
elif ent_type in ['
|
|
106
|
-
label = "
|
|
140
|
+
if ent_type in ['VR','ER']:
|
|
141
|
+
label = "VR_ER"
|
|
142
|
+
elif ent_type in ['EP','EV']:
|
|
143
|
+
label = "EP_EV"
|
|
144
|
+
elif ent_type in ['CN','AF']:
|
|
145
|
+
label = "AF_CN"
|
|
107
146
|
else:
|
|
108
147
|
label = ent_type
|
|
109
148
|
new_rrs.setdefault(label,[]).append((rr['BeginOffset'],rr['EndOffset']))
|
|
110
|
-
return new_rrs
|
|
149
|
+
return new_rrs
|
|
150
|
+
|
|
151
|
+
def collect_syntax_offsets(self,syntax_results):
|
|
152
|
+
offsets = {}
|
|
153
|
+
for sr in syntax_results:
|
|
154
|
+
pos = sr['PartOfSpeech']
|
|
155
|
+
if pos['Score']>0.99:
|
|
156
|
+
if pos['Tag'] in ['PRON','NOUN','ADJ']:
|
|
157
|
+
offsets.setdefault("EO",[]).append((sr['BeginOffset'],sr['EndOffset']))
|
|
158
|
+
if pos['Tag'] in ['ADV','VERB']:
|
|
159
|
+
offsets.setdefault("EA",[]).append((sr['BeginOffset'],sr['EndOffset']))
|
|
160
|
+
return offsets
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|