abchapman93 / cycontext_old Goto Github PK
View Code? Open in Web Editor NEWA Python implementation of the ConText algorithm for clinical text concept assertion using the spaCy framework
A Python implementation of the ConText algorithm for clinical text concept assertion using the spaCy framework
There is an exception in cycontext when several default components are missing. I think this is because there is no sentence. This should be handled gracefully -- perhaps with a warning to check that expected components (i.e. something that leads to sentence boundary detection) must be enabled?
nlp = spacy.load('en')
#nlp.remove_pipe('tagger')
#nlp.remove_pipe('parser')
# and then cycontext
item_data = [ConTextItem("no evidence of", "DEFINITE_NEGATED_EXISTENCE", rule="forward")]
context = ConTextComponent(nlp)
context.add(item_data)
nlp.add_pipe(context, last=True)
text = "Congestion but no evidence of pneumonia."
doc = nlp(text)
Here's the call stack:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-5-d0f024db1ca2> in <module>
1 text = "Congestion but no evidence of pneumonia."
2
----> 3 doc = nlp(text)
4 print(doc._.context_graph.edges)
5
~\AppData\Roaming\Python\Python36\site-packages\spacy\language.py in __call__(self, text, disable, component_cfg)
433 if not hasattr(proc, "__call__"):
434 raise ValueError(Errors.E003.format(component=type(proc), name=name))
--> 435 doc = proc(doc, **component_cfg.get(name, {}))
436 if doc is None:
437 raise ValueError(Errors.E005.format(name=name))
~\AppData\Roaming\Python\Python36\site-packages\cycontext\context_component.py in __call__(self, doc)
165 # Get the ConTextItem object defining this modifier
166 item_data = self._modifier_item_mapping[match_id]
--> 167 tag_object = TagObject(item_data, start, end, doc)
168 context_graph.modifiers.append(tag_object)
169
~\AppData\Roaming\Python\Python36\site-packages\cycontext\tag_object.py in __init__(self, context_item, start, end, doc)
19 self._scope_start = None
20 self._scope_end = None
---> 21 self.set_scope()
22
23 @property
~\AppData\Roaming\Python\Python36\site-packages\cycontext\tag_object.py in set_scope(self)
47
48 if self.rule.lower() == "forward":
---> 49 self._scope_start, self._scope_end = self.end, sent.end
50 elif self.rule.lower() == "backward":
51 self._scope_start, self._scope_end = sent.start, self.start
AttributeError: 'NoneType' object has no attribute 'end'
@abchapman93
Great job here! Any chance you can tell me a bit about it. Maybe I could ask you questions regarding my own project? Perhaps via linked in? Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.