Wiki

Clone wiki

SuperSimpleSemantics / Usage Guide

How to use the SSS in your code (wip)

Introduction #

Heres a basic guide to using the SSS in your code WIP (sorry!)

If you just want to know how to SSS datafiles please see;

https://code.google.com/p/green-fruit-engine/wiki/Contributing

Contents #

  • Importing the lib
  • Very basic example program.
  • Setting up the semantic system for use
  • Adding data directly within your code
  • Loading from Index files
  • Querying;Getting nodes with certain property's
  • Querying;Running text based Query's

Importing and Setup #

Download, import, basic setup etc (to be written, sorry. Basically import the jar like any other java libaury. You need to also import guava v09 or above and gwt-guava as well if using this in gwt. If you need help contact me)

Example Program #

Below is an example program designed to test if its been set up correctly

Details on the setup options #

Adding new Nodes directly #

Loading from index files #

Querying; Getting nodes that match certain property's

Querying; Using a text based query search #

Example of a query based on a text query;

#!java


      DoSomethingWithNodesRunnable callback = new DoSomethingWithNodesRunnable(){

        @Override
        public void run(ArrayList<SSSNode> testresult, boolean invert) {

            Iterator<SSSNode> tri = testresult.iterator();

                         //output the results found to the log
            while (tri.hasNext()) {

                SSSNode currentResult = (SSSNode) tri.next();

                Log.info(currentResult.getPLabel());

            }

        }

    };


    //create a query for green fruit
    Query realQuery = new Query("color=green fruit");

    //run the query, using the callback created earlier to deal with the result
    QueryEngine.processQuery(realQuery, false, null, callback);

The key line here is

Query realQuery = new Query("color=green fruit");

This creates a query object from a string - in this case looking for things that have both a property of "color=green" and a property of "rdfs:subclass=fruit"

By default any space means "AND" and the results will be an intersection of the lists that meet all the requirements.

If you wish to use a string with spaces, just use escaped quotes in your code;

Query realQuery = new Query("\"tv show\"");

For example, would search for anything that's a subclass of "tv show".

If you wish to use an OR, use

Colour=Green || Fruit

Would return things that are green OR fruit

By using brackets and subquery you can even use a combination;

Colour=Green || (Fruit color=red)

Would return things that are green OR things that are both coloured red and fruit.

(Also note the mixed spelling of colour/color, this was done to show nodes can have more then one label to be refered too - and not in any way that I did a typo)

Negatives can also be used

fruit !(color=green || color=red)

This would be things that are fruit but not green or red

Updated