nlptoolkit-dictionary
Advanced tools
Comparing version 1.0.11 to 1.0.12
@@ -15,2 +15,8 @@ import { Word } from "./Word"; | ||
wordComparator: (comparator: WordComparator) => (word1: Word, word2: Word) => number; | ||
/** | ||
* Checks if a given word exists in the dictionary by performing a binary search on the words array. | ||
* @param word Searched word | ||
* @return the index of the search word, if it is contained in the words array; otherwise, (-(insertion point) - 1). The | ||
* insertion point is defined as the point at which the word would be inserted into the words array. | ||
*/ | ||
binarySearch(word: Word): number; | ||
@@ -17,0 +23,0 @@ /** |
@@ -31,2 +31,8 @@ (function (factory) { | ||
} | ||
/** | ||
* Checks if a given word exists in the dictionary by performing a binary search on the words array. | ||
* @param word Searched word | ||
* @return the index of the search word, if it is contained in the words array; otherwise, (-(insertion point) - 1). The | ||
* insertion point is defined as the point at which the word would be inserted into the words array. | ||
*/ | ||
binarySearch(word) { | ||
@@ -33,0 +39,0 @@ let lo = 0; |
import { Word } from "../Word"; | ||
import { TxtWord } from "../TxtWord"; | ||
export declare class Trie { | ||
private rootNode; | ||
private readonly rootNode; | ||
/** | ||
@@ -6,0 +6,0 @@ * A constructor of {@link Trie} class which creates a new {@link TrieNode} as rootNode. |
@@ -33,2 +33,8 @@ import { WordComparator } from "./WordComparator"; | ||
private loadMisspelledWords; | ||
/** | ||
* Loads the morphological lexicon of a given language. Only Turkish is currently supported. Morphological lexicon | ||
* contains subwords (possibly meaningful words or metamorphemes) of each root word in the Turkish dictionary. For | ||
* example, abacılık has subwords aba+CH+LHK. | ||
* @param fileName Morphological lexicon file | ||
*/ | ||
private loadMorphologicalLexicon; | ||
@@ -35,0 +41,0 @@ /** |
@@ -7,3 +7,3 @@ (function (factory) { | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "./WordComparator", "./Dictionary", "fs", "./TxtWord", "./Trie/Trie"], factory); | ||
define(["require", "exports", "./WordComparator", "./Dictionary", "fs", "./TxtWord", "./Trie/Trie", "nlptoolkit-util/dist/FileUtils"], factory); | ||
} | ||
@@ -19,2 +19,3 @@ })(function (require, exports) { | ||
const Trie_1 = require("./Trie/Trie"); | ||
const FileUtils_1 = require("nlptoolkit-util/dist/FileUtils"); | ||
class TxtDictionary extends Dictionary_1.Dictionary { | ||
@@ -68,11 +69,10 @@ /** | ||
loadMisspelledWords(fileName) { | ||
let data = fs.readFileSync(fileName, 'utf8'); | ||
let lines = data.split("\n"); | ||
for (let line of lines) { | ||
let list = line.split(" "); | ||
if (list.length == 2) { | ||
this.misspelledWords.set(list[0], list[1]); | ||
} | ||
} | ||
this.misspelledWords = FileUtils_1.FileUtils.readHashMap(fileName); | ||
} | ||
/** | ||
* Loads the morphological lexicon of a given language. Only Turkish is currently supported. Morphological lexicon | ||
* contains subwords (possibly meaningful words or metamorphemes) of each root word in the Turkish dictionary. For | ||
* example, abacılık has subwords aba+CH+LHK. | ||
* @param fileName Morphological lexicon file | ||
*/ | ||
loadMorphologicalLexicon(fileName) { | ||
@@ -79,0 +79,0 @@ let data = fs.readFileSync(fileName, 'utf8'); |
@@ -13,2 +13,5 @@ import { Word } from "./Word"; | ||
constructor(name: string, flag?: string); | ||
/** | ||
* Clone method that creates a copy of the current TxtWord. Clones the flags array and name property | ||
*/ | ||
clone(): TxtWord; | ||
@@ -27,3 +30,11 @@ /** | ||
removeFlag(flag: string): void; | ||
/** | ||
* Mutator for the inner morphology of the word. | ||
* @param morphology New inner morphology of the word. | ||
*/ | ||
setMorphology(morphology: string): void; | ||
/** | ||
* Accessor for the inner morphology of the word. | ||
* @return Inner morphology of the word. | ||
*/ | ||
getMorphology(): string; | ||
@@ -30,0 +41,0 @@ /** |
@@ -29,2 +29,5 @@ (function (factory) { | ||
} | ||
/** | ||
* Clone method that creates a copy of the current TxtWord. Clones the flags array and name property | ||
*/ | ||
clone() { | ||
@@ -53,5 +56,13 @@ let copy = new TxtWord(this.name); | ||
} | ||
/** | ||
* Mutator for the inner morphology of the word. | ||
* @param morphology New inner morphology of the word. | ||
*/ | ||
setMorphology(morphology) { | ||
this.morphology = morphology; | ||
} | ||
/** | ||
* Accessor for the inner morphology of the word. | ||
* @return Inner morphology of the word. | ||
*/ | ||
getMorphology() { | ||
@@ -58,0 +69,0 @@ return this.morphology; |
import { Vector } from "nlptoolkit-math/dist/Vector"; | ||
import { Word } from "./Word"; | ||
export declare class VectorizedWord extends Word { | ||
private vector; | ||
private readonly vector; | ||
/** | ||
@@ -6,0 +6,0 @@ * A constructor of {@link VectorizedWord} class which takes a String and a {@link Vector} as inputs and calls its |
@@ -100,2 +100,7 @@ export declare class Word { | ||
static isMoney(surfaceForm: string): boolean; | ||
/** | ||
* Converts the given string into its capital form | ||
* @param surfaceForm Given string which will be converted to its capital form | ||
* @return Capitalized form of the input string. | ||
*/ | ||
static toCapital(surfaceForm: string): string; | ||
@@ -102,0 +107,0 @@ /** |
@@ -182,2 +182,7 @@ (function (factory) { | ||
} | ||
/** | ||
* Converts the given string into its capital form | ||
* @param surfaceForm Given string which will be converted to its capital form | ||
* @return Capitalized form of the input string. | ||
*/ | ||
static toCapital(surfaceForm) { | ||
@@ -184,0 +189,0 @@ return surfaceForm.substring(0, 1).toLocaleUpperCase("tr") + surfaceForm.substring(1); |
{ | ||
"name": "nlptoolkit-dictionary", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"description": "Turkish Dictionary", | ||
@@ -28,4 +28,4 @@ "main": "index.js", | ||
"nlptoolkit-math": "^1.0.2", | ||
"nlptoolkit-util": "^1.0.5" | ||
"nlptoolkit-util": "^1.0.10" | ||
} | ||
} |
@@ -43,3 +43,3 @@ Turkish Dictionary | ||
You can also see [Python](https://github.com/starlangsoftware/Dictionary-Py), [Cython](https://github.com/starlangsoftware/Dictionary-Cy), | ||
[C++](https://github.com/starlangsoftware/Dictionary-CPP), [Swift](https://github.com/starlangsoftware/Dictionary-Swift), | ||
[C++](https://github.com/starlangsoftware/Dictionary-CPP), [C](https://github.com/starlangsoftware/Dictionary-C), [Swift](https://github.com/starlangsoftware/Dictionary-Swift), | ||
[Java](https://github.com/starlangsoftware/Dictionary), or [C#](https://github.com/starlangsoftware/Dictionary-CS) repository. | ||
@@ -46,0 +46,0 @@ |
@@ -27,2 +27,9 @@ import {Word} from "./Word"; | ||
/** | ||
* Checks if a given word exists in the dictionary by performing a binary search on the words array. | ||
* @param word Searched word | ||
* @return the index of the search word, if it is contained in the words array; otherwise, (-(insertion point) - 1). The | ||
* insertion point is defined as the point at which the word would be inserted into the words array. | ||
*/ | ||
binarySearch(word: Word): number{ | ||
@@ -29,0 +36,0 @@ let lo = 0 |
@@ -7,3 +7,3 @@ import {TrieNode} from "./TrieNode"; | ||
private rootNode: TrieNode | ||
private readonly rootNode: TrieNode | ||
@@ -10,0 +10,0 @@ /** |
@@ -6,2 +6,3 @@ import {WordComparator} from "./WordComparator"; | ||
import {Trie} from "./Trie/Trie"; | ||
import {FileUtils} from "nlptoolkit-util/dist/FileUtils" | ||
@@ -63,12 +64,11 @@ export class TxtDictionary extends Dictionary{ | ||
private loadMisspelledWords(fileName: string){ | ||
let data = fs.readFileSync(fileName, 'utf8') | ||
let lines = data.split("\n") | ||
for (let line of lines){ | ||
let list = line.split(" ") | ||
if (list.length == 2){ | ||
this.misspelledWords.set(list[0], list[1]) | ||
} | ||
} | ||
this.misspelledWords = FileUtils.readHashMap(fileName) | ||
} | ||
/** | ||
* Loads the morphological lexicon of a given language. Only Turkish is currently supported. Morphological lexicon | ||
* contains subwords (possibly meaningful words or metamorphemes) of each root word in the Turkish dictionary. For | ||
* example, abacılık has subwords aba+CH+LHK. | ||
* @param fileName Morphological lexicon file | ||
*/ | ||
private loadMorphologicalLexicon(fileName: string){ | ||
@@ -75,0 +75,0 @@ let data = fs.readFileSync(fileName, 'utf8') |
@@ -22,2 +22,5 @@ import {Word} from "./Word"; | ||
/** | ||
* Clone method that creates a copy of the current TxtWord. Clones the flags array and name property | ||
*/ | ||
clone(): TxtWord{ | ||
@@ -49,2 +52,6 @@ let copy = new TxtWord(this.name); | ||
/** | ||
* Mutator for the inner morphology of the word. | ||
* @param morphology New inner morphology of the word. | ||
*/ | ||
setMorphology(morphology: string){ | ||
@@ -54,2 +61,6 @@ this.morphology = morphology | ||
/** | ||
* Accessor for the inner morphology of the word. | ||
* @return Inner morphology of the word. | ||
*/ | ||
getMorphology(): string{ | ||
@@ -56,0 +67,0 @@ return this.morphology |
@@ -6,3 +6,3 @@ import {Vector} from "nlptoolkit-math/dist/Vector"; | ||
private vector: Vector | ||
private readonly vector: Vector | ||
@@ -9,0 +9,0 @@ /** |
@@ -186,2 +186,7 @@ import {TurkishLanguage} from "../Language/TurkishLanguage"; | ||
/** | ||
* Converts the given string into its capital form | ||
* @param surfaceForm Given string which will be converted to its capital form | ||
* @return Capitalized form of the input string. | ||
*/ | ||
static toCapital(surfaceForm: string): string{ | ||
@@ -188,0 +193,0 @@ return surfaceForm.substring(0, 1).toLocaleUpperCase("tr") + surfaceForm.substring(1) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
5929787
6446
Updatednlptoolkit-util@^1.0.10