Socket
Book a DemoInstallSign in
Socket

lucene-tokenizers

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lucene-tokenizers

Port from Apache Lucene

latest
npmnpm
Version
5.3.3
Version published
Maintainers
1
Created
Source

Online Demo

Install:

npm install lucene-tokenizers

Example:

var lt = require('lucene-tokenizers');

var ts = new lt.StandardTokenizer();
ts.setReader(new lt.StringReader("Hello World!"));
var res = [], token = null;
while ((token = ts.incrementToken()) !== null) {
  var pretty_token = {};
  for (var prop in token) {
    if(token.hasOwnProperty(prop)) {
      pretty_token[prop.substring('_$esjava$'.length)] = token[prop];
    } 
  }
  res.push(pretty_token);
}

console.log(JSON.stringify(res, null, 2));

Output:

[
  {
    "text": "Hello",
    "type": "<ALPHANUM>",
    "start": 0,
    "positionIncrement": 1
  },
  {
    "text": "World",
    "type": "<ALPHANUM>",
    "start": 6,
    "positionIncrement": 1
  }
]

More about ESJava

Keywords

Lucene

FAQs

Package last updated on 11 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts