wordmap
Version:
Multi-Lingual Word Alignment Prediction
96 lines (95 loc) • 3.54 kB
TypeScript
import { Token } from "wordmap-lexer";
import Algorithm from "../Algorithm";
import AlignmentMemoryIndex from "../index/AlignmentMemoryIndex";
import CorpusIndex from "../index/CorpusIndex";
import Alignment from "../structures/Alignment";
import Prediction from "../structures/Prediction";
import Suggestion from "../structures/Suggestion";
/**
* Generates a score for how closely the suggestion matches the answer key
* @param {Suggestion} suggestion
* @param {object} answerKey
* @return {number}
*/
export declare function scoreSuggestion(suggestion: Suggestion, answerKey: object): number;
/**
* converts some strings into corpus.
* @param {string} source
* @param {string} target
* @return {Token[][][]}
*/
export declare function makeCorpus(source: string, target: string): Token[][][];
/**
* Generates some strings into corpus with support for lemma
* @param source
* @param target
*/
export declare function makeComplexCorpus(source: string, target: string): Token[][][];
/**
* converts some strings into an unaligned sentence pair
* @param {string} source
* @param {string} target
* @return {Token[][]}
*/
export declare function makeUnalignedSentence(source: string, target: string): [Token[], Token[]];
/**
* Generates a sample alignment from a sentence
* @param {String} sentence - a raw sentence from which to generate a mock alignment
* @return {Array<Alignment>} a mock alignment
*/
export declare function alignMockSentence(sentence: string): Alignment[];
/**
* Generates a sample alignment from a complex sentence.
* Additional data like `lemma` can be appended to the words like `word:lemma`
* @param sentence
*/
export declare function alignComplexMockSentence(sentence: string): Alignment[];
/**
* Creates a mock alignment from two strings.
* The strings will be tokenized and converted to n-grams in the alignment
* @param {string} source
* @param {string} target
* @return {Alignment}
*/
export declare function makeMockAlignment(source: string, target: string): Alignment;
/**
* Creates a mock alignment from two complex strings.
* Additional data like `lemma` can be appended to the word like `word:lemma`
* @param source
* @param target
*/
export declare function makeComplexMockAlignment(source: string, target: string): Alignment;
/**
* Creates a mock prediction from two strings
* @param {string} source
* @param {string} target
* @param {number} confidence - the confidence of the prediction
* @return {Prediction}
*/
export declare function makeMockPrediction(source: string, target: string, confidence: number): Prediction;
/**
* Reverses the character order of words in a sentence
* @param {string} sentence
* @return {string}
*/
export declare function reverseSentenceWords(sentence: string): string;
/**
* Flips a sentence.
* @param sentence
*/
export declare function reverseSentence(sentence: string): string;
/**
* Converts a sentence to an array of Tokens
* @param {String} sentence - a raw sentence to convert into tokens
* @return {Array<Token>} an array of tokens
*/
export declare function tokenizeMockSentence(sentence: string): Token[];
/**
* Converts a sentence to an array of
* @param sentence - a sentence with lemmas appended to words like `word:lemma`.
*/
export declare function tokenizeComplexMockSentence(sentence: string): Token[];
export declare class MockAlgorithm extends Algorithm {
name: string;
execute(prediction: Prediction, cIndex: CorpusIndex, saIndex: AlignmentMemoryIndex, usIndex: CorpusIndex): Prediction;
}