New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-nlp

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-nlp

Visualization of Natural Language Processing for React

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

react-nlp

Visualization of Natural Language Processing for React

Installation

npm install react-nlp

Usage

import React from "react";
import { render } from "react-dom";
import { View } from "react-nlp";

render(
  <View
    types={types}
    data={data}
    colors={colors}
  />,
  document.getElementById("root")
);

Properties of View Component

PropertyTypeOptionalDefaultDescription
typesArrayNo-Annotation type list
dataArrayNo-Text and annotation data
reationsArrayYes-Relation list
colorsObjectYes-Color map for annotation labels
linumbooleanYestrueIf true, show line numbers
lineBreakbooleanYestrueIf true, enable line break
keepWhiteSpacesbooleanYesfalseIf true, show multiple consecutive whitespace
themeObjectYes-Override the defaultTheme

types

The types is an array of annotation type to show.

The annotations are shown in the order of types.

example:

["wiki", "ne", "pos"]

data

The data is an array of the object consists of a text and annotation data .

PropertyTypeOptionalDescription
data[].textstringNoText
data[].annoArrayNoAnnotation data for the text
data[].anno[][0]stringNoAnnotation type
data[].anno[][1]numberNoStart index of the text to annotate
data[].anno[][2]numberNoEnd index of the text to annotate
data[].anno[][3]stringNoAnnotation label

example:

[
  {
    text: "Darth Vador, also known as Anakin Skywalker is a fictional character.",
    anno: [
      ["wiki", 0, 10, "Darth_Vador"],
      ["wiki", 27, 41, "Darth_Vador"],
      ["ne", 0, 10, "PERSON"],
      ["ne", 27, 41, "PERSON"],
      ["pos", 0, 4, "NNP"],
      ["pos", 6, 10, "NNP"],
      ["pos", 11, 11, ","]
    ]
  },
  {
    text: "He is originally a good person, but",
    anno: [
      ["pos", 0, 1, "PRP"],
      ["pos", 3, 4, "VBZ"],
      ["pos", 6, 15, "RB"],
      ["pos", 17, 17, "DT"],
    ]
  }
]

relations

The relations is a list of relation of annotations.

PropertyTypeOptionalDescription
realations[][0]stringNoType of relation
tt: tail-tail relation (-)
ht: head-tail relation (←)
th: tail-head relation (→)
hh: head-head relation (↔)
realations[][1]numberNoFirst sentence index
realations[][2]numberNoFirst span index
realations[][3]numberNoSecond sentence index
realations[][4]numberNoSecond span index
realations[][5]stringNoRelation label

example:

[
  ["hh", 0, 0, 0, 1, "rel_label1"],
  ["ht", 0, 0, 0, 2, "rel_label2"],
  ["tt", 0, 0, 1, 0, "rel_label3"],
  ["hh", 0, 0, 1, 7, "rel_label4"]
]

colors

The colors is a map for colors for annotation labels.

example:

{
  "wiki": {
    "Darth_Vador": "gray"
  },
  "ne": {
    "PERSON": "yellow"
  },
  "pos": {
    ",": "#84b62b"
  }
}

theme

PropertyTypeDefaultDescription
fontSizestring|number14text font size
borderStylenumber10: none, 1: full, 2: simple
borderstring"solid 1px #9a9a9a"css border format
colorstring"black"text font color
linumColorstring"#9a9a9a"linum color
stripebooleantrueenable/disable stripe
stripeColorArray["#ffffff", "#f2f2f2"]stripe color
linePaddingstring|number"15px 5px"line padding
annotationLinePaddingstring|number"2px 3px"annotation line padding
labelFontSizestring|number"0.6em"label font size
labelColorstring"black"label color
labelPaddingstring"2px 3px"label padding
labelBorderstring"solid 1px gray"label border
characterPaddingstring|number0character left-right padding
relationColorstring"black"relation color
relationLabelFontSizestring|number"12px"relation label font size
relationLabelPaddingstring|number"2px 3px"relation label padding
relationLabelBorderstring"solid 1px gray"relation label border
relationLabelColorstring"black"relation label color
relationLabelBgColorstring"lightblue"relation label background color
relationLabelBorderRadiusstring|number"0px"relation label border radius

Run Example

npm install
npm install react react-dom
npm run build
npm run example

Then, access http://localhost:8080/ in your browser.

If enable Server Mode, access http://localhost:8080/?server=yes.

Run Demo App

npm install
npm install react react-dom
npm run build
npm run demo

Then, access http://localhost:8080/ in your browser.

Dependencies

  • react
  • react-dom
  • css-element-queries
  • color

License

MIT

FAQs

Package last updated on 05 Jan 2017

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