blob: 3dfa6deb10cd2a29d1999accf47b72f3f1085b34 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
* @author Peter Boros
* @date 2004/08/20
* @version $Id$
* @file tokenizer.h
* @brief Generic tokenizer class.
*/
#pragma once
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
namespace fsa {
// {{{ class Tokenizer
/**
* @class Tokenizer
* @brief Generic tokenizer class.
*
* Generic interface to various tokenizer implementations.
*/
class Tokenizer {
public:
/**
* @brief Constructor.
*/
Tokenizer() {}
/**
* @brief Destructor.
*/
virtual ~Tokenizer() {}
/**
* @brief Initialize the tokenizer.
*
* @param text Input text.
* @return True on success.
*/
virtual bool init(const std::string &text) = 0;
/**
* @brief Check if there are more tokens available.
*
* @return True if there are more tokens.
*/
virtual bool hasMore() = 0;
/**
* @brief Get next token.
*
* @return Next token, or empty string if there are no more tokens left.
*/
virtual std::string getNext() = 0;
};
// }}}
} // namespace fsa
|