Class WordAlignment

Nested Relationships

Nested Types

Class Documentation

class WordAlignment

Public Functions

WordAlignment()
WordAlignment(const std::string &line, size_t srcEosPos, size_t tgtEosPos)

Constructs word alignments from textual representation.

Adds alignment point for externally supplied EOS positions in source and target string.

Parameters
  • line: String in the form of “0-0 1-1 1-2”, etc.

Point &operator[](size_t i)
auto begin() const
auto end() const
void push_back(size_t s, size_t t, float p)
size_t size() const
void sort()

Sorts alignments in place by source indices in ascending order.

void normalize(bool reverse = false)

Normalizes alignment probabilities of target words to sum to 1 over source words alignments.

This is needed for correct cost computation for guided alignment training with CE cost criterion.

std::string toString() const

Returns textual representation.

struct Point

Public Members

size_t srcPos
size_t tgtPos
float prob