ModuleNotFoundError: No module named 'util'

I am trying to create a custom component class for sentimental analysis using the steps mentioned in this link.

I have done every steps mentioned there correctly, but when I try to train my bot this error is occurring.

ComponentNotFoundException: Failed to load the component 'sentiment.SentimentAnalyzer'. Failed to find module 'sentiment'. Either your pipeline configuration contains an error or the module you are trying to import is broken (e.g. the module is trying to import a package that is not installed). Traceback (most recent call last):
File "/home/dumin/.local/lib/python3.6/site-packages/rasa/nlu/registry.py", line 121, in get_component_class
   return rasa.shared.utils.common.class_from_module_path(component_name)
File "/home/dumin/.local/lib/python3.6/site-packages/rasa/shared/utils/common.py", line 37, in class_from_module_path
   m = importlib.import_module(module_name)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
   return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/dumin/.local/lib/python3.6/site-packages/sentiment/__init__.py", line 9, in <module>
   from util.summarize import Summarize
ModuleNotFoundError: No module named 'util'

I also intalled python utils package [pip install python-utils] but the same error is still occurring. can someone tell me how to solve this please??

I have herewith attached my config.yml file.my config.txt (907 Bytes) and my sentimental analysis component code sentiment anlysis implement code.txt (3.2 KB)

nlu file nlu.txt (235 Bytes)

and I have included my labels for intents into the labels.txt like this

- intent: feedback
     pos
     pos
     neu
     neu
     neg
     neg

Ah I fear you’ve found a very old blogpost. The API has since moved on.

You might enjoy this other repo that I maintain with example components. I’ll gladly answer any questions you may have on the implementation of these components.

1 Like

thank you for your reply. Is this can be used in sentimental analysis.

You can use the examples as a starting point to write your own components. You could make a component that adds sentiment information to the message for example.

Alternatively, you can also use a custom action to set a sentiment slot if that’s more inline with your usecase.

1 Like