1.3.3 • Published 2 years ago

know-parser v1.3.3

Weekly downloads
46
License
MIT
Repository
github
Last release
2 years ago

know-parser

npm.io npm.io Coverage Status

Parses a piece of text to grab the most useful data

know-parser is a JavaScript plugin-based package designed to extract useful data from a piece of text

This package comes bundled with a few pre-existing plugins to use right out of the box. If you would like to create your own plugins, see ./PLUGIN_DEVELOPMENT.md

This plugin was inspired by knwl.js

Installation

npm install --save know-parser

Usage Guide

Example script

const parser = require("know-parser");
const knowParser = new parser("a bunch of words with an email: knowparser@implink.org");

const emails = knowParser.get("emails");
console.log(emails); // output: ["knowparser@implink.org"]

Detailed walkthrough

  1. Create a new instance of know-parser

    const parser = require("know-parser");
    const knowParser = new parser();
  2. Provide a piece of text to parse

    // string
    knowParser.lines = "this is a piece of text";
    
    // array
    knowParser.lines = ["an array", "of words"];
    
    // you can also provide lines via the constructor
    const knowParser = new parser("this is a piece of text");
  3. Run a plugin on the piece of text

    const emails = knowParser.get("emails");
    console.log(emails); // an array of email addresses

Default Plugins

These are automatically loaded by default.

emails

const emails = knowParser.get("emails");
console.log(emails); // An array of email addresses

phones

const phones = knowParser.get('phones');
console.log(phones); // An array of phone numbers

links

const links = knowParser.get('links');
console.log(links); // An array of links (starting with http/https/www) e.g. "https://www.example.com"

You can also filter results like so:

const links = knowParser.get('links', ['google.com'])
console.log(links) // An array of links including 'google.com'

domains

const domains = knowParser.get('domains');
console.log(domains); // an array of domains e.g. "example.com"

Developing Parser Plugins

Because of the plugin-based nature of this package, it's surprisingly simple to create your own plugins for know-parser. If you would like to contribute to/create a plugin please see ./PLUGIN_DEVELOPMENT.md

1.3.3

2 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.13

3 years ago

1.2.12

4 years ago

1.2.11

4 years ago

1.2.10

4 years ago

1.2.9

4 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago