nlptoolkit-util 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  For Developers
2
2
  ============
3
3
  You can also see [Cython](https://github.com/starlangsoftware/Util-Cy), [Java](https://github.com/starlangsoftware/Util),
4
- [C++](https://github.com/starlangsoftware/Util-CPP), [Swift](https://github.com/starlangsoftware/Util-Swift),
5
- [Python](https://github.com/starlangsoftware/Util-Py), or [C#](https://github.com/starlangsoftware/Util-CS) repository.
4
+ [C++](https://github.com/starlangsoftware/Util-CPP), [Swift](https://github.com/starlangsoftware/Util-Swift), [C](https://github.com/starlangsoftware/Util-C), [Python](https://github.com/starlangsoftware/Util-Py), or [C#](https://github.com/starlangsoftware/Util-CS) repository.
6
5
 
7
6
  ## Requirements
8
7
 
@@ -0,0 +1,6 @@
1
+ export declare class FileContents {
2
+ private readonly contents;
3
+ private filePointer;
4
+ constructor(fileName: string);
5
+ readLine(): string;
6
+ }
@@ -0,0 +1,32 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports", "fs"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.FileContents = void 0;
13
+ var fs = require("fs");
14
+ var FileContents = /** @class */ (function () {
15
+ function FileContents(fileName) {
16
+ var data = fs.readFileSync(fileName, 'utf8');
17
+ this.contents = data.split("\n");
18
+ this.filePointer = 0;
19
+ }
20
+ FileContents.prototype.readLine = function () {
21
+ if (this.filePointer < this.contents.length) {
22
+ var s = this.contents[this.filePointer];
23
+ this.filePointer++;
24
+ return s;
25
+ }
26
+ return "";
27
+ };
28
+ return FileContents;
29
+ }());
30
+ exports.FileContents = FileContents;
31
+ });
32
+ //# sourceMappingURL=FileContents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileContents.js","sourceRoot":"","sources":["../source/FileContents.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,uBAAyB;IAEzB;QAKI,sBAAY,QAAgB;YACxB,IAAI,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;YAC5C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YAChC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAA;QACxB,CAAC;QAED,+BAAQ,GAAR;YACI,IAAI,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAC;gBACxC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;gBACvC,IAAI,CAAC,WAAW,EAAE,CAAA;gBAClB,OAAO,CAAC,CAAA;aACX;YACD,OAAO,EAAE,CAAA;QACb,CAAC;QACL,mBAAC;IAAD,CAAC,AAnBD,IAmBC;IAnBY,oCAAY"}
package/dist/Random.js CHANGED
@@ -18,7 +18,7 @@
18
18
  }
19
19
  }
20
20
  Random.prototype.nextRandom = function () {
21
- this.seed = (1664525 * this.seed + 1013904223) % 2147483647;
21
+ this.seed = (1664525 * this.seed + 1013904223) % Number.MAX_SAFE_INTEGER;
22
22
  };
23
23
  Random.prototype.nextDouble = function (min, max) {
24
24
  this.nextRandom();
@@ -1 +1 @@
1
- {"version":3,"file":"Random.js","sourceRoot":"","sources":["../source/Random.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA;QAII,gBAAY,IAAa;YAFjB,SAAI,GAAW,CAAC,CAAA;YAGpB,IAAI,IAAI,IAAI,SAAS,EAAC;gBAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;aACnB;QACL,CAAC;QAEO,2BAAU,GAAlB;YACI,IAAI,CAAC,IAAI,GA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,CAAC;QAEO,2BAAU,GAAlB;YACI,IAAI,CAAC,IAAI,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,GAAG,MAAM,CAAC,gBAAgB,CAAC;QAC7E,CAAC;QAED,2BAAU,GAAV,UAAW,GAAY,EAAE,GAAY;YACjC,IAAI,CAAC,UAAU,EAAE,CAAA;YACjB,IAAI,GAAG,IAAI,SAAS,IAAI,GAAG,IAAI,SAAS,EAAC;gBACrC,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAA;aACnE;YACD,OAAO,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,gBAAgB,CAAC;QAC/C,CAAC;QAED,wBAAO,GAAP,UAAQ,QAAgB;YACpB,IAAI,CAAC,UAAU,EAAE,CAAA;YACjB,OAAO,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;QAChC,CAAC;QAED,wBAAO,GAAP,UAAQ,KAAiB;;YACrB,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAC;gBACtC,IAAI,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;gBACtC,KACI,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EADjC,KAAK,CAAC,CAAC,CAAC,QAAA,EAAE,KAAK,CAAC,WAAW,CAAC,QAAA,CACM;aACtC;QACL,CAAC;QACL,aAAC;IAAD,CAAC,AAlCD,IAkCC;IAlCY,wBAAM"}
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export * from "./dist/Interval"
2
2
  export * from "./dist/Permutation"
3
- export * from "./dist/RandomNormalizedArray"
4
3
  export * from "./dist/Subset"
5
4
  export * from "./dist/SubsetFromList"
6
5
  export * from "./dist/Tuple"
7
6
  export * from "./dist/Random"
7
+ export * from "./dist/FileContents"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nlptoolkit-util",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Simple Utils Library",
5
5
  "main": "index.js",
6
6
  "types": "index.js",
@@ -0,0 +1,22 @@
1
+ import * as fs from "fs";
2
+
3
+ export class FileContents {
4
+
5
+ private readonly contents: string[]
6
+ private filePointer: number
7
+
8
+ constructor(fileName: string) {
9
+ let data = fs.readFileSync(fileName, 'utf8')
10
+ this.contents = data.split("\n")
11
+ this.filePointer = 0
12
+ }
13
+
14
+ readLine(): string{
15
+ if (this.filePointer < this.contents.length){
16
+ let s = this.contents[this.filePointer]
17
+ this.filePointer++
18
+ return s
19
+ }
20
+ return ""
21
+ }
22
+ }
package/source/Random.ts CHANGED
@@ -9,7 +9,7 @@ export class Random {
9
9
  }
10
10
 
11
11
  private nextRandom(){
12
- this.seed = (1664525 * this.seed + 1013904223) % 2147483647
12
+ this.seed = (1664525 * this.seed + 1013904223) % Number.MAX_SAFE_INTEGER;
13
13
  }
14
14
 
15
15
  nextDouble(min?: number, max?: number): number{
@@ -1,25 +0,0 @@
1
- import {Random} from "../dist/Random";
2
- import * as assert from "assert";
3
-
4
- describe('RandomTest', function() {
5
- describe('nextIntTest', function () {
6
- it('nextIntTest', function () {
7
- let random = new Random(0);
8
- assert.equal(3, random.nextInt(10));
9
- assert.equal(98, random.nextInt(100));
10
- assert.equal(528, random.nextInt(1000));
11
- assert.equal(7607, random.nextInt(10000));
12
- assert.equal(48324, random.nextInt(100000));
13
- });
14
- });
15
- describe('nextDoubleTest', function () {
16
- it('nextDoubleTest', function () {
17
- let random = new Random(0);
18
- assert.equal(1.1256598131392793e-7, random.nextDouble(1));
19
- assert.equal(0.18736900261254721, random.nextDouble(1));
20
- assert.equal(0.3890737627280681, random.nextDouble(1));
21
- assert.equal(0.004905050110260657, random.nextDouble(1));
22
- assert.equal(0.5785348941853924, random.nextDouble(1));
23
- });
24
- });
25
- });