Socket
Socket
Sign inDemoInstall

retext-keywords

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

retext-keywords - npm Package Compare versions

Comparing version 4.0.0 to 4.0.1

7

index.js
'use strict';
var has = require('has');
var stemmer = require('stemmer');

@@ -11,2 +10,4 @@ var visit = require('unist-util-visit');

var own = {}.hasOwnProperty;
function keywords(options) {

@@ -95,3 +96,3 @@ this.use(pos).use(gatherKeywords, options);

* phrase somewhere. */
if (has(stemmedPhrases, phrase.value)) {
if (own.call(stemmedPhrases, phrase.value)) {
/* Add weight per phrase to the score of

@@ -239,3 +240,3 @@ * the phrase. */

if (!has(words, stem)) {
if (!own.call(words, stem)) {
words[stem] = {

@@ -242,0 +243,0 @@ matches: [match],

{
"name": "retext-keywords",
"version": "4.0.0",
"version": "4.0.1",
"description": "Keyword extraction with Retext",

@@ -14,3 +14,3 @@ "license": "MIT",

],
"repository": "https://github.com/wooorm/retext-keywords",
"repository": "wooorm/retext-keywords",
"bugs": "https://github.com/wooorm/retext-keywords/issues",

@@ -26,3 +26,2 @@ "author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",

"dependencies": {
"has": "^1.0.1",
"nlcst-to-string": "^2.0.0",

@@ -35,12 +34,12 @@ "retext-pos": "^2.0.0",

"browserify": "^14.1.0",
"esmangle": "^1.0.1",
"nyc": "^10.0.0",
"remark-cli": "^3.0.0",
"remark-preset-wooorm": "^2.0.0",
"esmangle": "^1.0.0",
"nyc": "^11.0.0",
"remark-cli": "^4.0.0",
"remark-preset-wooorm": "^3.0.0",
"retext": "^5.0.0",
"tape": "^4.0.0",
"xo": "^0.17.1"
"xo": "^0.18.0"
},
"scripts": {
"build-md": "remark . --quiet --frail",
"build-md": "remark . -qfo",
"build-bundle": "browserify index.js --ignore-missing --bare -s retextKeywords > retext-keywords.js",

@@ -50,3 +49,3 @@ "build-mangle": "esmangle retext-keywords.js > retext-keywords.min.js",

"lint": "xo",
"test-api": "node test.js",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",

@@ -63,2 +62,3 @@ "test": "npm run build && npm run lint && npm run test-coverage"

"space": true,
"esnext": false,
"rules": {

@@ -65,0 +65,0 @@ "no-negated-condition": "off",

@@ -15,48 +15,29 @@ # retext-keywords [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]

Say we have the following file, `example.txt`, with the first three paragraphs
on [Term Extraction][term-extraction] from Wikipedia:
```text
Terminology mining, term extraction, term recognition, or glossary extraction, is a subtask of information extraction. The goal of terminology extraction is to automatically extract relevant terms from a given corpus.
In the semantic web era, a growing number of communities and networked enterprises started to access and interoperate through the internet. Modeling these communities and their information needs is important for several web applications, like topic-driven web crawlers, web services, recommender systems, etc. The development of terminology extraction is essential to the language industry.
One of the first steps to model the knowledge domain of a virtual community is to collect a vocabulary of domain-relevant terms, constituting the linguistic surface manifestation of domain concepts. Several methods to automatically extract technical terms from domain-specific document warehouses have been described in the literature.
Typically, approaches to automatic term extraction make use of linguistic processors (part of speech tagging, phrase chunking) to extract terminological candidates, i.e. syntactically plausible terminological noun phrases, NPs (e.g. compounds "credit card", adjective-NPs "local tourist information office", and prepositional-NPs "board of directors" - in English, the first two constructs are the most frequent). Terminological entries are then filtered from the candidate list using statistical and machine learning methods. Once filtered, because of their low ambiguity and high specificity, these terms are particularly useful for conceptualizing a knowledge domain or for supporting the creation of a domain ontology. Furthermore, terminology extraction is a very useful starting point for semantic similarity, knowledge management, human translation and machine translation, etc.
```
And our script, `example.js`, looks as follows:
```javascript
var vfile = require('to-vfile');
var retext = require('retext');
var keywords = require('retext-keywords');
var nlcstToString = require('nlcst-to-string');
var keywords = require('retext-keywords');
retext().use(keywords).process(
/* First three paragraphs on Term Extraction from Wikipedia:
* http://en.wikipedia.org/wiki/Terminology_extraction */
'Terminology mining, term extraction, term recognition, or ' +
'glossary extraction, is a subtask of information extraction. ' +
'The goal of terminology extraction is to automatically extract ' +
'relevant terms from a given corpus.' +
'\n\n' +
'In the semantic web era, a growing number of communities and ' +
'networked enterprises started to access and interoperate through ' +
'the internet. Modeling these communities and their information ' +
'needs is important for several web applications, like ' +
'topic-driven web crawlers, web services, recommender systems, ' +
'etc. The development of terminology extraction is essential to ' +
'the language industry.' +
'\n\n' +
'One of the first steps to model the knowledge domain of a ' +
'virtual community is to collect a vocabulary of domain-relevant ' +
'terms, constituting the linguistic surface manifestation of ' +
'domain concepts. Several methods to automatically extract ' +
'technical terms from domain-specific document warehouses have ' +
'been described in the literature.' +
'\n\n' +
'Typically, approaches to automatic term extraction make use of ' +
'linguistic processors (part of speech tagging, phrase chunking) ' +
'to extract terminological candidates, i.e. syntactically ' +
'plausible terminological noun phrases, NPs (e.g. compounds ' +
'"credit card", adjective-NPs "local tourist information office", ' +
'and prepositional-NPs "board of directors" - in English, the ' +
'first two constructs are the most frequent). Terminological ' +
'entries are then filtered from the candidate list using ' +
'statistical and machine learning methods. Once filtered, ' +
'because of their low ambiguity and high specificity, these terms ' +
'are particularly useful for conceptualizing a knowledge domain ' +
'or for supporting the creation of a domain ontology. Furthermore, ' +
'terminology extraction is a very useful starting point for ' +
'semantic similarity, knowledge management, human translation ' +
'and machine translation, etc.',
function (err, file) {
retext()
.use(keywords)
.process(vfile.readSync('example.txt'), function (err, file) {
if (err) throw err;
console.log('Keywords:');
file.data.keywords.forEach(function (keyword) {

@@ -68,3 +49,2 @@ console.log(nlcstToString(keyword.matches[0].node));

console.log('Key-phrases:');
file.data.keyphrases.forEach(function (phrase) {

@@ -77,3 +57,3 @@ console.log(phrase.matches[0].nodes.map(nlcstToString).join(''));

Yields:
Now, running `node example` yields:

@@ -164,1 +144,3 @@ ```text

[retext]: https://github.com/wooorm/retext
[term-extraction]: http://en.wikipedia.org/wiki/Terminology_extraction
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