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

daq-proc

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

daq-proc - npm Package Compare versions

Comparing version 5.0.4 to 5.0.5

63

demo/document-processing/document-processor-app.js

@@ -18,2 +18,7 @@ // exposing the underlying libraries in a transparent way

}
// declaring some variables
let emojiString
let headlineStopped
let bodyStopped
let emojiArray

@@ -23,8 +28,11 @@ // document and query processing

// Extract array of words and populate
let headlineString = document.getElementById('headlinetext').value
let bodyString = document.getElementById("bodytext").value
let emojiString = headlineString.concat(' ', bodyString)
let headlineArray = wnn.extract(headlineString, { regex: wnn.wordsNumbers, toLowercase: true })
let bodyArray = wnn.extract(bodyString, { regex: wnn.wordsNumbers, toLowercase: true })
let emojiArray = wnn.extract(emojiString, { regex: wnn.emojis })
const headlineString = document.getElementById('headlinetext').value
const bodyString = document.getElementById('bodytext').value
if (headlineString.length > 0 || bodyString.length > 0) {
emojiString = headlineString.concat(' ', bodyString)
}
const headlineArray = wnn.extract(headlineString, { regex: wnn.wordsNumbers, toLowercase: true })
const bodyArray = wnn.extract(bodyString, { regex: wnn.wordsNumbers, toLowercase: true })
emojiArray = wnn.extract(emojiString, { regex: wnn.emojis })
populate(JSON.stringify(headlineArray, 2, ' '), 'headlineArrDiv')

@@ -35,24 +43,39 @@ populate(JSON.stringify(bodyArray, 2, ' '), 'bodyArrDiv')

const languages = { af: sw.af, ar: sw.ar, bg: sw.bg, bn: sw.bn, br: sw.br, ca: sw.ca, cs: sw.cs, da: sw.da, de: sw.de, el: sw.el, en: sw.en, eo: sw.eo, es: sw.es, et: sw.et, eu: sw.eu, fa: sw.fa, fi: sw.fi, fr: sw.fr, ga: sw.ga, gl: sw.gl, ha: sw.ha, he: sw.he, hi: sw.hi, hr: sw.hr, hu: sw.hu, hy: sw.hy, id: sw.id, it: sw.it, ja: sw.ja, ko: sw.ko, la: sw.la, lgg: sw.lgg, lggo: sw.lggo, lv: sw.lv, mr: sw.mr, nl: sw.nl, no: sw.no, pl: sw.pl, pt: sw.pt, ptbr: sw.ptbr, pa: sw.pa, ro: sw.ro, ru: sw.ru, sk: sw.sk, sl: sw.sl, so: sw.so, st: sw.st, sv: sw.sv, sw: sw.sw, th: sw.th, tr: sw.tr, vi: sw.vi, yo: sw.yo, zh: sw.zh, zu: sw.zu }
let code = document.getElementById("languageSelected").value || en
const code = document.getElementById('languageSelected').value
console.log(code)
// Removing stopwords
let headlineStopped = sw.removeStopwords(headlineArray, languages[code])
populate(JSON.stringify(headlineStopped, 2, ' '), 'headlineStoppedDiv')
let bodyStopped = sw.removeStopwords(bodyArray, languages[code])
populate(JSON.stringify(bodyStopped, 2, ' '), 'bodyStoppedDiv')
if (headlineArray !== null) {
headlineStopped = sw.removeStopwords(headlineArray, languages[code])
populate(JSON.stringify(headlineStopped, 2, ' '), 'headlineStoppedDiv')
}
if (bodyArray !== null) {
bodyStopped = sw.removeStopwords(bodyArray, languages[code])
populate(JSON.stringify(bodyStopped, 2, ' '), 'bodyStoppedDiv')
}
// Ngramming
let headlineNgrams = ngraminator(headlineStopped, [2,3,4])
populate(JSON.stringify(headlineNgrams, 2, ' '), 'headlineNgramifiedDiv')
let bodyNgrams = ngraminator(bodyStopped, [2,3,4])
populate(JSON.stringify(bodyNgrams, 2, ' '), 'bodyNgramifiedDiv')
if (headlineStopped !== null || headlineStopped.length > 0) {
const headlineNgrams = ngraminator(headlineStopped, [1, 2, 3, 4])
populate(JSON.stringify(headlineNgrams, 2, ' '), 'headlineNgramifiedDiv')
}
if (bodyStopped !== null || bodyStopped.length > 0) {
const bodyNgrams = ngraminator(bodyStopped, [1, 2, 3, 4])
populate(JSON.stringify(bodyNgrams, 2, ' '), 'bodyNgramifiedDiv')
}
// Calculating keywords
let keywords = ehp.findKeywords(headlineStopped, bodyStopped, 5)
populate(JSON.stringify(keywords, 2, ' '), 'keywordsFoundDiv')
if (headlineStopped.length > 0 || bodyStopped.length > 0) {
const keywords = ehp.findKeywords(headlineStopped, bodyStopped, 5)
populate(JSON.stringify(keywords, 2, ' '), 'keywordsFoundDiv')
}
// Emoji population
emojiArray = emojiArray.join('')
emojiArray = [...new Set(emojiArray)]
populate(JSON.stringify(emojiArray, 2, ' '), 'emojisFoundDiv')
if (emojiArray !== null && emojiArray.length > 0) {
emojiArray = emojiArray.join('')
emojiArray = [...new Set(emojiArray)]
populate(JSON.stringify(emojiArray, 2, ' '), 'emojisFoundDiv')
}
}

@@ -59,0 +82,0 @@

{
"name": "daq-proc",
"version": "5.0.4",
"version": "5.0.5",
"description": "Simple document processor to make search running in the browser and node.js a little better. Supports 50+ languages. Removes stopwords (smaller index and less irrelevant hits), extract keywords to filter on and prepares ngrams for auto-complete functionality.",

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

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