How to use the keyword-extractor.extract function in keyword-extractor

To help you get started, we’ve selected a few keyword-extractor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TessMyers / headline-parser / headline-parser.js View on Github external
var findKeywords = function( headline, body, n, keywordArgs ){
  keywordArgs = keywordArgs || { language:"english", return_changed_case:true };

  body = body.split(' ');

  // Extract keywords from headline. Returns an array
  keywordArray = extractor.extract( headline, keywordArgs );

  // if no N is given, set n to max length. // todo: just set to infinity?
  n = n || keywordArray.length;

  // Create object to track each mention of keyword in summary
  keywordCount = {};
  keywordArray.map(function(word){ keywordCount[word] = 0; });

  // Iterate over summary to count mentions of each keyword
  for ( var i = 0; i < body.length; i++ ) {
    for (word in keywordCount) {
      // console.log(word, body[i]);
      if (word === body[i]){
        keywordCount[word] += 1;
      }
    }
github synzen / Discord.RSS / src / web / client / src / js / constants / faq.js View on Github external
// First get the words
  // Question
  const keywords = item.q.split(' ').map(stemmer)
  for (const word of keywords) {
    if (!invertedIndexes[word]) {
      invertedIndexes[word] = []
      invertedIndexes[word][contentIndex] = [contentIndex, QUESTION_POINTS]
    } else if (!invertedIndexes[word][contentIndex]) {
      invertedIndexes[word][contentIndex] = [contentIndex, QUESTION_POINTS]
    } else {
      invertedIndexes[word][contentIndex][1] += QUESTION_POINTS
    }
  }

  // Answer
  const answerKeywords = keywordExtractor.extract(item.a, extractorOptions).map(stemmer)
  for (const word of answerKeywords) {
    if (!invertedIndexes[word]) {
      invertedIndexes[word] = []
      invertedIndexes[word][contentIndex] = [contentIndex, ANSWER_POINTS]
    } else if (!invertedIndexes[word][contentIndex]) {
      invertedIndexes[word][contentIndex] = [contentIndex, ANSWER_POINTS]
    } else {
      invertedIndexes[word][contentIndex][1] += ANSWER_POINTS
    }
  }

  // Tags. Give half points for each word if it's a multi-word tag
  const halfTags = []
  const tags = []
  item.t.forEach(item => {
    tags.push(stemmer(item))
github wingedfox / dgeni-alive / src / packages / search / processors / search-index.js View on Github external
}).map(function(v) {
        // for each document extract only certain properties
        var index = tokenizer.extract(
          ['events', 'properties', 'methods', 'name', 'codeName', 'renderedContent', 'docType'].map(function(k) {
            if ('string' === typeof v[k]) {
              // rendered content should be cleaned a bit
              return 'renderedContent' === k ? cleanText(v[k]) : v[k];
            } else if (v[k]) {
              var m = v[k];
              return [m.codeName || '',
                      m.name || '',
                      cleanText(m.renderedContent || ''),
                      m.alias || '',
                      m.eventTarget || '',
                      m.eventType || ''
              ].join(' ');
            } else {
              return '';
            }
github hack4impact-uiuc / life-after-hate / backend / routes / api / resources.js View on Github external
errorWrap(async (req, res) => {
    const data = req.body;
    const created_tags = extractor.extract(data.notes, {
      language: "english",
      remove_digits: true,
      return_changed_case: true,
      remove_duplicates: true
    });

    const latlng = await resourceUtils.addressToLatLong(data.address);

    data.location.coordinates[0] = latlng.lng;
    data.location.coordinates[1] = latlng.lat;
    data.federalRegion = latlng.region;

    const newResource = new Resource(data);
    newResource.tags = created_tags;
    await newResource.save();
github alexbruno / hexo-generator-json-content / index.js View on Github external
getKeywords = str => {
		return keywords.extract(str, {
			language: cfg.keywords,
			remove_digits: true,
			return_changed_case: true,
			remove_duplicates: true
		}).join(' ')
	},
	setContent = (obj, item, ref) => {
github alexbruno / hexo-generator-json-content / src / modules / utils.js View on Github external
export function getKeywords (str, language) {
  const keywords = extract(str, {
    language,
    remove_digits: true,
    return_changed_case: true,
    remove_duplicates: true
  })

  return keywords.join(' ')
}
github eiriklv / collectify / helpers / get-keywords-from-string.js View on Github external
exports = module.exports = function(text) {
  return (keywordExtractor.extract(text, keywordOptions) || []).slice(0, 5);
};

keyword-extractor

Module for creating a keyword array from a string and excluding stop words.

Unrecognized
Latest version published 1 year ago

Package Health Score

54 / 100
Full package analysis

Popular keyword-extractor functions