Skip to content

Custom entities with regex pattern #86

Discussion options

You must be logged in to vote

Hello @bennyty

Based on the problem description, here is a possible solution:

const winkNLP = require( 'wink-nlp' );
const model = require( 'wink-eng-lite-web-model' );
const nlp = winkNLP( model );
const its = nlp.its;
// Define patterns.
const patterns = [
  { name: 'customEmoji', patterns: [ ': green _ checkmark :' ] },
  { name: 'mention', patterns: [ '< MENTION >' ] },
  { name: 'channel', patterns: [ '< HASHTAG >' ] }
];
// Train using patterns.
nlp.learnCustomEntities(patterns);
// Sample text
const text = "<@U024BE7LH> had shared a :green_checkmark: on  <#C024BE7LR> slack's channel after completing the task.";
// Read document.
const doc = nlp.readDoc( text );
// Print tokens.
con…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@bennyty
Comment options

@sanjayaksaxena
Comment options

Answer selected by sanjayaksaxena
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #85 on October 25, 2022 07:18.