source: branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/Sentence.cs @ 15723

Last change on this file since 15723 was 15723, checked in by lkammere, 21 months ago

#2886: Add simple data analysis tests and further informations about algorithm run.

File size: 738 bytes
RevLine 
[15712]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6
7namespace HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration.GrammarEnumeration {
8  public class SymbolString : List<Symbol> {
9
[15723]10    public SymbolString() { }
11
[15712]12    public SymbolString(IEnumerable<Symbol> symbols) : base(symbols) { }
13
14    public bool IsSentence() {
15      return this.All(sym => sym is TerminalSymbol);
16    }
17
18    public int[] GetNonterminalSymbolIndexes() {
19      return Enumerable.Range(0, Count)
20        .Where(i => this[i] is NonterminalSymbol)
21        .ToArray();
22    }
23
[15723]24    public override string ToString() {
[15712]25      return string.Join(" ", this);
26    }
27  }
28}
Note: See TracBrowser for help on using the repository browser.