npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

diccionary

v1.0.3

Published

Some NLP util for neural network.

Downloads

4

Readme

Author

Install

Before installing it you need to install Node.js The install is executed using the npm install command:

$ npm install diccionary --save

Constructor

The constructor need one argument

  • lowercase: True or False (this just convert text to lowercase before adding it to the dictionary so hello and HeLlO will be the same word)

Properties

  • maxid:Max number assigned to a word
  • list:The full vocabulary with the words associated numbers
  • count:The full vocabulary with the times every word have been added
  • maxcount:The most added word

Methods

add

This function add words/sentences to the dictionary(if the word is already in the dictionary it will be counted)

remove

This function remove words/sentences of the dictionary

convert

This function convert words/sentences to numbers(the number is the associated number in the dictionary in case it isn't in the dictionary it will be a 0)

convertnormalized

This function use the already explained convert function but then it divide the number of every word with the max number on the dictionary so the numbers will be in the range 0-1

deconvert

This function deconvert numbers to words/sentences

deconvertnormalized

This function reverts the convertnormalized so from numbers in range 0-1 converts them to words

Example

const diccionaries = require('dictionary')
const dictionary = new diccionaries(true) //true => it will be lowercase
let exampletext = 'Nory was a Catholic because her mother was a Catholic, and Nory’s mother was a Catholic because her father was a Catholic, and her father was a Catholic because his mother was a Catholic, or had been.'
dictionary.add(exampletext) //In this case Nory and Nory's will be different words and this also applies to Catholic - Catholic,
console.log(dictionary.list)
/*
Console Output:
{
  nory: 1,
  was: 2,
  a: 3,
  catholic: 4,
  because: 5,
  her: 6,
  mother: 7,
  'catholic,': 8,
  and: 9,
  'nory’s': 10,
  father: 11,
  his: 12,
  or: 13,
  had: 14,
  'been.': 15
}
*/
console.log(dictionary.maxid) //Console Output:15
console.log(dictionary.count)
/*
Console Output:
{
  nory: 1,
  was: 6,
  a: 6,
  catholic: 3,
  because: 3,
  her: 3,
  mother: 3,
  'catholic,': 3,
  and: 2,
  'nory’s': 1,
  father: 2,
  his: 1,
  or: 1,
  had: 1,
  'been.': 1
}
*/
console.log(dictionary.maxcount)
/*
In this case its return "was" because its the first element in the list with the highest value
Console Output:{ word: 'was', counts: 6 }
*/

console.log(dictionary.convert(exampletext))
/*
Console Output:[
  1,  2, 3, 4,  5,  6,  7, 2,  3,  8,
  9, 10, 7, 2,  3,  4,  5, 6, 11,  2,
  3,  8, 9, 6, 11,  2,  3, 4,  5, 12,
  7,  2, 3, 8, 13, 14, 15
]
*/
console.log(dictionary.convertnormalized(exampletext))
/*
Console Output:[
  0.06666666666666667, 0.13333333333333333,
                  0.2, 0.26666666666666666,
   0.3333333333333333,                 0.4,
   0.4666666666666667, 0.13333333333333333,
                  0.2,  0.5333333333333333,
                  0.6,  0.6666666666666666,
   0.4666666666666667, 0.13333333333333333,
                  0.2, 0.26666666666666666,
   0.3333333333333333,                 0.4,
   0.7333333333333333, 0.13333333333333333,
                  0.2,  0.5333333333333333,
                  0.6,                 0.4,
   0.7333333333333333, 0.13333333333333333,
                  0.2, 0.26666666666666666,
   0.3333333333333333,                 0.8,
   0.4666666666666667, 0.13333333333333333,
                  0.2,  0.5333333333333333,
   0.8666666666666667,  0.9333333333333333,
                    1
]
*/

Created by: Discord Safe