-
Notifications
You must be signed in to change notification settings - Fork 622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can we expect docs and examples update for v4? #596
Comments
Hi, I will put here a FAQ with the links to different interesting parts to documentation or examples. If there is something that you want to cover that is not here, just ask, and I will update the documentation with it. - Where do I find an example of use of v4? - But this example seems to be of the v3... - But I don't find the NluManager in this package... - Ok, but I feel that I want to go with the pure v4, how I start? - But this is for backend... I want this bundle to work in my browser or mobile using react native - This thing of intents is hard to understand, I just want to do a Questions and Answers bot - How I test my chatbot in Console? - How I do a multilanguage chatbot? - Do you have some example of a chatbot running in several languages? - Using node-nlp package I need to install the languages separately? - Where I can see the languages and their locales to find the correct package to install? - But I want to have a web for my chatbot! - But this does not help on how to orchestrate a chatbot - When an intent is triggered I want to get the answer from an API call and I'm not using any chatbot orchestrating SDK - How I guess the language from an utterance when I have a multi-language bot? - And how I guess a language from a sentence, not integrated with the NLP? - Ok, what about the NER? const { NlpManager } = require('node-nlp');
async function main() {
const manager = new NlpManager({ languages: ['en'], forceNER: true });
manager.addNamedEntityText(
'hero',
'spiderman',
['en'],
['Spiderman', 'Spider-man'],
);
manager.addNamedEntityText(
'hero',
'iron man',
['en'],
['iron man', 'iron-man'],
);
manager.addNamedEntityText('hero', 'thor', ['en'], ['Thor']);
manager.addNamedEntityText(
'food',
'burguer',
['en'],
['Burguer', 'Hamburguer'],
);
manager.addNamedEntityText('food', 'pizza', ['en'], ['pizza']);
manager.addNamedEntityText('food', 'pasta', ['en'], ['Pasta', 'spaghetti']);
const result = await manager.process('I saw spederman eating speghetti in the city');
console.log(result);
}
main(); - This is not extracting the entities... const manager = new NlpManager({ languages: ['en'], forceNER: true }); - The enum entity extraction is slow const manager = new NlpManager({ languages: ['en'], forceNER: true, ner: { threshold: 1 } }); With threshold set to 1, the exact match of entities is done by searching words in a dictionary, so the process is able to search over millions of posible values in miliseconds. - The builtin entity extraction is slow or crash the process - How I use enum entities - How I search entities by regular expressions - What builtin (golden) entities I can extract - I want to extract builtin (golden) entities but it only works in a few languages - I want to go "lowlevel" to use only the Neural Network for classifying - I want to use NGrams Here you have an example of how to use ngrams by char and by word: const { NGrams } = require('@nlpjs/utils');
const fs = require('fs');
const gramsByChar = new NGrams();
const gramsByWord = new NGrams({ byWord: true, startToken: '[START]', endToken: '[END]' });
const input = 'one ring to rule them all';
const outputByChar = gramsByChar.getNGrams(input, 3);
const outputByWord = gramsByWord.getNGrams(input, 3);
console.log(outputByChar);
console.log(outputByWord);
const freqByChar = gramsByChar.getNGramsFreqs(input, 2, true);
console.log(freqByChar);
const lines = fs.readFileSync('./data/wikipedia_es.txt', 'utf-8').split(/\r?\n/);
console.log(lines);
const freqs = gramsByChar.getNGramsFreqs(lines, 3);
console.log(freqs); - I want a pattern corpus, I mean, to generate a full cartesian product corpus from sentences with different options const { composeFromPattern, composeCorpus } = require('@nlpjs/utils');
const corpusPattern = require('./data/corpus-en-pattern.json');
const input = 'I [am having|have] a [problem|question|issue] that I have to [solve|investigate]';
const result = composeFromPattern(input);
console.log(result);
const corpus = composeCorpus(corpusPattern);
console.log(JSON.stringify(corpus, null, 2));
To use with this example corpus:
```json
{
"name": "Corpus Pattern",
"locale": "en-US",
"data": [
{
"intent": "eat",
"utterances": [
"I [usually|always] [like|love] to eat [pizza|spaghetti|burguer]"
],
"tests": [
"I [like|love] [pizza|burguer]"
]
},
{
"intent": "investigate",
"utterances": [
"I [am having|have] a [problem|question] that I have to [solve|investigate]"
],
"tests": [
"I should [solve|investigate] that [problem|question]"
]
}
]
} - I want to calculate the levenshtein distance of two strings Use similarity function, the third parameter by default is "false", set it to "true" if you want both strings to be normalized. const { similarity } = require('@nlpjs/similarity');
console.log(similarity('potatoe', 'potatoe'));
console.log(similarity('potatoe', 'potatoes'));
console.log(similarity('potatoe', 'potsatoe'));
console.log(similarity('potatoe', 'poattoe'));
console.log(similarity('potatoe', 'postatoé', true));
console.log(similarity('potatoe', 'Postatoé', true)); - Given a text I want to calculate the best substring that match an string Use getBestSubstring from ExtractorEnum of ner const { ExtractorEnum } = require('@nlpjs/ner');
const text = 'Morbi ainterd multricies neque varius condimentum. Donec volutpat turpis interdum metus ultricies vulputate. Duis ultricies rhoncus sapien, sit amet fermentum risus imperdiet vitae. Ut et lectus';
const str = 'interdum ultricies';
const extractor = new ExtractorEnum();
const result = extractor.getBestSubstring(text, str);
console.log(result); |
=] Thanks!! |
How do I get Trim Named Entities working? When I try using |
I'm struggling with that too. Is it possible to find one full working example on how to use NER and all of it functions? I cant find help for many of the functions, and all the examples ar or outdated or incomplete. Some function have "options" as last parameter and even going trough source code I could'nt figure that out. Looks like the "addTrimEntity" is no more, and it appears that direct function took its place, but just guessing here. Is there a working example on how to use "addBetweenCondition"? Thanks |
The first answer is amazing 👀 I've learnt a lot 🌶️. I was really looking to compute a corpus from code as well, thanks a lot. The only missing piece is how to use Ner in v4, bc the example is given with v3 code sample. There's a PS: this issue should be pinned. PS2: |
@carlocadiz @labs20 The methods are called addNER* in v4 ... just check the nlp class |
I included the FAQ into my PR to add to the main Readme |
Closing due to inactivity. Please, re-open if you think the topic is still alive. |
Hi. Before anything, thanks for your hard and awesome work on this package, and most of all, really thanks for sharing your hard work with us. Thanks!
Now, the lack of docs or functional examples about v4 is making hard to use this package. I mean, NLP is already hard on its own, at least for a newcomer like me, and I'm on that hard spot were I must choose and settle wich weapons I'll use for the entire project.
I'd like very much to stay on node so I'm trying to find packages that I could use to my main goal that is text classification. Right now it's looking that I should go to the other side of the fence and take python's spacy or nltk, with word2vec and such, but mostly because there are plenty of docs and examples to help me sort things out.
So, with all due respect for your time and work, is there a plan to produce new docs and examples, or there is a community forum that I could fetch more information about?
Thanks!
The text was updated successfully, but these errors were encountered: