node-nlp-rn not fully supporting rn?
Macilias opened this issue · comments
Describe the bug
I'm trying to follow your example for react-native, and after importing
import { NlpManager } from 'node-nlp-rn';
from the rn package
and calling the train method on the manager (after adding the documents and answers as in the example)
I get the following warning:
WARN Possible Unhandled Promise Rejection (id: 0):
TypeError: process.hrtime is not a function. (In 'process.hrtime()', 'process.hrtime' is undefined)
Secondly: While I still get the answer form manager.process
I wonder how to obtain the types
for the package to satisfy:
Could not find a declaration file for module 'node-nlp-rn'. '...node_modules/node-nlp-rn/lib/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/node-nlp-rn` if it exists or add a new declaration (.d.ts) file containing `declare module 'node-nlp-rn';`
Is there a type package planned or am I missing something? Thanks!
To Reproduce
Steps to reproduce the behavior:
- Go to https://www.npmjs.com/package/node-nlp-rn
- Try to run in the current React-Native environment
Expected behavior
I would expect no warnings
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: macOS
- Browser: not browser - ios
- Package version: "3.5.2"
- Node version "v16.10.0"
I was able to fix this problem, sort of.
I went to the JS file where this error was occurring, I believe it’s in node-nlp-rn/lib/classifiers/neural-network.js, and made some changes. Comment out:
const hrstart = process.hrtime();
and replace it with
const hrstart = performance.now();
Then you’ll need to go down a few lines and comment out the hrend, and replace it with:
const hrend = process.now() - hrstart;
It’s not as precise, but it’ll let it run on RN.