View Javadoc
1   package ubic.basecode.ontology.jena;
2   
3   import com.hp.hpl.jena.ontology.OntModel;
4   import com.hp.hpl.jena.rdf.model.Resource;
5   import ubic.basecode.ontology.search.OntologySearchException;
6   
7   import java.util.List;
8   
9   interface SearchIndex extends AutoCloseable {
10  
11      /**
12       * Find RDF nodes matching the given query string.
13       */
14      List<JenaSearchResult> search( OntModel model, String queryString, int maxResults ) throws OntologySearchException;
15  
16      /**
17       * Find classes that match the query string.
18       *
19       * @param model that goes with the index
20       * @return Collection of OntologyTerm objects
21       */
22      List<JenaSearchResult> searchClasses( OntModel model, String queryString, int maxResults ) throws OntologySearchException;
23  
24      /**
25       * Find individuals that match the query string
26       *
27       * @param model that goes with the index
28       * @return Collection of OntologyTerm objects
29       */
30      List<JenaSearchResult> searchIndividuals( OntModel model, String queryString, int maxResults ) throws OntologySearchException;
31  
32      class JenaSearchResult {
33  
34          public final Resource result;
35          public final double score;
36  
37          JenaSearchResult( Resource result, double score ) {
38              this.result = result;
39              this.score = score;
40          }
41  
42          @Override
43          public String toString() {
44              return String.format( "%s score=%f", result, score );
45          }
46      }
47  }