AttributeError: [E046] Can't retrieve unregistered extension attribute 'phrases'. Did you forget to call the set_extension
method?
#11001
-
Info about spaCy
Some weeks ago I wrote (copy pasted) a script that does extract the most important sentences. Now I am getting this error. I haven't found anything useful on Google. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Can you share your code? It looks like, as the error indicates, you never called If I had to guess, it looks like maybe you imported your custom code when building a model, but now you've loaded the model and didn't import your code. If that's the problem, you should be able to fix the issue by importing the code with your custom function before loading the model. |
Beta Was this translation helpful? Give feedback.
-
I often get that error and it comes up in a couple of different instances. The most common issue for me is the extension attribute is is created in one component and a latter in the pipeline component needs that attribute for training purposes. The solution in that instance is to add something like this to the config file.
The other common issue I encounter is when there are two components that depend on each other and are very tightly coupled and even if the attribute is not needed for training a later component in the pipeline the logic consumes the attribute. You can add some logic to the lang factory for any attributes that are required as seen below.
The cause is often that for some edge case document the attribute is not properly set. The link below shows an example of catching this which basically checks after the logic that would create the attribute asserts something exists there and if not creates it. In this example it basically just checks to make sure it is not over writing anything but there can be edge cases and good to assert something is there and have an empty container to populate so that it exists, even if empty. |
Beta Was this translation helpful? Give feedback.
-
@polm @darrkj Many thanks for your answers. @darrkj has provided a codesnippet that solves the problem (somehow, I don't fully understand it). In case anyone is interested here is the code that I am running to extract the x most important sentences from a string:
with model = an arbitrary spacy model |
Beta Was this translation helpful? Give feedback.
I often get that error and it comes up in a couple of different instances. The most common issue for me is the extension attribute is is created in one component and a latter in the pipeline component needs that attribute for training purposes. The solution in that instance is to add something like this to the config file.
The other common issue I encounter is when there are two components that depend on each other and are very tightly coupled and even if the attribute is not needed for training a later component in the pipeline the logic consumes the attribute. You can add some logic to the lang factory for any attributes that ar…