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

nlptoolkit-ngram

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nlptoolkit-ngram - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

5

dist/MultipleFile.d.ts
export declare class MultipleFile {
private fileIndex;
private lineIndex;
private fileNameList;
private lines;
private readonly fileNameList;
private contents;
constructor(...args: Array<any>);

@@ -7,0 +6,0 @@ readLine(): string;

19

dist/MultipleFile.js

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

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

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

exports.MultipleFile = void 0;
const fs = require("fs");
const FileContents_1 = require("nlptoolkit-util/dist/FileContents");
class MultipleFile {

@@ -20,18 +20,13 @@ constructor(...args) {

this.fileNameList = args;
let data = fs.readFileSync(args[this.fileIndex], 'utf8');
this.lines = data.split("\n");
this.lineIndex = 0;
this.contents = new FileContents_1.FileContents(args[this.fileIndex]);
}
readLine() {
if (this.lineIndex == this.lines.length) {
if (!this.contents.hasNextLine()) {
this.fileIndex++;
let data = fs.readFileSync(this.fileNameList[this.fileIndex], 'utf8');
this.lines = data.split("\n");
this.lineIndex = 0;
this.contents = new FileContents_1.FileContents(this.fileNameList[this.fileIndex]);
}
this.lineIndex++;
return this.lines[this.lineIndex - 1];
return this.contents.readLine();
}
hasNextLine() {
return this.fileIndex != this.fileNameList.length - 1 || this.lineIndex != this.lines.length - 1;
return this.fileIndex != this.fileNameList.length - 1 || this.contents.hasNextLine();
}

@@ -38,0 +33,0 @@ readCorpus() {

{
"name": "nlptoolkit-ngram",
"version": "1.0.2",
"version": "1.0.3",
"description": "NGram library",

@@ -30,4 +30,4 @@ "main": "index.js",

"nlptoolkit-sampling": "^1.0.2",
"nlptoolkit-util": "^1.0.5"
"nlptoolkit-util": "^1.0.9"
}
}

@@ -1,2 +0,2 @@

import * as fs from "fs";
import {FileContents} from "nlptoolkit-util/dist/FileContents";

@@ -6,5 +6,4 @@ export class MultipleFile {

private fileIndex: number
private lineIndex: number
private fileNameList: Array<string>
private lines: Array<string>
private readonly fileNameList: Array<string>
private contents: FileContents

@@ -14,20 +13,15 @@ constructor(... args: Array<any>) {

this.fileNameList = args
let data = fs.readFileSync(args[this.fileIndex], 'utf8')
this.lines = data.split("\n")
this.lineIndex = 0
this.contents = new FileContents(args[this.fileIndex])
}
readLine(): string{
if (this.lineIndex == this.lines.length){
if (!this.contents.hasNextLine()){
this.fileIndex++
let data = fs.readFileSync(this.fileNameList[this.fileIndex], 'utf8')
this.lines = data.split("\n")
this.lineIndex = 0
this.contents = new FileContents(this.fileNameList[this.fileIndex])
}
this.lineIndex++
return this.lines[this.lineIndex - 1]
return this.contents.readLine()
}
hasNextLine(): boolean {
return this.fileIndex != this.fileNameList.length - 1 || this.lineIndex != this.lines.length - 1
return this.fileIndex != this.fileNameList.length - 1 || this.contents.hasNextLine()
}

@@ -34,0 +28,0 @@

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