[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/nepomuk-kde/scribo
From: Sebastian Trueg <sebastian () trueg ! de>
Date: 2009-06-17 21:18:39
Message-ID: 1245273519.595321.22272.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 983278 by trueg:
* New scribo plugin which extracts dates and times. The reporting is not perfect yet \
since Scribo::Entity does not fit and using Statement is more a hack
* Use pimo types in the OpenCalais plugin
M +1 -0 lib/entity.cpp
M +28 -1 lib/statement.cpp
M +15 -0 lib/statement.h
M +5 -0 lib/statement_p.h
D ontologies (directory)
M +1 -0 plugins/CMakeLists.txt
A plugins/datetime (directory)
A plugins/datetime/CMakeLists.txt
A plugins/datetime/datetimetextmatchplugin.cpp [License: LGPL (v2+)]
A plugins/datetime/datetimetextmatchplugin.h [License: LGPL (v2+)]
A plugins/datetime/scribo_datetimetextmatchplugin.desktop
M +17 -0 plugins/opencalais/CMakeLists.txt
A plugins/opencalais/opencalais.rdfs ontologies/opencalais.rdfs#982999
M +23 -1 plugins/opencalais/opencalaistextmatchplugin.cpp
M +7 -0 plugins/opencalais/opencalaistextmatchplugin.h
M +0 -2 plugins/pimo/CMakeLists.txt
M +2 -2 plugins/pimo/pimotextmatchplugin.cpp
--- trunk/playground/base/nepomuk-kde/scribo/lib/entity.cpp #983277:983278
@@ -33,6 +33,7 @@
ep->m_occurrences = m_occurrences;
ep->m_name = m_name;
ep->m_type = m_type;
+ ep->m_localResource = m_localResource;
return ep;
}
--- trunk/playground/base/nepomuk-kde/scribo/lib/statement.cpp #983277:983278
@@ -29,13 +29,18 @@
s->m_occurrences = m_occurrences;
s->m_verb = m_verb;
s->m_entity = m_entity;
+ s->m_property = m_property;
+ s->m_value = m_value;
return s;
}
QString Scribo::StatementPrivate::label() const
{
- return m_label;
+ if ( !m_label.isEmpty() )
+ return m_label;
+ else
+ return m_value.toString();
}
@@ -56,6 +61,16 @@
}
+Scribo::Statement::Statement( const Nepomuk::Types::Property& property, const \
Nepomuk::Variant& value, const Soprano::Graph& rdf ) + : TextMatch( new \
StatementPrivate() ) +{
+ StatementPrivate* p = static_cast<StatementPrivate*>( d );
+ p->m_rdf = rdf;
+ p->m_property = property;
+ p->m_value = value;
+}
+
+
Scribo::Statement::~Statement()
{
}
@@ -79,3 +94,15 @@
{
return static_cast<StatementPrivate*>( d )->m_entity;
}
+
+
+Nepomuk::Types::Property Scribo::Statement::property() const
+{
+ return static_cast<StatementPrivate*>( d )->m_property;
+}
+
+
+Nepomuk::Variant Scribo::Statement::value() const
+{
+ return static_cast<StatementPrivate*>( d )->m_value;
+}
--- trunk/playground/base/nepomuk-kde/scribo/lib/statement.h #983277:983278
@@ -25,6 +25,13 @@
#include "scribo_export.h"
+namespace Nepomuk {
+ class Variant;
+ namespace Types {
+ class Property;
+ }
+}
+
namespace Scribo {
class StatementPrivate;
@@ -34,12 +41,20 @@
public:
Statement();
Statement( const QString& verb, const Entity& entity, const QString& label, \
const Soprano::Graph& rdf ); + Statement( const Nepomuk::Types::Property& \
property, const Nepomuk::Variant& value, const Soprano::Graph& rdf ); ~Statement();
Statement& operator=( const Statement& );
+ // either this...
QString verb() const;
Entity entity() const;
+
+ // ... or this
+ Nepomuk::Types::Property property() const;
+ Nepomuk::Variant value() const;
+
+ // -> this is no good. Split in two classes or cleanup somehow
};
}
--- trunk/playground/base/nepomuk-kde/scribo/lib/statement_p.h #983277:983278
@@ -24,6 +24,9 @@
#include "textmatch_p.h"
#include "entity.h"
+#include <Nepomuk/Variant>
+#include <Nepomuk/Types/Property>
+
namespace Scribo {
class StatementPrivate : public TextMatchPrivate
{
@@ -35,6 +38,8 @@
QString m_verb;
QString m_label;
Entity m_entity;
+ Nepomuk::Types::Property m_property;
+ Nepomuk::Variant m_value;
};
}
--- trunk/playground/base/nepomuk-kde/scribo/plugins/CMakeLists.txt #983277:983278
@@ -2,3 +2,4 @@
add_subdirectory(opencalais)
add_subdirectory(pimo)
+add_subdirectory(datetime)
--- trunk/playground/base/nepomuk-kde/scribo/plugins/opencalais/CMakeLists.txt \
#983277:983278 @@ -1,3 +1,5 @@
+include(MacroAddOntology)
+
include_directories(
${QT_INCLUDES}
${KDE4_INCLUDES}
@@ -5,14 +7,28 @@
${CMAKE_SOURCE_DIR}
${libscribo_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
+ ${pimolib_BINARY_DIR}
+ ${pimolib_SOURCE_DIR}
)
+find_file(NFO_TRIG_SOURCE
+ nfo.trig
+ PATHS "${KDE4_DATA_INSTALL_DIR}/.." "${KDE4_DATA_INSTALL_DIR}" ENV XDG_DATA_DIRS
+ PATH_SUFFIXES "apps/nepomuk/ontologies"
+ )
+if(NOT NFO_TRIG_SOURCE)
+ message(ERROR_FATAL "Could not find nfo.trig NFO source file. Is kdebase-runtime \
installed?") +endif(NOT NFO_TRIG_SOURCE)
+
# plugin
set(OCTMP_SCRS
lookupjob.cpp
opencalaistextmatchplugin.cpp
)
+kde4_add_ontology(OCTMP_SCRS ${CMAKE_CURRENT_SOURCE_DIR}/opencalais.rdfs \
"OpenCalais" "Nepomuk::Vocabulary" "rdfxml") +kde4_add_ontology(OCTMP_SCRS \
${NFO_TRIG_SOURCE} "NFO" "Nepomuk::Vocabulary" "trig") +
kde4_add_kcfg_files(OCTMP_SCRS opencalaisconfig.kcfgc)
kde4_add_plugin(scribo_opencalaistextmatchplugin ${OCTMP_SCRS})
@@ -23,6 +39,7 @@
${KDE4_KDEUI_LIBS}
${QT_QTNETWORK_LIBRARY}
scribo
+ pimo
)
install(TARGETS scribo_opencalaistextmatchplugin DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES scribo_opencalaistextmatchplugin.desktop DESTINATION \
${SERVICES_INSTALL_DIR}/scribotextmatchplugins)
--- trunk/playground/base/nepomuk-kde/scribo/plugins/opencalais/opencalaistextmatchplugin.cpp \
#983277:983278 @@ -22,6 +22,9 @@
#include "lookupjob.h"
#include "entity.h"
#include "statement.h"
+#include "pimo.h"
+#include "opencalais.h"
+#include "nfo.h"
#include <Nepomuk/Types/Class>
@@ -40,6 +43,16 @@
: TextMatchPlugin( parent ),
m_lookupJob( 0 )
{
+ // build OpenCalais->PIMO type map
+ // FIXME: complete the map
+ m_typeMap.insert( Nepomuk::Vocabulary::OpenCalais::City(), \
Nepomuk::Vocabulary::PIMO::City() ); + m_typeMap.insert( \
Nepomuk::Vocabulary::OpenCalais::Country(), Nepomuk::Vocabulary::PIMO::Country() ); + \
m_typeMap.insert( Nepomuk::Vocabulary::OpenCalais::Company(), \
Nepomuk::Vocabulary::PIMO::Organization() ); + m_typeMap.insert( \
Nepomuk::Vocabulary::OpenCalais::Organization(), \
Nepomuk::Vocabulary::PIMO::Organization() ); + m_typeMap.insert( \
Nepomuk::Vocabulary::OpenCalais::Person(), Nepomuk::Vocabulary::PIMO::Person() ); + \
m_typeMap.insert( Nepomuk::Vocabulary::OpenCalais::Position(), \
Nepomuk::Vocabulary::PIMO::PersonRole() ); + m_typeMap.insert( \
Nepomuk::Vocabulary::OpenCalais::Continent(), Nepomuk::Vocabulary::PIMO::Location() \
); + m_typeMap.insert( Nepomuk::Vocabulary::OpenCalais::URL(), \
Nepomuk::Vocabulary::NFO::Website() ); }
@@ -103,7 +116,7 @@
.arg( r.toN3() ),
Soprano::Query::QueryLanguageSparql );
if ( it2.next() ) {
- Nepomuk::Types::Class type( it2["type"].uri() );
+ Nepomuk::Types::Class type( matchPimoType( it2["type"].uri() ) );
QString name = it2["name"].toString();
Scribo::Entity entity( name, type, graph );
@@ -163,6 +176,15 @@
}
+QUrl OpenCalaisTextMatchPlugin::matchPimoType( const QUrl& openCalaisType )
+{
+ QHash<QUrl, QUrl>::const_iterator it = m_typeMap.constFind( openCalaisType );
+ if ( it == m_typeMap.constEnd() )
+ return Nepomuk::Vocabulary::PIMO::Thing();
+ else
+ return *it;
+}
+
SCRIBO_EXPORT_TEXTMATCH_PLUGIN( OpenCalaisTextMatchPlugin, \
"scribo_opencalaistextmatchplugin" )
#include "opencalaistextmatchplugin.moc"
--- trunk/playground/base/nepomuk-kde/scribo/plugins/opencalais/opencalaistextmatchplugin.h \
#983277:983278 @@ -24,7 +24,11 @@
#include "textmatchplugin.h"
#include <QtCore/QVariant>
+#include <QtCore/QHash>
+#include <Soprano/Node> // for qHash(QUrl)
+
+
namespace OpenCalais {
class LookupJob;
}
@@ -45,7 +49,10 @@
void slotResult( KJob* );
private:
+ QUrl matchPimoType( const QUrl& openCalaisType );
+
OpenCalais::LookupJob* m_lookupJob;
+ QHash<QUrl, QUrl> m_typeMap;
};
#endif
--- trunk/playground/base/nepomuk-kde/scribo/plugins/pimo/CMakeLists.txt \
#983277:983278 @@ -19,8 +19,6 @@
${SOPRANO_LIBRARIES}
${SOPRANO_INDEX_LIBRARIES}
${KDE4_KDECORE_LIBS}
- ${KDE4_KDEUI_LIBS}
- ${QT_QTNETWORK_LIBRARY}
scribo
pimo
)
--- trunk/playground/base/nepomuk-kde/scribo/plugins/pimo/pimotextmatchplugin.cpp \
#983277:983278 @@ -86,11 +86,11 @@
void PimoTextMatchPlugin::queryWord( const QString& word )
{
if ( word.length() < s_minLength ) {
- kDebug() << word << "too short";
+// kDebug() << word << "too short";
return;
}
- kDebug() << "checking word" << word;
+// kDebug() << "checking word" << word;
QString query
= Soprano::Index::IndexFilterModel::encodeUriForLuceneQuery( \
Soprano::Vocabulary::NAO::prefLabel() )
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic