Commit 2877880e authored by Ivan Frade's avatar Ivan Frade

Ontology doc: Add table with all fts-indexed properties

parent 6dd2b2af
......@@ -17,6 +17,7 @@
<!ENTITY maemo-ontology SYSTEM "maemo-ontology.xml">
<!ENTITY ncal-ontology SYSTEM "ncal-ontology.xml">
<!ENTITY scal-ontology SYSTEM "scal-ontology.xml">
<!ENTITY fts-properties SYSTEM "fts-properties.xml">
]>
<book id="index">
<bookinfo>
......@@ -58,6 +59,8 @@
&maemo-ontology;
&ncal-ontology;
&scal-ontology;
&fts-properties;
</part>
<part id="ontology-notation-description">
......
......@@ -6,21 +6,23 @@
#
BUILD_DIR="../reference/ontology/"
echo "Generating list of classes-properties and files (file-class.cache)"
if [ -e file-class.cache ]; then
rm -f file-class.cache ;
fi
echo "Preparing file full text index properties (fts-properties.xml)"
for f in `find ../../data/ontologies -name "*.ontology"` ; do
TMPNAME=${f%.ontology}
PREFIX=${TMPNAME#*-}
grep "^[a-z]\{1,\}\:[a-zA-Z]" $f |awk -v pr=$PREFIX '{print pr " " $1}' >> file-class.cache
done
echo "<?xml version='1.0' encoding='UTF-8'?>
<chapter id='fts-properties'>
<title>Full-text indexed properties in the ontology</title>
<table frame='all'>
<colspec colname='Property'/>
<colspec colname='Weigth'/>
#echo "Converting all dia diagrams to png"
#for image in `find ../../docs/ontologies -name "*.dia"` ; do
# dia -t png $image -e $BUILD_DIR/$(basename ${image/.dia/.png})
#done
<thead>
<tr>
<td>Property</td>
<td>Weigth</td>
</tr>
</thead>
<tbody>" > $BUILD_DIR/fts-properties.xml
for f in `find ../../data/ontologies -name "*.description"` ; do
# ../../data/ontologies/XX-aaa.description -> PREFIX=aaa
......@@ -28,6 +30,8 @@ for f in `find ../../data/ontologies -name "*.description"` ; do
PREFIX=${TMPNAME#*-}
echo "Generating $PREFIX documentation"
./ttl2sgml -d $f -o $BUILD_DIR/$PREFIX-ontology.xml -l file-class.cache \
./ttl2sgml -d $f -o $BUILD_DIR/$PREFIX-ontology.xml -f $BUILD_DIR/fts-properties.xml \
-e ../../docs/ontologies/$PREFIX/explanation.xml
done
echo "</tbody></table></chapter>" >> $BUILD_DIR/fts-properties.xml
......@@ -8,7 +8,7 @@
static gchar *desc_file = NULL;
static gchar *output_file = NULL;
static gchar *class_location_file = NULL;
static gchar *fts_properties_file = NULL;
static gchar *explanation_file = NULL;
static GOptionEntry entries[] = {
......@@ -20,8 +20,8 @@ static GOptionEntry entries[] = {
"File to write the output (default stdout)",
NULL
},
{ "links", 'l', 0, G_OPTION_ARG_FILENAME, &class_location_file,
"File with pairs: (prefix where the class is defined, class)",
{ "fts", 'f', 0, G_OPTION_ARG_FILENAME, &fts_properties_file,
"Output file listing the full text indexed properties",
NULL
},
{ "explanation", 'e', 0, G_OPTION_ARG_FILENAME, &explanation_file,
......@@ -40,6 +40,7 @@ main (gint argc, gchar **argv)
gchar *ttl_file = NULL;
gchar *dirname = NULL;
FILE *f = NULL;
FILE *fts = NULL;
g_type_init ();
......@@ -73,6 +74,10 @@ main (gint argc, gchar **argv)
}
g_assert (f != NULL);
if (fts_properties_file) {
fts = fopen (fts_properties_file, "a");
}
description = ttl_loader_load_description (desc_file);
dirname = g_path_get_dirname (desc_file);
......@@ -84,7 +89,7 @@ main (gint argc, gchar **argv)
g_free (ttl_file);
g_free (dirname);
ttl_sgml_print (description, ontology, f, class_location_file, explanation_file);
ttl_sgml_print (description, ontology, f, fts, explanation_file);
ttl_loader_free_ontology (ontology);
ttl_loader_free_description (description);
......@@ -92,6 +97,7 @@ main (gint argc, gchar **argv)
g_option_context_free (context);
fclose (f);
fclose (fts);
return 0;
}
......@@ -20,6 +20,7 @@
#define TRACKER_NS "http://www.tracker-project.org/ontologies/tracker#"
#define TRACKER_NOTIFY TRACKER_NS "notify"
#define TRACKER_FTS_INDEXED TRACKER_NS "fulltextIndexed"
#define TRACKER_FTS_WEIGHT TRACKER_NS "weight"
#define NAO_DEPRECATED "http://www.semanticdesktop.org/ontologies/2007/08/15/nao#deprecated"
......@@ -131,6 +132,19 @@ load_in_memory (Ontology *ontology,
prop->fulltextIndexed = string_to_boolean (turtle_object);
} else if (!g_strcmp0 (turtle_predicate, TRACKER_FTS_WEIGHT)) {
/*
* A tracker:weight X
*/
OntologyProperty *prop;
prop = g_hash_table_lookup (ontology->properties, turtle_subject);
if (!prop) {
g_error ("Something wrong");
}
prop->weight = g_strdup (turtle_object);
} else if (!g_strcmp0 (turtle_predicate, RDFS_COMMENT)) {
OntologyClass *klass;
OntologyProperty *prop;
......
......@@ -56,7 +56,7 @@ ttl_model_property_new (const gchar *propname)
prop->description = NULL;
prop->deprecated = FALSE;
prop->fulltextIndexed = FALSE ;
prop->weight = NULL;
return prop;
}
......@@ -81,6 +81,10 @@ ttl_model_property_free (OntologyProperty *def)
g_free (def->description);
}
if (def->weight) {
g_free (def->weight);
}
g_free (def);
}
......
......@@ -28,6 +28,7 @@ typedef struct {
gchar *description;
gboolean deprecated;
gboolean fulltextIndexed;
gchar *weight;
} OntologyProperty;
typedef struct {
......
......@@ -283,18 +283,44 @@ print_ontology_property (gpointer key, gpointer value, gpointer user_data)
g_fprintf (f, "</refsect2>\n\n");
}
static void
print_fts_properties (gpointer key, gpointer value, gpointer user_data)
{
OntologyProperty *def = (OntologyProperty *) value;
gchar *name, *id;
FILE *fts = (FILE *) user_data;
g_return_if_fail (fts != NULL);
if (!def->fulltextIndexed) {
return;
}
name = qname_to_shortname (def->propertyname);
id = shortname_to_id (name);
g_fprintf (fts, "<tr>\n");
g_fprintf (fts, " <td>\n");
print_reference (def->propertyname, fts);
g_fprintf (fts, " </td>\n");
g_fprintf (fts, " <td>%s</td>\n", (def->weight ? def->weight : "0"));
g_fprintf (fts, "</tr>\n");
g_free (id);
}
void
ttl_sgml_print (OntologyDescription *description,
Ontology *ontology,
FILE *f,
const gchar *class_location_file,
FILE *fts,
const gchar *explanation_file)
{
gchar *upper_name;
upper_name = g_ascii_strup (description->localPrefix, -1);
qname_init (description->baseUrl, description->localPrefix, class_location_file);
qname_init (description->baseUrl, description->localPrefix, NULL);
print_sgml_header (f, description);
/* FIXME: make desc files sgml */
......@@ -313,4 +339,8 @@ ttl_sgml_print (OntologyDescription *description,
print_sgml_footer (f);
g_free (upper_name);
if (fts) {
g_hash_table_foreach (ontology->properties, print_fts_properties, fts);
}
}
......@@ -10,7 +10,7 @@ G_BEGIN_DECLS
void ttl_sgml_print (OntologyDescription *description,
Ontology *ontology,
FILE *output,
const gchar *class_location,
FILE *class_location,
const gchar *explanation_file);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment