reflexive 1.2.3__py3-none-any.whl → 1.2.5__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/analyse.py +1 -1
- reflexive/res.py +87 -3
- reflexive/res_functions.py +62 -0
- reflexive/session.py +1 -1
- reflexive/util.py +1 -1
- {reflexive-1.2.3.dist-info → reflexive-1.2.5.dist-info}/METADATA +1 -1
- reflexive-1.2.5.dist-info/RECORD +12 -0
- reflexive-1.2.3.dist-info/RECORD +0 -11
- {reflexive-1.2.3.dist-info → reflexive-1.2.5.dist-info}/WHEEL +0 -0
- {reflexive-1.2.3.dist-info → reflexive-1.2.5.dist-info}/licenses/LICENSE +0 -0
reflexive/analyse.py
CHANGED
reflexive/res.py
CHANGED
|
@@ -117,10 +117,94 @@ class Res_display:
|
|
|
117
117
|
html_out = displacy.render(disp_data,manual=True,style="ent", options=self.res_analyse.config.display_options,page=True,jupyter=False)
|
|
118
118
|
return html_out
|
|
119
119
|
|
|
120
|
-
def
|
|
120
|
+
def get_interactions(self,df:DataFrame) -> DataFrame:
|
|
121
121
|
#Get RE sequence
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
df = self._add_res_sequence(df)
|
|
123
|
+
df = self._add_res_interactions(df)
|
|
124
|
+
df = self._add_res_adj_matrix(df)
|
|
125
|
+
return df
|
|
126
|
+
|
|
127
|
+
def show_graph(self,df:DataFrame,inline=True) -> str:
|
|
128
|
+
for am in df.res_adj_matrix:
|
|
129
|
+
g = RES_graph(am)
|
|
130
|
+
g.show()
|
|
131
|
+
return("nothing yet")
|
|
132
|
+
|
|
133
|
+
def _add_res_sequence(self,df):
|
|
134
|
+
temp_df = df.copy()
|
|
135
|
+
temp_df['res_sequence'] = temp_df.reflexive_expressions.apply(self._get_res_sequence)
|
|
136
|
+
return temp_df
|
|
137
|
+
|
|
138
|
+
def _add_res_interactions(self,df):
|
|
139
|
+
temp_df = df.copy()
|
|
140
|
+
temp_df['res_interactions'] = temp_df.res_sequence.apply(self._count_res_interactions)
|
|
141
|
+
return temp_df
|
|
142
|
+
|
|
143
|
+
def _add_res_weights(self,df):
|
|
144
|
+
temp_df = df.copy()
|
|
145
|
+
temp_df['res_weights'] = temp_df.res_interactions.apply(self._calc_res_weights)
|
|
146
|
+
return temp_df
|
|
147
|
+
|
|
148
|
+
def _add_res_adj_matrix(self,df):
|
|
149
|
+
temp_df = df.copy()
|
|
150
|
+
temp_df['res_adj_matrix'] = temp_df.res_weights.apply(self._create_adj_matrix)
|
|
151
|
+
return temp_df
|
|
152
|
+
|
|
153
|
+
def _get_res_sequence(self,reflexive_expressions):
|
|
154
|
+
re_seq = [label for re,label in reflexive_expressions]
|
|
155
|
+
res_seq = []
|
|
156
|
+
# Need to substitute new RES labels for old RE labels
|
|
157
|
+
for re in re_seq:
|
|
158
|
+
if re=='ER' or re=='VR':
|
|
159
|
+
res_seq.append('NR')
|
|
160
|
+
elif re=='EV':
|
|
161
|
+
res_seq.append('EP')
|
|
162
|
+
elif re=='CN':
|
|
163
|
+
res_seq.append('AF')
|
|
164
|
+
else:
|
|
165
|
+
res_seq.append(re)
|
|
166
|
+
return res_seq
|
|
167
|
+
|
|
168
|
+
def _empty_res_interactions(self) -> dict[tuple,int]:
|
|
169
|
+
RE_types = ['RR','NR','AR','AF','EP']
|
|
170
|
+
RE_interactions:dict[tuple,int] = dict()
|
|
171
|
+
for t1 in RE_types:
|
|
172
|
+
for t2 in RE_types:
|
|
173
|
+
entry = tuple(sorted((t1,t2)))
|
|
174
|
+
if entry not in RE_interactions.keys():
|
|
175
|
+
RE_interactions[entry] = 0
|
|
176
|
+
return RE_interactions
|
|
177
|
+
|
|
178
|
+
def _count_res_interactions(self,re_sequence:list[str]) -> dict[tuple,int]:
|
|
179
|
+
re_ints = self._empty_res_interactions()
|
|
180
|
+
limit = len(re_sequence)-1
|
|
181
|
+
for i,s in enumerate(re_sequence):
|
|
182
|
+
if i < limit:
|
|
183
|
+
rei = tuple(sorted((s,re_sequence[i+1])))
|
|
184
|
+
#print(i,rei)
|
|
185
|
+
re_ints[rei] += 1
|
|
186
|
+
return re_ints
|
|
187
|
+
|
|
188
|
+
def _calc_res_weights(self,interactions:dict[tuple,int])->dict[tuple,float]:
|
|
189
|
+
max = max(interactions.values())
|
|
190
|
+
weights = dict()
|
|
191
|
+
for edge,count in interactions.items():
|
|
192
|
+
weights[edge] = round(count/(15*max),3)
|
|
193
|
+
return weights
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def _create_adj_matrix(self,weights:dict[tuple,float])->list[list[float]]:
|
|
197
|
+
re_types = ["RR","NR","AR","AF","EP"]
|
|
198
|
+
matrix = []
|
|
199
|
+
for r in re_types:
|
|
200
|
+
row = []
|
|
201
|
+
for c in re_types:
|
|
202
|
+
key = tuple(sorted((r,c)))
|
|
203
|
+
#print(key)
|
|
204
|
+
weight = weights.get(key,0)
|
|
205
|
+
row.append(weight)
|
|
206
|
+
matrix.append(row)
|
|
207
|
+
return matrix
|
|
124
208
|
|
|
125
209
|
|
|
126
210
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# import text into dataframe
|
|
2
|
+
# accepts either an iterable of strings, or an iterable over text files
|
|
3
|
+
# returns a pandas series iterable of type string
|
|
4
|
+
|
|
5
|
+
# clean text and calculate length
|
|
6
|
+
# accepts an iterable of strings in form of pandas series of type string
|
|
7
|
+
# returns a pandas series iterable of type int
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# chunk text and keep original index ref
|
|
11
|
+
# accepts an iterable of dataframe rows
|
|
12
|
+
# returns an iterable of dataframe rows with added column 'text_chunks' - list of strings
|
|
13
|
+
|
|
14
|
+
# upload docs to s3 and save local copy - side effects
|
|
15
|
+
# accepts an iterable of iterable of chunks (with ids)
|
|
16
|
+
# returns an an iterable of s3 responses? URLs to S3 file?
|
|
17
|
+
|
|
18
|
+
# initiate custom entity job on comprehend
|
|
19
|
+
# no parameters
|
|
20
|
+
# returns job id for checking status, and downloading
|
|
21
|
+
|
|
22
|
+
# check status
|
|
23
|
+
# accepts job id
|
|
24
|
+
# returns status
|
|
25
|
+
|
|
26
|
+
# download results
|
|
27
|
+
# accepts job id
|
|
28
|
+
# returns iterable of results
|
|
29
|
+
|
|
30
|
+
# unpack results and load into dataframe
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# extract reflexive expressions into dataframe
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# get reflexive sequences
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# get interactions
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# create count adj matrix
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# create weighted adj matrix
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# save dataframe to file
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# visualise expressions in text
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# visualise reflexive sequence
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# visualise res graph
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
#
|
|
61
|
+
# Network analysis functions
|
|
62
|
+
#
|
reflexive/session.py
CHANGED
reflexive/util.py
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
reflexive/__init__.py,sha256=x5l8GV_9yC8yJyjTLqiM_WkfuPMLuNgQxF6PIz5MfFU,422
|
|
2
|
+
reflexive/analyse.py,sha256=CU6mQ8PxQrkOvuSe4mmnuI18jGMkuxql3zLZ1vEeMEY,17466
|
|
3
|
+
reflexive/cfg.py,sha256=tDPiC9NwpEVoT05_831sMsMfHhJt8pVrSOsgbtzTNDM,4267
|
|
4
|
+
reflexive/res.py,sha256=ekpjo-dA4QT3swE-HDsWrgHp2oYy8SD2qVAeUL4v1OM,7393
|
|
5
|
+
reflexive/res_functions.py,sha256=YF45yUF8NYMSC19DFpE0lmV4xyNxv3QqbbzZmdwmFzg,1231
|
|
6
|
+
reflexive/session.py,sha256=8STWo8sqmWn-1PHcloFbgmLEvd7lsiFTU4t7ESRTsvw,10046
|
|
7
|
+
reflexive/util.py,sha256=uU7-lqUmiCiCaR85AdNFKXrdrBspjb1Rmd-yThA3fRU,3699
|
|
8
|
+
reflexive/visualise.py,sha256=pVnsPJOnHiLAIvDDm9P0u6-sGQINC4GVOY9b0GrzTK4,11725
|
|
9
|
+
reflexive-1.2.5.dist-info/METADATA,sha256=NLXNj7RjrhdIBaIezMJFtTXfayBQ7QAMiCCk6Y1LEYc,574
|
|
10
|
+
reflexive-1.2.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
11
|
+
reflexive-1.2.5.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
12
|
+
reflexive-1.2.5.dist-info/RECORD,,
|
reflexive-1.2.3.dist-info/RECORD
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
reflexive/__init__.py,sha256=x5l8GV_9yC8yJyjTLqiM_WkfuPMLuNgQxF6PIz5MfFU,422
|
|
2
|
-
reflexive/analyse.py,sha256=LsDgFI_UUlK88ecQc19iPdcweAvT11CZCqtWtCsevC8,17465
|
|
3
|
-
reflexive/cfg.py,sha256=tDPiC9NwpEVoT05_831sMsMfHhJt8pVrSOsgbtzTNDM,4267
|
|
4
|
-
reflexive/res.py,sha256=D4LfMG20BikFHdLts3v6dbYZG6UubCNlGUBUJbpJfwg,4398
|
|
5
|
-
reflexive/session.py,sha256=ttyUAowaKgkwAgejRb_af5nZruKeH_kn3NB1NtitYUk,10045
|
|
6
|
-
reflexive/util.py,sha256=zwlFncsWrRSuK8rsQaZKFNVLTkRySb1WPeY6Hz6qHhc,3698
|
|
7
|
-
reflexive/visualise.py,sha256=pVnsPJOnHiLAIvDDm9P0u6-sGQINC4GVOY9b0GrzTK4,11725
|
|
8
|
-
reflexive-1.2.3.dist-info/METADATA,sha256=NlCGUhf0OJWmRImBng_9YQGTsWbDFf-roOwVT_xVl88,574
|
|
9
|
-
reflexive-1.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
10
|
-
reflexive-1.2.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
11
|
-
reflexive-1.2.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|