Hi,
I'm happy and excited to announce that I have ported my Nepomuk query
parser to Baloo. The port itself and a small preliminary commit live in
kde:baloo, branch "queryparser".
All the parsing passes work, so the new parser is able to understand
numbers, file sizes, float values, property names (and their aliases),
type hints ("emails from John", "archives tagged as secret", etc) and
date-times ("yesterday", "last Sunday", "May 18, 2011").
Working on Baloo has been a great pleasure. The parser heavily relies on
Term, and Baloo::Term is way nicer than Nepomuk2::Term (and its
subclasses that all have a slightly different API for the same thing).
The porting operation mainly consisted of removing all the boilerplate
needed by Nepomuk. I congratulate all the Baloo developers for their
hard work!
The first commit in my branch adds the methods Term::setPosition,
Term::setLength, Term::position and Term::length. I finally chose to use
these methods instead of a more general setUserData and getUserData,
because I think that exposing a clear API is better than saying "to get
the position of a term, pass _k_term_position to getUserData".
During my work, I encountered three problems that prevent some features
of the parser to work as they did in the Nepomuk days:
* How do I do a regular expression matching? I currently build a Term
whose operation is "Contains" and value is a QRegExp object, but the
JSon serializer does not support regular expressions and is unable to
serialize queries using them (it returns an empty byte array)
* Date-times are handled by Query, using setDateFilter. The parser
properly lowers date-time comparisons to date filters (see
QueryParser::tuneTerm for all the lowering that takes place), but there
is nothing I can do with times or more advanced comparisons (before a
date-time, between two date-times that are not aligned on a
year/month/day boundary, etc).
* Subqueries are gone, as there is no more "related to" property. I have
ported the code, but it is currently #ifdef'ed out.
My branch also contains a test suite that is not very extensive but
tests all the parsing passes (and allowed me to find plenty of bugs, as
the semantics of Term have slightly changed between Nepomuk and Baloo).
Denis Steckelmacher
Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
- Baloo now has a user query parser Denis Steckelmacher
-