it.unimi.di.mg4j.scratch
Class GraphFromQuery

java.lang.Object
  extended by it.unimi.di.mg4j.scratch.GraphFromQuery

public class GraphFromQuery
extends Object

Solves a given query (in a boolean way), takes the resulting set of document pointers, and then produces a subgraph (of a given graph whose nodes represent document pointers) made of only the arcs stemming from a document in the result set.


Constructor Summary
GraphFromQuery(SimpleParser parser, Object2ReferenceLinkedOpenHashMap<String,Index> indexMap, ImmutableGraph graph, ImmutableGraph grapht, int maxIn, int maxOut, Random random)
          Creates an object ready for solving queries.
 
Method Summary
static SimpleParser getParser(Object2ReferenceLinkedOpenHashMap<String,Index> indexMap)
          Given an index map, creates and returns a parser.
static Object2ReferenceLinkedOpenHashMap<String,Index> loadIndices(String[] indexBasename)
          Loads a set of indices of given basenames, and returns a map from index aliases to indices.
static void main(String[] args)
           
 ImmutableGraph resolve(Query query)
          Solves a query and returns the corresponding graph.
 ImmutableGraph resolve(String queryString)
          Solves a query and returns the corresponding graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphFromQuery

public GraphFromQuery(SimpleParser parser,
                      Object2ReferenceLinkedOpenHashMap<String,Index> indexMap,
                      ImmutableGraph graph,
                      ImmutableGraph grapht,
                      int maxIn,
                      int maxOut,
                      Random random)
Creates an object ready for solving queries.

Parameters:
parser - the parser to be used when solving queries.
indexMap - the map from index alias to indices.
graph - the graph whence we are going to extract subgraphs.
grapht - the transpose graph, only needed if maxIn or maxOut are positive and finite.
maxIn - how many nodes should be taken (at most) from the in-neighborhood.
maxOut - how many nodes should be taken (at most) from the out-neighborhood.
random - the random number generator to be used for selecting neighbors.
Method Detail

resolve

public ImmutableGraph resolve(Query query)
                       throws QueryBuilderVisitorException,
                              IOException
Solves a query and returns the corresponding graph.

Parameters:
query - the query to be resolved.
Returns:
the subgraph obtained by taking only the results of the query plus, possibly, is out/in-neighbors.
Throws:
QueryBuilderVisitorException
IOException

resolve

public ImmutableGraph resolve(String queryString)
                       throws QueryParserException,
                              QueryBuilderVisitorException,
                              IOException
Solves a query and returns the corresponding graph.

Parameters:
queryString - the query to be resolved.
Returns:
the subgraph obtained by taking only the results of the query plus, possibly, is out/in-neighbors.
Throws:
QueryParserException
QueryBuilderVisitorException
IOException

loadIndices

public static Object2ReferenceLinkedOpenHashMap<String,Index> loadIndices(String[] indexBasename)
                                                                   throws ConfigurationException,
                                                                          SecurityException,
                                                                          IOException,
                                                                          URISyntaxException,
                                                                          ClassNotFoundException,
                                                                          InstantiationException,
                                                                          IllegalAccessException,
                                                                          InvocationTargetException,
                                                                          NoSuchMethodException
Loads a set of indices of given basenames, and returns a map from index aliases to indices.

Parameters:
indexBasename - the index basenames.
Returns:
the map from index alias to indices.
Throws:
ConfigurationException
SecurityException
IOException
URISyntaxException
ClassNotFoundException
InstantiationException
IllegalAccessException
InvocationTargetException
NoSuchMethodException

getParser

public static SimpleParser getParser(Object2ReferenceLinkedOpenHashMap<String,Index> indexMap)
Given an index map, creates and returns a parser.

Parameters:
indexMap - the map from index alias to indices.
Returns:
a parser.

main

public static void main(String[] args)
                 throws com.martiansoftware.jsap.JSAPException,
                        ConfigurationException,
                        SecurityException,
                        IOException,
                        URISyntaxException,
                        ClassNotFoundException,
                        InstantiationException,
                        IllegalAccessException,
                        InvocationTargetException,
                        NoSuchMethodException,
                        QueryBuilderVisitorException
Throws:
com.martiansoftware.jsap.JSAPException
ConfigurationException
SecurityException
IOException
URISyntaxException
ClassNotFoundException
InstantiationException
IllegalAccessException
InvocationTargetException
NoSuchMethodException
QueryBuilderVisitorException