@Override public String toString() { final StringBuilder builder = new StringBuilder(); for (int i = 0; i < size() - 1; i++) { builder.append(getKeyword(i).toString()); builder.append("|"); } builder.append(getKeyword(size() - 1).toString()); return builder.toString(); } }
/** * This is equivalent to "getKeywordIndex" * * @param symbol a symbol in this Alphabet. * @return the index for that symbol. */ public int getSymbolIndex(@NonNull String symbol) { return getKeywordIndex(symbol); }
/** * This is equivalent to "getKeywords" * * @return the symbols that are contained in this Alphabet. */ public String[] getSymbols() { return getKeywords(); }
@Override public int range() { return alphabet.size(); }
final Alphabet alphabet = new Alphabet(symbols.toArray(new String[0])); return toSequences(strings, alphabet);
/** * This is equivalent to "hasKeyword". * * @param symbol the actual symbol. * @return true if this symbol is contained in the Alphabet and false * otherwise. */ public boolean hasSymbol(@NonNull String symbol) { return hasKeyword(symbol); }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final SymbolicKeywordSpecification other = (SymbolicKeywordSpecification) obj; if (!super.equals(obj)) { return false; } if (this.alphabet != other.alphabet && (this.alphabet == null || !this.alphabet.equals(other.alphabet))) { return false; } return true; } }
/** * This is equivalent to "getKeyword" * * @param index an index. * @return the symbol for this index. */ public String getSymbol(int index) { return getKeyword(index); }
@Override public int index(@NonNull String symbol) { return alphabet.getSymbolIndex(symbol); }
getKeywordSpecification(Sequence.DEFAULTKEYWORD)).getAlphabet(); final double[][] costMatrix = new double[alphabet.size() + 2][alphabet.size() + 2]; for (int i = 0; i < alphabet.size() + 2; i++) { for (int j = 0; j < alphabet.size() + 2; j++) { if (i >= alphabet.size() || j >= alphabet.size()) { costMatrix[i][j] = gapCost; } else {
/** * Sets the actual symbol. * * @param symbol the actual symbol. */ public void setSymbol(@NonNull String symbol) { if (alphabet.hasKeyword(symbol)) { this.symbol = symbol; } else { throw new UnsupportedOperationException( "The given alphabet does not support the given symbol!"); } }
/** * This applies the KeywordSpecification validation and additionally checks * whether the given value is part of the Alphabet. * * {@inheritDoc } */ @Override public boolean validate(Value value) { return value == null || (super.validate(value) && ((SymbolicValue) value).getAlphabet().equals(alphabet)); }