Socket
Socket
Sign inDemoInstall

@agtabesh/keyword-extractor

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @agtabesh/keyword-extractor

A package to extract important keywords from a document using TF-IDF technique


Version published
Weekly downloads
8
Maintainers
1
Install size
29.7 kB
Created
Weekly downloads
 

Readme

Source

@agtabesh/keyword-extractor

npm (scoped)

npm (scoped)

TF-IDF is a statistical measure used to evaluate how important a word is to a document in a collection or corpus. This package uses TF-IDF to extract important keywords from a document.

Install

$ npm install @agtabesh/keyword-extractor --save

Usage

const { EnglishTokenizer, KeywordExtractor } = require("@agtabesh/keyword-extractor")
const documents = [
  'Austria will press ahead with a proposed tax on internet giants after plans for an European Union-wide levy fell through this week, Finance Minister Hartwig Loeger said on Friday.',
  'Facebook Inc said on Friday it would use artificial intelligence to combat the spread of intimate photos shared without peoples permission, sometimes called "revenge porn," on its social networks.',
  'Tesla Inc unveiled its Model Y electric sports utility vehicle on Thursday evening in California, promising a much-awaited crossover that will face competition from European car makers rolling out their own electric rivals.'
]

const tokenizer = new EnglishTokenizer()
const keywordExtractor = new KeywordExtractor()
keywordExtractor.setTokenizer(tokenizer)

documents.forEach((text, i) => {
  keywordExtractor.addDocument(i, text)
})

const randomDocument = documents[Math.floor(Math.random() * documents.length)]
const keywords = keywordExtractor.extractKeywords(randomDocument, {
  sortByScore: true,
  limit: 10
})

console.log(keywords)

All contributions are welcome.

Keywords

FAQs

Last updated on 15 Mar 2019

Did you know?

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc