nlptoolkit-ngram
Advanced tools
Comparing version 1.0.2 to 1.0.3
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; |
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
6841246
3584
Updatednlptoolkit-util@^1.0.9