Giter VIP home page Giter VIP logo

cycontext_old's Issues

Exception when disabling upstream components

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'

love your work

@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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.