3 * Library to deal with pinyin.
5 * Copyright (C) 2010 Peng Wu
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 #include "novel_types.h"
27 /* Note: the optional tag has been removed from the first implementation.
28 * Maybe the optional tag will be added back later.
35 * @returns: whether the initialize operation is successful.
37 * Initialize the n-gram tag parse library.
44 * @line_type: the line type.
45 * @line_tag: the line tag.
46 * @num_of_values: the number of values following the line tag.
47 * @required_tags: the required tags of the line.
48 * @ignored_tags: the ignored tags of the line.
49 * @returns: whether the add operation is successful.
51 * Add one line tag to the tag parse library.
53 * Note: the required and ignored tags are separated by ',' or ':' .
56 bool taglib_add_tag(int line_type, const char * line_tag, int num_of_values, const char * required_tags, const char * ignored_tags);
60 * @input_line: one input line.
61 * @line_type: the line type.
62 * @values: the values following the line tag.
63 * @required: the required tags of the line type.
64 * @returns: whether the line is parsed ok.
66 * Parse one input line into line_type, values and required tags.
68 * Note: most parameters are hash table of string (const char *).
71 bool taglib_read(const char * input_line, int & line_type,
72 GPtrArray * values, GHashTable * required);
76 * @line_type: the type of the line tag.
77 * @returns: whether the remove operation is successful.
79 * Remove one line tag.
82 bool taglib_remove_tag(int line_type);
86 * @returns: whether the push operation is successful.
88 * Push the current state onto the stack.
90 * Note: the taglib_push/pop_state functions are used to save
91 * the current known tag list in stack.
92 * Used when the parsing context is changed.
94 bool taglib_push_state();
98 * @returns: whether the pop operation is successful.
100 * Pop the current state off the stack.
103 bool taglib_pop_state();
107 * @returns: whether the finish operation is successful.
109 * Finish the n-gram tag parse library.
114 class PhraseLargeTable2;
115 class FacadePhraseIndex;
119 * taglib_string_to_token:
120 * @phrase_table: the phrase table for token lookup.
121 * @phrase_index: the phrase index to prepare PhraseTokens.
122 * @string: the string of the phrase.
123 * @returns: the phrase token found in phrase table.
125 * Translate one phrase into the token.
128 phrase_token_t taglib_string_to_token(PhraseLargeTable2 * phrase_table,
129 FacadePhraseIndex * phrase_index,
130 const char * string);
133 * taglib_token_to_string:
134 * @phrase_index: the phrase index for phrase string lookup.
135 * @token: the phrase token.
136 * @returns: the phrase string found in phrase index.
138 * Translate one token into the phrase string.
141 char * taglib_token_to_string(FacadePhraseIndex * phrase_index,
142 phrase_token_t token);
144 /* Note: the following function is only available when the optional tag exists.
145 * bool taglib_report_status(int line_type);
148 /* Note: taglib_write is omited, as printf is more suitable for this. */