wordmap
Version:
Multi-Lingual Word Alignment Prediction
50 lines (49 loc) • 1.49 kB
TypeScript
import Ngram from "./Ngram";
/**
* Represents two individual n-grams that have been matched from two texts.
* e.g. from a primary text and secondary text.
*/
export default class Alignment {
sourceNgram: Ngram;
targetNgram: Ngram;
private cachedKey;
private cachedLemmaKey;
/**
* Returns the n-gram from the source text.
* @deprecated Consider using {@link sourceNgram} instead since getters have a performance hit.
* @return {Ngram}
*/
readonly source: Ngram;
/**
* Returns the n-gram from the target text
* @deprecated Consider using {@link targetNgram} instead since getters have a performance hit.
* @return {Ngram}
*/
readonly target: Ngram;
/**
* Returns the alignment key.
* TODO: would a regular function be faster?
* @return {string}
*/
readonly key: string;
/**
* Returns the alignment lemma-based key
*/
readonly lemmaKey: string | undefined;
/**
* Instantiates a new alignment
* @param {Ngram} sourceNgram - an n-gram from the source text
* @param {Ngram} targetNgram - an n-gram from the secondary text
*/
constructor(sourceNgram: Ngram, targetNgram: Ngram);
/**
* Outputs the alignment to json
* @param verbose - print full metadata
* @return {object}
*/
toJSON(verbose?: boolean): object;
/**
* Caches the keys if they have not already been generated
*/
private cacheKeys;
}