Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/11/15 13:06:02 (9 years ago)
Author:
gkronber
Message:

#2283: commit before cleanup after EuroCAST

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Problems/SantaFeAntProblem.cs

    r11977 r11980  
    123123
    124124    public string CanonicalRepresentation(string phrase) {
    125       phrase = phrase.Replace("A", ".");
     125      //phrase = phrase.Replace("A", ".");
    126126      var sb = new StringBuilder(phrase);
    127127      string canonicalPhrase = phrase;
     
    133133        canonicalPhrase = sb.ToString();
    134134      } while (canonicalPhrase != oldPhrase);
    135       return sb.ToString();
     135      return canonicalPhrase;
    136136    }
    137137
     
    141141
    142142
    143       //yield return new Feature("const", 0.0);
     143      yield return new Feature(isTerminal + ToString(), 1.0);
    144144      //if (phrase.Length > 0) {
    145145      //  var ant = new Ant(recordTrail: true);
     
    157157      //}
    158158      //
    159       ////yield return new Feature("$" + phrase[0], 1.0);
    160       // if (!isTerminal) {
    161       //   for (int i = 4; i < phrase.Length; i++) {
    162       //     if (grammar.IsNonTerminal(phrase[i])) {
    163       //       yield return new Feature(phrase[i - 4].ToString() + phrase[i - 3].ToString() + phrase[i - 2] + phrase[i - 1], 0.1);
    164       //       break;
    165       //     }
    166       //   }
    167       // }
     159      yield return new Feature("$" + (phrase.Length > 0 ? phrase[0] : ' '), 1.0);
     160      if (!isTerminal) {
     161        for (int i = 4; i < phrase.Length; i++) {
     162          if (!grammar.IsTerminal(phrase[i])) {
     163            yield return new Feature(phrase[i - 4].ToString() + phrase[i - 3].ToString() + phrase[i - 2] + phrase[i - 1], 1.0);
     164            break;
     165          }
     166        }
     167      }
    168168      // var d = 0;
    169169      // var ls = 0;
Note: See TracChangeset for help on using the changeset viewer.