Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents a multi-lingual word alignment prediction engine.

Hierarchy

  • Engine

Index

Constructors

constructor

  • new Engine(__namedParameters?: object): Engine
  • Parameters

    • Default value __namedParameters: object = {}
      • sourceNgramLength: number
      • targetNgramLength: number
      • warnings: boolean

    Returns Engine

Properties

Private alignmentMemoryIndex

alignmentMemoryIndex: AlignmentMemoryIndex

Private corpusIndex

corpusIndex: CorpusIndex

Private maxSourceNgramLength

maxSourceNgramLength: number

Private maxTargetNgramLength

maxTargetNgramLength: number

Private nGramWarnings

nGramWarnings: boolean

Private registeredAlgorithms

registeredAlgorithms: Algorithm[] = []

Private registeredGlobalAlgorithms

registeredGlobalAlgorithms: GlobalAlgorithm[] = []

Private scheduler

scheduler: Scheduler

Accessors

algorithms

  • Returns a list of algorithms that are registered in the engine

    Returns Algorithm[]

Methods

addAlignmentMemory

  • addAlignmentMemory(alignmentMemory: Alignment[]): void
  • Appends new alignment memory to the engine. Adding alignment memory improves the quality of predictions.

    Parameters

    • alignmentMemory: Alignment[]

      a list of alignments

    Returns void

addCorpus

  • addCorpus(source: Token[][], target: Token[][]): void
  • Appends new corpus to the engine.

    Parameters

    • source: Token[][]

      an array of tokenized source sentences.

    • target: Token[][]

      an array of tokenized target sentences.

    Returns void

clearAlignmentMemory

  • clearAlignmentMemory(): void
  • Removes all of the alignment memory from the engine.

    Returns void

performPrediction

  • Executes prediction algorithms on the unaligned sentence pair. The sentence tokens should contain positional metrics for better accuracy.

    Parameters

    Returns Prediction[]

registerAlgorithm

  • Adds a new algorithm to the engine.

    Parameters

    Returns void

run

  • run(sourceSentence: Token[], targetSentence: Token[]): Prediction[]
  • Performs the prediction calculations

    Parameters

    • sourceSentence: Token[]
    • targetSentence: Token[]

    Returns Prediction[]

score

  • Generates the final confidence scores and sorts the predictions.

    Parameters

    Returns Prediction[]

Static calculateConfidence

  • Scores the predictions and returns a filtered set of suggestions TODO: this should not be done in the engine because we don't know anything about the algorithms here.

    Parameters

    Returns Prediction[]

Static calculateWeightedConfidence

  • Calculates the weighted confidence score of a prediction

    Parameters

    • prediction: Prediction

      the prediction to score

    • scoreKeys: string[]

      the score keys to include in the calculation

    • weights: NumberObject

      the weights to influence the calculation

    Returns number

Static generatePredictions

  • Generates an array of all possible alignment predictions

    Parameters

    • sourceNgrams: Ngram[]

      every possible n-gram in the source text

    • targetNgrams: Ngram[]

      every possible n-gram in the target text

    Returns Prediction[]

Static generateSentenceNgrams

  • generateSentenceNgrams(sentence: Token[], maxNgramLength?: number): Ngram[]
  • Generates an array of all possible contiguous n-grams within the sentence.

    deprecated

    use Parser.ngrams instead

    Parameters

    • sentence: Token[]

      the tokens in a sentence

    • Default value maxNgramLength: number = 3

    Returns Ngram[]

Static readSizedNgrams

  • readSizedNgrams(sentence: Token[], ngramLength: number): Ngram[]
  • Returns an array of n-grams of a particular size from a sentence

    deprecated

    used Parser.sizedNgrams instead

    Parameters

    • sentence: Token[]

      the sentence from which n-grams will be read

    • ngramLength: number

      the length of each n-gram.

    Returns Ngram[]

Static sortPredictions

  • Sorts an array of predictions by confidence

    Parameters

    • predictions: Prediction[]

      the predictions to sort

    Returns Prediction[]

Static sortSuggestions

  • Sorts an array of suggestions by compound confidence

    Parameters

    • suggestions: Suggestion[]

      the suggestions to sort

    Returns Suggestion[]

Static suggest

  • suggest(predictions: Prediction[], maxSuggestions?: number, forceOccurrenceOrder?: boolean, minConfidence?: number): Suggestion[]
  • Returns an array of alignment suggestions

    Parameters

    • predictions: Prediction[]

      a sorted array of predictions from which to base the suggestion

    • Default value maxSuggestions: number = 1

      the maximum number of suggestions to return

    • Default value forceOccurrenceOrder: boolean = true

      forces suggestions to use words in order of occurrence. This may exponentially increase the processing time.

    • Default value minConfidence: number = 0

      the minimum confidence a prediction must have to be used

    Returns Suggestion[]

Generated using TypeDoc