medspacy.visualization
MedspaCyVisualizerWidget
Source code in medspacy/visualization.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
__init__(docs, target_span_type='ents', span_group_name='medspacy_spans')
Create an IPython Widget Box displaying medspaCy's visualizers. The widget allows selecting visualization style ("Ent", "Dep", or "Both") and a slider for selecting the index of docs.
For more information on IPython widgets, see: https://ipywidgets.readthedocs.io/en/latest/index.html
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
docs
|
A list of docs processed by a medspaCy pipeline |
required |
Source code in medspacy/visualization.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
display()
Display the Box widget in the current IPython cell.
Source code in medspacy/visualization.py
308 309 310 311 312 | |
set_docs(docs)
Replace the list of docs to be visualized.
Source code in medspacy/visualization.py
335 336 337 338 | |
_create_color_generator()
Create a generator which will cycle through a list of default matplotlib colors
Source code in medspacy/visualization.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
visualize_dep(doc, jupyter=True)
Create a dependency-style visualization for ConText targets and modifiers in doc. This will show the relationships between entities in doc and contextual modifiers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
Doc
|
The spacy Doc to visualize. |
required |
jupyter
|
bool
|
Whether it is being rendered in a jupyter notebook. |
True
|
Returns:
| Type | Description |
|---|---|
str
|
The visualization. |
Source code in medspacy/visualization.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
visualize_ent(doc, context=True, sections=True, jupyter=True, colors=None, target_span_type='ents', span_group_name='medspacy_spans')
Creates a NER-style visualization for targets and modifiers in Doc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
Doc
|
A spacy doc to visualize. |
required |
context
|
bool
|
Whether to display the modifiers generated by medSpaCy's cycontext. If the doc has not been processed by context, this will be automatically changed to False. Default True. |
True
|
sections
|
bool
|
Whether to display the section titles generated by medSpaCy's sectionizer (still in development). If the doc has not been processed by sectionizer , this will be automatically changed to False. This may also have some overlap with cycontext, in which case duplicate spans will be displayed. Default True. |
True
|
jupyter
|
bool
|
If True, will render directly in a Jupyter notebook. If False, will return the HTML. Default True. |
True
|
colors
|
Dict[str, str]
|
An optional dictionary which maps labels of targets and modifiers to color strings to be rendered. If None, will create a generator which cycles through the default matplotlib colors for ent and modifier labels and uses a light gray for section headers. Default None. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The visualization. |
Source code in medspacy/visualization.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |