Logo Search packages:      
Sourcecode: apertium version File versions  Download package

void HMM2::apply_rules (  ) 

It applies the forbid and enforce rules found in tagger specification. To to so the transition matrix is modified by introducing null probabilitites in the involded transitions.

Definition at line 357 of file HMM2.C.

  vector<TForbidRule> &forbid_rules = td->getForbidRules();
  vector<TEnforceAfterRule> &enforce_rules = td->getEnforceRules();
  int N = td->getN();
  int i, j, j2;
  bool found;
  for(i=0; i<(int) forbid_rules.size(); i++) {
    (td->getA())[forbid_rules[i].tagi][forbid_rules[i].tagj] = ZERO;

  for(i=0; i<(int) enforce_rules.size(); i++) {
    for(j=0; j<N; j++) {
      found = false;
      for (j2=0; j2<(int) enforce_rules[i].tagsj.size(); j2++) {
           if (enforce_rules[i].tagsj[j2]==j) {
             found = true;
      if (!found)
        (td->getA())[enforce_rules[i].tagi][j] = ZERO;
  // Normalize probabilities
  for(i=0; i<N; i++) {
    double sum=0;
    for(j=0; j<N; j++) 
      sum += (td->getA())[i][j];
    for(j=0; j<N; j++)
      (td->getA())[i][j] = (td->getA())[i][j]/sum;

Generated by  Doxygen 1.6.0   Back to index