Using the "natural" module in node.js

I am trying to play with the natural module in Node.JS. I wrote a simple program that takes input from a browser and uses a Bayesian classifier to classify it. However, at runtime, I get the following error:

/home/hadoop/cloud_major/testing/node_modules/natural/node_modules/apparatus/lib/apparatus/classifier/bayes_classifier.js:95 classifier.__proto__ = BayesClassifier.prototype; ^ TypeError: Cannot set property '__proto__' of undefined at Function.restore (/home/hadoop/cloud_major/testing/node_modules/natural/node_modules/apparatus/lib/apparatus/classifier/bayes_classifier.js:95:27) at restore (/home/hadoop/cloud_major/testing/node_modules/natural/lib/natural/classifiers/bayes_classifier.js:37:54) at /home/hadoop/cloud_major/testing/node_modules/natural/lib/natural/classifiers/bayes_classifier.js:44:23 at /home/hadoop/cloud_major/testing/node_modules/natural/lib/natural/classifiers/classifier.js:114:13 at fs.readFile (fs.js:176:14) at Object.oncomplete (fs.js:297:15) 

Now for research, I looked at the following thread for those who had a similar problem in another Node.JS module: https://github.com/andris9/mailcomposer/issues/6 I followed the decision to remove and reinstall the natural without help. I also found: http://tommytcchan.blogspot.in/2012_07_01_archive.html I used npm ls to get:

 ├─┬ natural@0.1.17 │ ├─┬ apparatus@0.0.6 │ │ └── sylvester@0.0.21 │ └── underscore@1.4.2 

Then I looked: Find the version of the installed npm package and received the following output:

 ├─┬ natural@0.1.17 │ ├─┬ apparatus@0.0.6 │ │ └── sylvester@0.0.21 │ └── underscore@1.4.2 

i.e. I think the local version of the installed packages matches the required dependencies. Has anyone else used this package and was able to debug this error?

Thank you very much in advance!

+4
source share
1 answer

Just a guess, but I think this is due to incorrect initialization.

 TypeError: Cannot set property '__proto__' of undefined 

I get similar errors when I try to use the properties of objects that I forgot to initialize in the first place. Having guessed the error, you cannot define or initialize the classifier by making it undefined . You cannot set or use properties on undefined .

Here are similar posts:

0
source

Source: https://habr.com/ru/post/1439723/


All Articles