[tracker] Bugfixes extracting keywords



commit 5fc88e40c4b1f40e6dfad8f848da3b2cb148d51f
Author: Philip Van Hoof <philip codeminded be>
Date:   Wed Apr 22 13:53:20 2009 +0200

    Bugfixes extracting keywords
---
 src/tracker-extract/tracker-extract-msoffice.c |    4 +++
 src/tracker-extract/tracker-xmp.c              |   31 ++++++++++++++++++++++-
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/src/tracker-extract/tracker-extract-msoffice.c b/src/tracker-extract/tracker-extract-msoffice.c
index 79ef38d..6aa753d 100644
--- a/src/tracker-extract/tracker-extract-msoffice.c
+++ b/src/tracker-extract/tracker-extract-msoffice.c
@@ -154,9 +154,13 @@ metadata_cb (gpointer key,
 		char *lasts, *keyw;
 		size_t len;
 
+		keyw = keywords;
 		keywords = strchr (keywords, '"');
 		if (keywords)
 			keywords++;
+		else 
+			keywords = keyw;
+
 		len = strlen (keywords);
 		if (keywords[len - 1] == '"')
 			keywords[len - 1] = '\0';
diff --git a/src/tracker-extract/tracker-xmp.c b/src/tracker-extract/tracker-xmp.c
index 6ea9139..3e3782a 100644
--- a/src/tracker-extract/tracker-xmp.c
+++ b/src/tracker-extract/tracker-xmp.c
@@ -296,9 +296,13 @@ tracker_xmp_iter_simple (const gchar *uri,
 			char *lasts, *keyw;
 			size_t len;
 
+			keyw = keywords;
 			keywords = strchr (keywords, '"');
 			if (keywords)
 				keywords++;
+			else 
+				keywords = keyw;
+
 			len = strlen (keywords);
 			if (keywords[len - 1] == '"')
 				keywords[len - 1] = '\0';
@@ -313,12 +317,35 @@ tracker_xmp_iter_simple (const gchar *uri,
 			g_free (keywords);
 		}
 		else if (strcmp (name, "subject") == 0) {
+			gchar *keywords = g_strdup (value);
+			char *lasts, *keyw;
+			size_t len;
+
 			tracker_statement_list_insert (metadata, uri, 
 						  NIE_PREFIX "subject", value);
 
 			/* The subject field may contain keywords as well */
-			tracker_statement_list_insert (metadata, uri,
-						  "Image:Keywords", value);
+
+			keyw = keywords;
+			keywords = strchr (keywords, '"');
+			if (keywords)
+				keywords++;
+			else 
+				keywords = keyw;
+
+			len = strlen (keywords);
+			if (keywords[len - 1] == '"')
+				keywords[len - 1] = '\0';
+
+			for (keyw = strtok_r (keywords, ",; ", &lasts); keyw; 
+			     keyw = strtok_r (NULL, ",; ", &lasts)) {
+				tracker_statement_list_insert (metadata,
+						  uri, NIE_PREFIX "keyword",
+						  (const gchar*) keyw);
+			}
+
+			g_free (keywords);
+
 		}
 		else if (strcmp (name, "publisher") == 0) {
 			tracker_statement_list_insert (metadata, ":", RDF_TYPE, NCO_PREFIX "Contact");



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