• R/O
  • SSH
  • HTTPS

comatz: Commit


Commit MetaInfo

Revisão13 (tree)
Hora2007-04-20 16:44:22
Autorkous

Mensagem de Log

* comatz/cm-word.[ch]: added frequency.

Mudança Sumário

Diff

--- comatz/trunk/ChangeLog (revision 12)
+++ comatz/trunk/ChangeLog (revision 13)
@@ -1,5 +1,7 @@
11 2007-04-20 Kouhei Sutou <kou@cozmixng.org>
22
3+ * comatz/cm-word.[ch]: added frequency.
4+
35 * comatz/cm-word.[ch]: renamed from ch-char.[ch]. We handle words
46 not characters.
57
--- comatz/trunk/comatz/cm-word.c (revision 12)
+++ comatz/trunk/comatz/cm-word.c (revision 13)
@@ -32,8 +32,9 @@
3232 typedef struct _CmWordPrivate CmWordPrivate;
3333 struct _CmWordPrivate
3434 {
35- gword *reading;
36- gword *utf8;
35+ gchar *reading;
36+ gchar *utf8;
37+ gint frequency;
3738 };
3839
3940 enum
@@ -40,7 +41,8 @@
4041 {
4142 PROP_0,
4243 PROP_READING,
43- PROP_UTF8
44+ PROP_UTF8,
45+ PROP_FREQUENCY
4446 };
4547
4648 G_DEFINE_TYPE (CmWord, cm_word, G_TYPE_OBJECT)
@@ -69,7 +71,7 @@
6971
7072 spec = g_param_spec_string("reading",
7173 N_("UTF8"),
72- N_("UTF8 encoding of the wordacter."),
74+ N_("UTF8 encoding of the word."),
7375 NULL,
7476 G_PARAM_READABLE | G_PARAM_WRITABLE);
7577 g_object_class_install_property(gobject_class, PROP_READING, spec);
@@ -76,11 +78,20 @@
7678
7779 spec = g_param_spec_string("utf8",
7880 N_("UTF8"),
79- N_("UTF8 encoding of the wordacter."),
81+ N_("UTF8 encoding of the word."),
8082 NULL,
8183 G_PARAM_READABLE | G_PARAM_WRITABLE);
8284 g_object_class_install_property(gobject_class, PROP_UTF8, spec);
8385
86+ spec = g_param_spec_int("frequency",
87+ N_("Frequency"),
88+ N_("The frequency of appearance of the word."),
89+ -1,
90+ CM_WORD_MAX_FREQUENCY,
91+ -1,
92+ G_PARAM_READABLE | G_PARAM_WRITABLE);
93+ g_object_class_install_property(gobject_class, PROP_FREQUENCY, spec);
94+
8495 g_type_class_add_private (gobject_class, sizeof(CmWordPrivate));
8596 }
8697
@@ -88,8 +99,9 @@
8899 cm_word_init (CmWord *word)
89100 {
90101 CmWordPrivate *priv = CM_WORD_GET_PRIVATE (word);
91- priv->reading = NULL;
92- priv->utf8 = NULL;
102+ priv->reading = NULL;
103+ priv->utf8 = NULL;
104+ priv->frequency = -1;
93105 }
94106
95107 static void
@@ -104,6 +116,7 @@
104116
105117 priv->reading = NULL;
106118 priv->utf8 = NULL;
119+ priv->frequency = -1;
107120
108121 G_OBJECT_CLASS(cm_word_parent_class)->dispose(object);
109122 }
@@ -124,6 +137,9 @@
124137 case PROP_UTF8:
125138 cm_word_set_utf8(word, g_value_get_string(value));
126139 break;
140+ case PROP_FREQUENCY:
141+ cm_word_set_frequency(word, g_value_get_int(value));
142+ break;
127143 default:
128144 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
129145 break;
@@ -149,6 +165,9 @@
149165 case PROP_UTF8:
150166 g_value_set_string(value, priv->utf8);
151167 break;
168+ case PROP_FREQUENCY:
169+ g_value_set_int(value, priv->frequency);
170+ break;
152171 default:
153172 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
154173 break;
@@ -163,7 +182,7 @@
163182 * Return value: a new #CmWord
164183 */
165184 CmWord*
166-cm_word_new (const gword *reading, const gword *utf8)
185+cm_word_new (const gchar *reading, const gchar *utf8)
167186 {
168187 return g_object_new(CM_TYPE_WORD,
169188 "reading", reading,
@@ -171,7 +190,7 @@
171190 NULL);
172191 }
173192
174-const gword *
193+const gchar *
175194 cm_word_get_reading (CmWord *word)
176195 {
177196 g_return_val_if_fail(CM_IS_WORD(word), NULL);
@@ -178,7 +197,7 @@
178197 return CM_WORD_GET_PRIVATE(word)->reading;
179198 }
180199
181-const gword *
200+const gchar *
182201 cm_word_get_utf8 (CmWord *word)
183202 {
184203 g_return_val_if_fail(CM_IS_WORD(word), NULL);
@@ -185,8 +204,15 @@
185204 return CM_WORD_GET_PRIVATE(word)->utf8;
186205 }
187206
207+gint
208+cm_word_get_frequency (CmWord *word)
209+{
210+ g_return_val_if_fail(CM_IS_WORD(word), -1);
211+ return CM_WORD_GET_PRIVATE(word)->frequency;
212+}
213+
188214 void
189-cm_word_set_reading (CmWord *word, const gword *reading)
215+cm_word_set_reading (CmWord *word, const gchar *reading)
190216 {
191217 CmWordPrivate *priv;
192218 g_return_if_fail(CM_IS_WORD(word));
@@ -201,7 +227,7 @@
201227 }
202228
203229 void
204-cm_word_set_utf8 (CmWord *word, const gword *utf8)
230+cm_word_set_utf8 (CmWord *word, const gchar *utf8)
205231 {
206232 CmWordPrivate *priv;
207233 g_return_if_fail(CM_IS_WORD(word));
@@ -215,6 +241,16 @@
215241 priv->utf8 = g_strdup(priv->utf8);
216242 }
217243
244+void
245+cm_word_set_frequency (CmWord *word, gint frequency)
246+{
247+ CmWordPrivate *priv;
248+ g_return_if_fail(CM_IS_WORD(word));
249+
250+ priv = CM_WORD_GET_PRIVATE(word);
251+ priv->frequency = frequency;
252+}
253+
218254 /*
219255 vi:ts=4:nowrap:ai:expandtab
220256 */
--- comatz/trunk/comatz/cm-word.h (revision 12)
+++ comatz/trunk/comatz/cm-word.h (revision 13)
@@ -26,6 +26,8 @@
2626
2727 G_BEGIN_DECLS
2828
29+#define CM_WORD_MAX_FREQUENCY 100
30+
2931 #define CM_TYPE_WORD (cm_word_get_type())
3032 #define CM_WORD(o) (G_TYPE_CHECK_INSTANCE_CAST((o), CM_TYPE_WORD, CmWord))
3133 #define CM_IS_WORD(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), CM_TYPE_WORD))
@@ -46,16 +48,19 @@
4648
4749 GType cm_word_get_type (void) G_GNUC_CONST;
4850
49-CmWord *cm_word_new (const gword *reading,
50- const gword *utf8);
51+CmWord *cm_word_new (const gchar *reading,
52+ const gchar *utf8);
5153
52-const gword *cm_word_get_reading (CmWord *word);
53-const gword *cm_word_get_utf8 (CmWord *word);
54+const gchar *cm_word_get_reading (CmWord *word);
55+const gchar *cm_word_get_utf8 (CmWord *word);
56+gint cm_word_get_frequency (CmWord *word);
5457
55-void cm_word_set_reading (CmWord *word,
56- const gword *reading);
57-void cm_word_set_utf8 (CmWord *word,
58- const gword *utf8);
58+void cm_word_set_reading (CmWord *word,
59+ const gchar *reading);
60+void cm_word_set_utf8 (CmWord *word,
61+ const gchar *utf8);
62+void cm_word_set_frequency (CmWord *word,
63+ gint frequency);
5964
6065 G_END_DECLS
6166
Show on old repository browser