reflexive 1.0.15__py3-none-any.whl → 1.0.16__py3-none-any.whl

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/visualise.py CHANGED
@@ -6,8 +6,36 @@ class Display:
6
6
  config:cfg.Config = None
7
7
 
8
8
  defaults = {
9
- "priority_tags": ["AR","EP","VR_EV_CN","ER_AF","RR","KP"],
10
- "colours": {"VR_EV_CN": "#ff6644","ER_AF": "#dd44cc","AR": "#00cc00","EP": "#aacc33","RR": "#00aaff","KP":"#aaaacc"}}
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
@@ -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
- return self.add_keyphrase_offsets(df)
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','EV','CN']:
104
- label = "VR_EV_CN"
105
- elif ent_type in ['ER','AF']:
106
- label = "ER_AF"
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: reflexive
3
- Version: 1.0.15
3
+ Version: 1.0.16
4
4
  Summary: Supports AWS Reflexive Expressions Analysis
5
5
  Home-page: https://github.com/nlytx/reflexive
6
6
  Author: Andrew Gibson
@@ -3,10 +3,10 @@ reflexive/analyse.py,sha256=UzWwgjAFNjeWFkCQ2o99g2vWajf17_OtSq4dFCvuPYU,17489
3
3
  reflexive/cfg.py,sha256=Ges35G234P2lvOQHgPZQae5hMSOGyBsmp1bY_yQEKkk,4303
4
4
  reflexive/session.py,sha256=MbqwTsYTgq_e_gw3mb1eRv6USs-zZ2cTCrvUNWuKfAQ,10067
5
5
  reflexive/util.py,sha256=WQ1oyzDi1i8wQ6IBwBPk6IFy07YKhg-Ug2FsOGVJRJQ,3649
6
- reflexive/visualise.py,sha256=gsTqZRRvmfonxz6ZWFhaZURl9LalRMWrSZBrpasIitQ,4031
7
- reflexive-1.0.15.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
8
- reflexive-1.0.15.dist-info/LICENSE.txt,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
9
- reflexive-1.0.15.dist-info/METADATA,sha256=dC2sVG_Bv-h3PS7opJeC2alRO9PWdfEdDfRk5eJrSvw,12038
10
- reflexive-1.0.15.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
11
- reflexive-1.0.15.dist-info/top_level.txt,sha256=pOMr-QGleRBRCFBozgvM-UUUmOjD_-naJfu1522E2V8,10
12
- reflexive-1.0.15.dist-info/RECORD,,
6
+ reflexive/visualise.py,sha256=9f-4tfUsv2-zr9tlKZcEEkugEPffcoAogXMWqnmcECs,5615
7
+ reflexive-1.0.16.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
8
+ reflexive-1.0.16.dist-info/LICENSE.txt,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
9
+ reflexive-1.0.16.dist-info/METADATA,sha256=_Ck3ePqPaq4QWZzkmqAnnZqCU1eTZXFZeLG7Lb2twg4,12038
10
+ reflexive-1.0.16.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
11
+ reflexive-1.0.16.dist-info/top_level.txt,sha256=pOMr-QGleRBRCFBozgvM-UUUmOjD_-naJfu1522E2V8,10
12
+ reflexive-1.0.16.dist-info/RECORD,,