entity-parser
Entity parser for texts
Last updated a year ago by queenscrown .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install entity-parser 
SYNC missed versions from official npm registry.

Entity-Parser

Entity parser for DialogEngine

Build Status FOSSA Status


  $ npm i entity-parser

Parsing texts

entityParser.parse("Hello ${ai.name||ai.nickname}! How is the weather in ${user.location} ?",{
    prefix:"$", // ${entity}
})
  .then(function(data) {
    console.log(data.toArray());
      /*
      //List of entities
      [
        {
          complete: true,
          start: 7,
          end: 29,
          nextWord: '!',
          startAfterNextWord: null,
          prevNextWord: null,
          found: ['ai.name', 'ai.nickname'],
          type: 'or'
        },
        {
          complete: true,
          start: 54,
          end: 69,
          nextWord: '?',
          startAfterNextWord: 23,
          prevNextWord: '!',
          found: 'user.location',
          type: 'single'
        }
      ]
      //Encoded data for decoding 
        console.log(data.encoded());
        5b7b22636f6d706c657465223a747275652c227374617274223a372c22656e64223a32392c226e65787...
      */
    }).catch(function(err){
      console.log(err)
    })

Decoding parsed texts

      var encodedData = "5b7b22636f6d706c657465223a747275652c227374617274223a372c22656e64223a32392c226e65787..."
      parser.decode("Hello Ann! How is the weather in Istanbul ?",{
        hex: encodedData
      })
      .then(function(data){
        console.log(data);    
        /*
        //List of data
          {
            'ai.name,ai.nickname': {
              pos: 9,
              pre: 6,
              found: 'Ann'
            },
            'user.location': {
              pos: 42,
              pre: 33,
              found: 'Istanbul'
            }
          }
        */
      })
      .catch(function(err){
        console.log(err)
      })

Run tests


$ npm test

FOSSA Status

Current Tags

  • 2.1.5                                ...           latest (a year ago)

2 Versions

  • 2.1.5                                ...           a year ago
  • 2.1.4                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 1
Last Week 0
Last Month 1
Dependencies (3)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |