[tracker/parser-unicode-libs-review] tracker-language: new method to check if a word is a stopword



commit 2d59ead35e0e97a17e93163f633112dc4bea3e39
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Fri May 14 18:34:51 2010 +0200

    tracker-language: new method to check if a word is a stopword

 src/libtracker-common/tracker-language.c |   26 +++++++++++++++++++++++++-
 src/libtracker-common/tracker-language.h |    2 ++
 2 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/src/libtracker-common/tracker-language.c b/src/libtracker-common/tracker-language.c
index 07df05a..d67d13d 100644
--- a/src/libtracker-common/tracker-language.c
+++ b/src/libtracker-common/tracker-language.c
@@ -330,7 +330,7 @@ tracker_language_new (const gchar *language_code)
 {
 	TrackerLanguage *language;
 
-	language = g_object_new (TRACKER_TYPE_LANGUAGE, 
+	language = g_object_new (TRACKER_TYPE_LANGUAGE,
 	                         "language-code", language_code,
 	                         NULL);
 
@@ -380,6 +380,30 @@ tracker_language_get_stop_words (TrackerLanguage *language)
 }
 
 /**
+ * tracker_language_is_stop_word:
+ * @language: a #TrackerLanguage
+ * @word: a string containing a word
+ *
+ * Returns %TRUE if the given @word is in the list of stop words of the
+ *  given @language.
+ *
+ * Returns: %TRUE if @word is a stop word. %FALSE otherwise.
+ */
+gboolean
+tracker_language_is_stop_word (TrackerLanguage *language,
+                               const gchar     *word)
+{
+	TrackerLanguagePriv *priv;
+
+	g_return_val_if_fail (TRACKER_IS_LANGUAGE (language), FALSE);
+	g_return_val_if_fail (word, FALSE);
+
+	priv = GET_PRIV (language);
+
+	return g_hash_table_lookup (priv->stop_words, word) != NULL;
+}
+
+/**
  * tracker_language_get_language_code:
  * @language: a #TrackerLanguage
  *
diff --git a/src/libtracker-common/tracker-language.h b/src/libtracker-common/tracker-language.h
index f0ff3cd..71e00f1 100644
--- a/src/libtracker-common/tracker-language.h
+++ b/src/libtracker-common/tracker-language.h
@@ -52,6 +52,8 @@ TrackerLanguage *tracker_language_new                (const gchar     *language_
 
 gboolean         tracker_language_get_enable_stemmer (TrackerLanguage *language);
 GHashTable *     tracker_language_get_stop_words     (TrackerLanguage *language);
+gboolean         tracker_language_is_stop_word       (TrackerLanguage *language,
+                                                      const gchar     *word);
 const gchar *    tracker_language_get_language_code  (TrackerLanguage *language);
 
 void             tracker_language_set_enable_stemmer (TrackerLanguage *language,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]