20 if (vocab.size() == 0)
21 throw Exception(
"LexicalAlphabet::LexicalAlphabet: not constructible from empty vocabulary.");
23 size_t t = vocab[0].size();
26 for (
size_t i = 0; i < t; i++)
34 for (
size_t i = 0; i < vocab.size(); ++i)
36 if (t != vocab[i].size())
37 throw Exception(
"LexicalAlphabet: several lengths in vocabulary.");
42 throw Exception(
"LexicalAlphabet : " + vocab[i] +
" defined twice.");
51 for (
size_t i = 0; i < t; i++)
64 string s =
"Lexicon(";
A partial implementation of the Alphabet interface.
std::string getName(const std::string &state) const
Get the complete name of a state given its string description.
virtual AlphabetState & getStateAt(size_t stateIndex)
Get a state at a position in the alphabet_ vector.
size_t getNumberOfStates() const
This is a convenient alias for getNumberOfChars(), returning a size_t instead of unsigned int.
virtual void registerState(AlphabetState *st)
Add a state to the Alphabet.
This is the base class to describe states in an Alphabet.
const std::string & getLetter() const
Get the letter(s) corresponding to the state.
An alphabet exception thrown when trying to specify a bad char to the alphabet.
std::string getAlphabetType() const
Identification method.
LexicalAlphabet(const std::vector< std::string > &vocab)
Builds a new word alphabet from a vector of given words.
This alphabet is used to deal NumericAlphabet.