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

void HMM::apply_rules ( vector< TForbidRule > const &  forbid_rules,
vector< TEnforceAfterRule > const &  enforce_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 471 of file HMM.C.

                                                                 {
//  TForbidRule forbid_rules[] = FORBID_RULES;         // Automatically generated by etq2flex.awk
//  TEnforceAfterRule enforce_rules[] = ENFORCE_RULES; // Automatically generated by etq2flex.awk
  int i, j, j2;
  bool found;
   
  for(i=0; i<(int) forbid_rules.size(); i++) {
    a[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;
             break;
           }        
      }
      if (!found)
        a[enforce_rules[i].tagi][j] = ZERO;
    }
  }
    
  // Normalize probabilities
  for(i=0; i<N; i++) {
    double sum=0;
    for(j=0; j<N; j++) 
      sum += a[i][j];
    for(j=0; j<N; j++)
      a[i][j] = a[i][j]/sum;
  }
}


Generated by  Doxygen 1.6.0   Back to index