Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ner-node

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ner-node - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

2

package.json
{
"name": "ner-node",
"version": "0.0.3",
"version": "0.0.4",
"description": "Node library for spawning NER server and pinging it to get entities out of raw text.",

@@ -5,0 +5,0 @@ "main": "SocketNER.js",

@@ -19,3 +19,3 @@ <h1>NER-Node</h2>

// A Sync function to get the Entities JSON
obj.getEntities(rawText, requiredEntity)
var entitiesJSON = obj.getEntities(rawText, requiredEntity)
// closes the server and socket when done

@@ -35,4 +35,4 @@ obj.close()

<h4>Donate</h4>
<p>If this repository helps you anyhow and you can want to contribute, then you can
<p>If this repository helps you anyhow, please don't mind coming back and
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=F3QQCWFPWHBYE" target="_blank">Buy Me Coffee</a>
</p>

@@ -56,43 +56,43 @@ var spawn = require("child_process").spawn

socketNER.getEntities = function (rawText, requiredEntity) {
// taking a copy of requiredEntity preference
requiredEntityG = requiredEntity
// replacing line breaks with spaces and adding two line breaks at the end
// for an unknown reason. May be, it relates to how a request should be sent through socket.
rawTextG = rawText.replace(/[\r\n\f\t\v]/g, " ") + "\n\n"
// Reconnecting on each getEntities function call, that's neccessary as the NER sever closes
// the socket after each such call.
socket.connect(port)
// deasync would won't halt the Event Loop ie. it would also next events to be met
// but at the same time, it won't exit this function untill jsonEntities comes back.
deasync.loopWhile(function () { return (jsonEntities.length !== 1) })
return jsonEntities.pop() // ** or jsonEntities.shift()
}
socketNER.getEntities = function (rawText, requiredEntity) {
// taking a copy of requiredEntity preference
requiredEntityG = requiredEntity
// replacing line breaks with spaces and adding two line breaks at the end
// for an unknown reason. May be, it relates to how a request should be sent through socket.
rawTextG = rawText.replace(/[\r\n\f\t\v]/g, " ") + "\n\n"
// Reconnecting on each getEntities function call, that's neccessary as the NER sever closes
// the socket after each such call.
socket.connect(port)
// deasync would won't halt the Event Loop ie. it would also next events to be met
// but at the same time, it won't exit this function untill jsonEntities comes back.
deasync.loopWhile(function () { return (jsonEntities.length !== 1) })
return jsonEntities.pop() // ** or jsonEntities.shift()
}
// Closes the socket and kills the server process
socketNER.close = function () {
socket.end()
server.kill()
}
// Closes the socket and kills the server process
socketNER.close = function () {
socket.end()
server.kill()
}
// Passing in 'the parser' to the socketNER return object,
// so that user could be able to define his own parser later on
socketNER.parser = function (taggedText, requiredEntity) {
var matches, entities = {} //return value of parser function
// Change the regex scope according to user's Entitry requirements
// Please always pass the requiredEntity in Upper case as NER uses upper cased Tags
var re = requiredEntity ? new RegExp(["<(",requiredEntity,"?)>(.*?)<\/",requiredEntity,"?>"].join(""), "g")
: /<([A-Z]+?)>(.*?)<\/[A-Z]+?>/g
while((matches = re.exec(taggedText)) !== null) {
if (entities[matches[1]]) {
// if tagName is present, then pushing in the tagValue Array
entities[matches[1]].push(matches[2])
}
else {
// otherwise adding the tagName with a new tagValue Array
entities[matches[1]] = [matches[2]]
}
// Passing in 'the parser' to the socketNER return object,
// so that user could be able to define his own parser later on
socketNER.parser = function (taggedText, requiredEntity) {
var matches, entities = {} //return value of parser function
// Change the regex scope according to user's Entitry requirements
// Please always pass the requiredEntity in Upper case as NER uses upper cased Tags
var re = requiredEntity ? new RegExp(["<(",requiredEntity,"?)>(.*?)<\/",requiredEntity,"?>"].join(""), "g")
: /<([A-Z]+?)>(.*?)<\/[A-Z]+?>/g
while((matches = re.exec(taggedText)) !== null) {
if (entities[matches[1]]) {
// if tagName is present, then pushing in the tagValue Array
entities[matches[1]].push(matches[2])
}
return entities
else {
// otherwise adding the tagName with a new tagValue Array
entities[matches[1]] = [matches[2]]
}
}
return entities
}

@@ -99,0 +99,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc