New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nlptoolkit-dictionary

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nlptoolkit-dictionary - npm Package Compare versions

Comparing version 1.0.9 to 1.0.10

5

dist/Dictionary/VectorizedDictionary.d.ts

@@ -10,4 +10,5 @@ import { Dictionary } from "./Dictionary";

* @param comparator {@link WordComparator} type input.
* @param fileName Name of the file to be read
*/
constructor(comparator: WordComparator);
constructor(comparator: WordComparator, fileName?: string);
/**

@@ -45,3 +46,3 @@ * The addWord method takes a {@link VectorizedWord} as an input and adds it to the words {@link Array}.

* of type {@link VectorizedWord} and a {@link VectorizedWord} word by getting the given name from words {@link Array}.
* Then, it loops through the words {@link Array} and adds current word to the resultWords. It then sort resultWords {@link Array}
* Then, it loops through the words {@link Array} and adds current word to the resultWords. It then sorts resultWords {@link Array}
* and if the size of the {@link Array} is greater than given input k, it removes items from the ending. Then, it returns

@@ -48,0 +49,0 @@ * resultWords {@link Array}.

22

dist/Dictionary/VectorizedDictionary.js

@@ -7,3 +7,3 @@ (function (factory) {

else if (typeof define === "function" && define.amd) {
define(["require", "exports", "./Dictionary", "./VectorizedWord", "nlptoolkit-math/dist/Vector"], factory);
define(["require", "exports", "./Dictionary", "./VectorizedWord", "nlptoolkit-math/dist/Vector", "fs"], factory);
}

@@ -17,2 +17,3 @@ })(function (require, exports) {

const Vector_1 = require("nlptoolkit-math/dist/Vector");
const fs = require("fs");
class VectorizedDictionary extends Dictionary_1.Dictionary {

@@ -24,4 +25,5 @@ /**

* @param comparator {@link WordComparator} type input.
* @param fileName Name of the file to be read
*/
constructor(comparator) {
constructor(comparator, fileName = undefined) {
super(comparator);

@@ -41,2 +43,16 @@ /**

word.getVector().cosineSimilarity(a.getVector());
if (fileName != undefined) {
let data = fs.readFileSync(fileName, 'utf8');
let lines = data.split("\n");
for (let line of lines) {
let items = line.split(" ");
let vector = new Vector_1.Vector(0, 0);
for (let i = 1; i < items.length; i++) {
vector.add(parseFloat(items[i]));
}
let vectorizedWord = new VectorizedWord_1.VectorizedWord(items[0], vector);
this.words.push(vectorizedWord);
}
this.words.sort(this.wordComparator(this.comparator));
}
}

@@ -86,3 +102,3 @@ /**

* of type {@link VectorizedWord} and a {@link VectorizedWord} word by getting the given name from words {@link Array}.
* Then, it loops through the words {@link Array} and adds current word to the resultWords. It then sort resultWords {@link Array}
* Then, it loops through the words {@link Array} and adds current word to the resultWords. It then sorts resultWords {@link Array}
* and if the size of the {@link Array} is greater than given input k, it removes items from the ending. Then, it returns

@@ -89,0 +105,0 @@ * resultWords {@link Array}.

{
"name": "nlptoolkit-dictionary",
"version": "1.0.9",
"version": "1.0.10",
"description": "Turkish Dictionary",

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

@@ -5,2 +5,3 @@ import {Dictionary} from "./Dictionary";

import {Vector} from "nlptoolkit-math/dist/Vector";
import * as fs from "fs";

@@ -14,5 +15,20 @@ export class VectorizedDictionary extends Dictionary{

* @param comparator {@link WordComparator} type input.
* @param fileName Name of the file to be read
*/
constructor(comparator: WordComparator) {
constructor(comparator: WordComparator, fileName: string = undefined) {
super(comparator);
if (fileName != undefined){
let data = fs.readFileSync(fileName, 'utf8')
let lines = data.split("\n")
for (let line of lines){
let items = line.split(" ")
let vector = new Vector(0, 0)
for (let i = 1; i < items.length; i++){
vector.add(parseFloat(items[i]))
}
let vectorizedWord = new VectorizedWord(items[0], vector)
this.words.push(vectorizedWord)
}
this.words.sort(this.wordComparator(this.comparator))
}
}

@@ -80,3 +96,3 @@

* of type {@link VectorizedWord} and a {@link VectorizedWord} word by getting the given name from words {@link Array}.
* Then, it loops through the words {@link Array} and adds current word to the resultWords. It then sort resultWords {@link Array}
* Then, it loops through the words {@link Array} and adds current word to the resultWords. It then sorts resultWords {@link Array}
* and if the size of the {@link Array} is greater than given input k, it removes items from the ending. Then, it returns

@@ -83,0 +99,0 @@ * resultWords {@link Array}.

Sorry, the diff of this file is not supported yet

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