User:Himanshu40

From Apertium
Revision as of 19:06, 5 January 2018 by Himanshu40 (talk | contribs)
Jump to navigation Jump to search

Weights to lttoolbox

Theory

Weighted transducers are automata in which each transition in addition to its usual input label is augmented with an output label from a possible new alphabet, and carries some weight element of a semiring.

For weight in lttoolbox which currently supports DFA system, we need Semi-ring for calculating weight.

A Semiring is defined by two binary operations and and two designated elements 0 and 1 with following properties:-

  • shows associative, commutative and has 0 as its own identity.
  • shows associative and has 1 as its own identity.

A left semiring distributes on the left and also a right semiring is similarly defined.

Store weights in lttoolbox

  • A Weight class must have binary functions Plus and Times these must form a left or right semiring.

Also in class Weight, there are some additions which must be defined like the following:-

  • >> :- This reads textual representation of a weight.
  • << :- This prints textual representation of a weight.
  • LeftSemiring :- This indicates how weights form a left semi-ring.
  • RightSemiring :- This indicates how weights form a right semi-ring.
  • Read(istream &) :- This reads binary representation of a weight.
  • Write(ostream &) :- This writes binary representation of a weight.
  • NoWeight :- This is a static member function that returns an element which is not a set member and used to signal an error.