Java Code Examples for pitt.search.semanticvectors.vectors.ZeroVectorException

The following examples show how to use pitt.search.semanticvectors.vectors.ZeroVectorException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: seldon-server   Source File: SemVectorsPeer.java    License: Apache License 2.0 6 votes vote down vote up
private LinkedList<SearchResult> search(String query,VectorStore queryStore,VectorStore searchStore,int numResults)
{
	 VectorSearcher vecSearcher;
	 LinkedList<SearchResult> results = new LinkedList<>();
	 try 
	 {
		 String[] queryTerms = query.split("\\s+");
		 vecSearcher =
	            new VectorSearcher.VectorSearcherCosine(queryStore,
	                                                    searchStore,
	                                                    luceneUtils,
	                                                    flagConfig,
	                                                    queryTerms);
		 results = vecSearcher.getNearestNeighbors(numResults);
		 
		 
	 } catch (pitt.search.semanticvectors.vectors.ZeroVectorException e) {
		 results = new LinkedList<>();

	}
	 return results;
}
 
Example 2
Source Project: seldon-server   Source File: SemVectorsPeer.java    License: Apache License 2.0 6 votes vote down vote up
private LinkedList<SearchResult> recommend(String query,VectorStore queryStore,VectorStore searchStore,int numResults,Set<String> exclusions,Set<String> inclusions,String minDoc)
{

	 LinkedList<SearchResult> results = new LinkedList<>();
	 try 
	 {
		 String[] queryTerms = query.split("\\s+");
		 VectorStoreRecommender vecSearcher =
	            new VectorStoreRecommender.VectorStoreRecommenderCosine(queryStore,
	                                                    searchStore,
	                                                    luceneUtils,
	                                                    queryTerms,
	                                                    exclusions,
	                                                    inclusions,
	                                                    minDoc);
		 results = vecSearcher.getNearestNeighbors(numResults);
		 
		 
	 } catch (ZeroVectorException zve) {
		 results = new LinkedList<>();
	 }
	 return results;
}
 
Example 3
Source Project: seldon-server   Source File: SemVectorsPeer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Find similar users by querying the docstore using a query from the terms passed in
 * @param <T>
 * @param terms
 * @param lUtils : lucene utils
 * @param numResults : max number of results to return
 * @param docResult : the result list of return ids T
 * @param docTransform : the transform from document to return id type T
 */
public <T extends Comparable<T>> void findSimilarUsersFromTerms(String[] terms,LuceneUtils lUtils,int numResults,ArrayList<SemVectorResult<T>> docResult,QueryTransform<T> docTransform)
{
	List<SearchResult> results;
	try 
	{
		VectorSearcher vecSearcher =
	            new VectorSearcher.VectorSearcherCosine(termVecReader,
	                                                    docVecReader,
	                                                    luceneUtils,
	                                                    flagConfig,
	                                                    terms);
		results = vecSearcher.getNearestNeighbors(numResults);
	} 
	catch (pitt.search.semanticvectors.vectors.ZeroVectorException e) {
		results = new LinkedList<>();
	}
	for(SearchResult r : results)
	{
		String filename = r.getObjectVector().getObject().toString();
		
		docResult.add(new SemVectorResult<>(docTransform.fromSV(filename),r.getScore()));
	}
}
 
Example 4
Source Project: seldon-server   Source File: VectorStoreRecommender.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @param queryVecStore Vector store to use for query generation.
 * @param searchVecStore The vector store to search.
 * @param luceneUtils LuceneUtils object to use for query weighting. (May be null.)
 * @param queryTerms Terms that will be parsed into a query
 * expression. If the string "NOT" appears, terms after this will be negated.
 */
public VectorStoreRecommenderCosine(VectorStore queryVecStore,
                            VectorStore searchVecStore,
                            LuceneUtils luceneUtils,
                            String[] queryTerms,
                            Set<String> exclusions,
                            Set<String> inclusions,
                            String minDoc)
    throws ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, exclusions,inclusions,minDoc);
  this.queryVector = CompoundVectorBuilder.getQueryVector(queryVecStore,
                                                          luceneUtils,
                                                          FlagConfig.getFlagConfig(null),
                                                          queryTerms);
  if (this.queryVector.isZeroVector()) {
    throw new ZeroVectorException("Query vector is zero ... no results.");
  }
}
 
Example 5
Source Project: seldon-server   Source File: SemanticVectorsStore.java    License: Apache License 2.0 6 votes vote down vote up
private LinkedList<SearchResult> search(String query,VectorStore queryStore,VectorStore searchStore,int numResults)
{
	 VectorSearcher vecSearcher;
	 LinkedList<SearchResult> results = new LinkedList<>();
	 try 
	 {
		 String[] queryTerms = query.split("\\s+");
		 vecSearcher =
	            new VectorSearcher.VectorSearcherCosine(queryStore,
	                                                    searchStore,
	                                                    luceneUtils,
	                                                    flagConfig,
	                                                    queryTerms);
		 results = vecSearcher.getNearestNeighbors(numResults);
		 
		 
	 } catch (pitt.search.semanticvectors.vectors.ZeroVectorException e) {
		 results = new LinkedList<>();

	}
	 return results;
}
 
Example 6
Source Project: seldon-server   Source File: SemanticVectorsStore.java    License: Apache License 2.0 6 votes vote down vote up
private LinkedList<SearchResult> recommend(String query,VectorStore queryStore,VectorStore searchStore,int numResults,Set<String> exclusions,Set<String> inclusions,String minDoc)
{

	 LinkedList<SearchResult> results = new LinkedList<>();
	 try 
	 {
		 String[] queryTerms = query.split("\\s+");
		 VectorStoreRecommender vecSearcher =
	            new VectorStoreRecommender.VectorStoreRecommenderCosine(queryStore,
	                                                    searchStore,
	                                                    luceneUtils,
	                                                    queryTerms,
	                                                    exclusions,
	                                                    inclusions,
	                                                    minDoc);
		 results = vecSearcher.getNearestNeighbors(numResults);
		 
		 
	 } catch (ZeroVectorException e) {
		 results = new LinkedList<>();
	}
	 finally{}
	 return results;
}
 
Example 7
Source Project: seldon-server   Source File: SemanticVectorsStore.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Find similar users by querying the docstore using a query from the terms passed in
 * @param <T>
 * @param terms
 * @param lUtils : lucene utils
 * @param numResults : max number of results to return
 * @param docResult : the result list of return ids T
 * @param docTransform : the transform from document to return id type T
 */
public <T extends Comparable<T>> void findSimilarUsersFromTerms(String[] terms,LuceneUtils lUtils,int numResults,ArrayList<SemVectorResult<T>> docResult,QueryTransform<T> docTransform)
{
	List<SearchResult> results;
	try 
	{
		VectorSearcher vecSearcher =
	            new VectorSearcher.VectorSearcherCosine(termVecReader,
	                                                    docVecReader,
	                                                    luceneUtils,
	                                                    flagConfig,
	                                                    terms);
		results = vecSearcher.getNearestNeighbors(numResults);
	} 
	catch (pitt.search.semanticvectors.vectors.ZeroVectorException e) {
		results = new LinkedList<>();
	}
	for(SearchResult r : results)
	{
		String filename = r.getObjectVector().getObject().toString();
		
		docResult.add(new SemVectorResult<>(docTransform.fromSV(filename),r.getScore()));
	}
}
 
Example 8
public VectorSearcherBoundProduct(VectorStore queryVecStore, VectorStore boundVecStore,
    VectorStore searchVecStore, LuceneUtils luceneUtils, FlagConfig flagConfig, ArrayList<Vector> incomingVectors)
        throws ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);

  Vector theSuperposition = VectorFactory.createZeroVector(
      flagConfig.vectortype(), flagConfig.dimension());

  for (int q = 0; q < incomingVectors.size(); q++)
    theSuperposition.superpose(incomingVectors.get(q), 1, null);

  theSuperposition.normalize();
  this.queryVector = theSuperposition;

  if (this.queryVector.isZeroVector()) {
    throw new ZeroVectorException("Query vector is zero ... no results.");
  }
}
 
Example 9
/**
 * @param queryVecStore Vector store to use for query generation.
 * @param searchVecStore The vector store to search.
 * @param luceneUtils LuceneUtils object to use for query weighting. (May be null.)
 * @param queryTerms Terms that will be parsed and used to generate a query subspace.
 */
public VectorSearcherMaxSim(VectorStore queryVecStore,
    VectorStore searchVecStore,
    LuceneUtils luceneUtils,
    FlagConfig flagConfig,
    String[] queryTerms)
        throws ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);
  this.disjunctVectors = new ArrayList<Vector>();

  for (int i = 0; i < queryTerms.length; ++i) {
    // There may be compound disjuncts, e.g., "A NOT B" as a single argument.
    String[] tmpTerms = queryTerms[i].split("\\s");
    Vector tmpVector = CompoundVectorBuilder.getQueryVector(
        queryVecStore, luceneUtils, flagConfig, tmpTerms);

    if (tmpVector != null) {
      this.disjunctVectors.add(tmpVector);
    }
  }
  if (this.disjunctVectors.size() == 0) {
    throw new ZeroVectorException("No nonzero input vectors ... no results.");
  }
}
 
Example 10
/**
 * @param queryVecStore Vector store to use for query generation.
 * @param searchVecStore The vector store to search.
 * @param luceneUtils LuceneUtils object to use for query weighting. (May be null.)
 * @param queryTerms Terms that will be parsed and used to generate a query subspace.
 */
public VectorSearcherMaxSim(VectorStore queryVecStore,
    VectorStore searchVecStore,
    LuceneUtils luceneUtils,
    FlagConfig flagConfig,
    Vector[] queryTerms)
        throws ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);
  this.disjunctVectors = new ArrayList<Vector>();

  for (int i = 0; i < queryTerms.length; ++i) {
    // There may be compound disjuncts, e.g., "A NOT B" as a single argument.
    Vector tmpVector = queryTerms[i];

    if (tmpVector != null) {
      this.disjunctVectors.add(tmpVector);
    }
  }
  if (this.disjunctVectors.size() == 0) {
    throw new ZeroVectorException("No nonzero input vectors ... no results.");
  }
}
 
Example 11
/**
 * @param queryVecStore Vector store to use for query generation.
 * @param searchVecStore The vector store to search.
 * @param luceneUtils LuceneUtils object to use for query weighting. (May be null.)
 * @param queryTerms Terms that will be parsed and used to generate a query subspace.
 */
public VectorSearcherMinSim(VectorStore queryVecStore,
    VectorStore searchVecStore,
    LuceneUtils luceneUtils,
    FlagConfig flagConfig,
    String[] queryTerms)
        throws ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);
  this.disjunctVectors = new ArrayList<Vector>();

  for (int i = 0; i < queryTerms.length; ++i) {
    // There may be compound disjuncts, e.g., "A NOT B" as a single argument.
    String[] tmpTerms = queryTerms[i].split("\\s");
    Vector tmpVector = CompoundVectorBuilder.getQueryVector(
        queryVecStore, luceneUtils, flagConfig, tmpTerms);

    if (tmpVector != null) {
      this.disjunctVectors.add(tmpVector);
    }
  }
  if (this.disjunctVectors.size() == 0) {
    throw new ZeroVectorException("No nonzero input vectors ... no results.");
  }
}
 
Example 12
/**
 * @param queryVecStore Vector store to use for query generation.
 * @param searchVecStore The vector store to search.
 * @param luceneUtils LuceneUtils object to use for query weighting. (May be null.)
 * @param queryTerms Terms that will be parsed and used to generate a query subspace.
 */
public VectorSearcherMinSim(VectorStore queryVecStore,
    VectorStore searchVecStore,
    LuceneUtils luceneUtils,
    FlagConfig flagConfig,
    Vector[] queryTerms)
        throws ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);
  this.disjunctVectors = new ArrayList<Vector>();

  for (int i = 0; i < queryTerms.length; ++i) {
    // There may be compound disjuncts, e.g., "A NOT B" as a single argument.
    Vector tmpVector = queryTerms[i];

    if (tmpVector != null) {
      this.disjunctVectors.add(tmpVector);
    }
  }
  if (this.disjunctVectors.size() == 0) {
    throw new ZeroVectorException("No nonzero input vectors ... no results.");
  }
}
 
Example 13
/**
 * @param queryVecStore Vector store to use for query generation.
 * @param searchVecStore The vector store to search.
 * @param luceneUtils LuceneUtils object to use for query weighting. (May be null.)
 * @param queryTerms Terms that will be parsed into a query
 * expression. If the string "?" appears, terms best fitting into this position will be returned
 */
public VectorSearcherPerm(VectorStore queryVecStore,
    VectorStore searchVecStore,
    LuceneUtils luceneUtils,
    FlagConfig flagConfig,
    String[] queryTerms)
        throws IllegalArgumentException, ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);

  try {
    theAvg = pitt.search.semanticvectors.CompoundVectorBuilder.
        getPermutedQueryVector(queryVecStore, luceneUtils, flagConfig, queryTerms);
  } catch (IllegalArgumentException e) {
    logger.info("Couldn't create permutation VectorSearcher ...");
    throw e;
  }

  if (theAvg.isZeroVector()) {
    throw new ZeroVectorException("Permutation query vector is zero ... no results.");
  }
}
 
Example 14
/**
 * @param queryVecStore Vector store to use for query generation (this is also reversed).
 * @param searchVecStore The vector store to search (this is also reversed).
 * @param luceneUtils LuceneUtils object to use for query weighting. (May be null.)
 * @param queryTerms Terms that will be parsed into a query
 * expression. If the string "?" appears, terms best fitting into this position will be returned
 */
public BalancedVectorSearcherPerm(
    VectorStore queryVecStore, VectorStore searchVecStore, LuceneUtils luceneUtils,
    FlagConfig flagConfig, String[] queryTerms)
        throws IllegalArgumentException, ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);
  specialFlagConfig = flagConfig;
  specialLuceneUtils = luceneUtils;
  try {
    oneDirection = pitt.search.semanticvectors.CompoundVectorBuilder.
        getPermutedQueryVector(queryVecStore, luceneUtils, flagConfig, queryTerms);
    otherDirection = pitt.search.semanticvectors.CompoundVectorBuilder.
        getPermutedQueryVector(searchVecStore, luceneUtils, flagConfig, queryTerms);
  } catch (IllegalArgumentException e) {
    logger.info("Couldn't create balanced permutation VectorSearcher ...");
    throw e;
  }

  if (oneDirection.isZeroVector()) {
    throw new ZeroVectorException("Permutation query vector is zero ... no results.");
  }
}
 
Example 15
/**
  * Lucene search, no semantic vectors required
  * @param luceneUtils LuceneUtils object to use for query weighting. (May not be null.)
  * @param queryTerms Terms that will be parsed into a query expression
  */
 public VectorSearcherLucene(LuceneUtils luceneUtils,
     FlagConfig flagConfig, String[] queryTerms)
         throws IllegalArgumentException, ZeroVectorException {
   
  super(null, null, luceneUtils, flagConfig);
  this.specialLuceneUtils = luceneUtils;
  this.specialFlagConfig = flagConfig;
  Directory dir;
try {
	dir = FSDirectory.open(FileSystems.getDefault().getPath(flagConfig.luceneindexpath()));
	this.iSearcher = new IndexSearcher(DirectoryReader.open(dir));
    
	if (!flagConfig.elementalvectorfile().equals("elementalvectors"))
	{this.acceptableTerms = new VectorStoreRAM(flagConfig);
    acceptableTerms.initFromFile(flagConfig.elementalvectorfile());
	}
} catch (IOException e) {
	logger.info("Lucene index initialization failed: "+e.getMessage());
}
  
  this.queryTerms = queryTerms;
  
 }
 
Example 16
/**
 * Prints the nearest predicate for a particular flagConfig. (Please extend this comment!)
 *
 * @param flagConfig
 * @throws IOException
 */
public static void printNearestPredicate(FlagConfig flagConfig) throws IOException {
  VerbatimLogger.info("Printing predicate results.");
  Vector queryVector = VectorFactory.createZeroVector(flagConfig.vectortype(), flagConfig.dimension());
  VectorSearcher.VectorSearcherBoundProduct predicateFinder;
  try {
    predicateFinder = new VectorSearcher.VectorSearcherBoundProduct(
        VectorStoreReader.openVectorStore(flagConfig.semanticvectorfile(), flagConfig),
        VectorStoreReader.openVectorStore(flagConfig.boundvectorfile(), flagConfig),
        null, flagConfig, queryVector);
    List<SearchResult> bestPredicate = predicateFinder.getNearestNeighbors(1);
    if (bestPredicate.size() > 0) {
      String pred = bestPredicate.get(0).getObjectVector().getObject().toString();
      System.out.println(pred);
    }
  } catch (ZeroVectorException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
}
 
Example 17
/**
 * @param queryVecStore Vector store to use for query generation.
 * @param searchVecStore The vector store to search.
 * @param luceneUtils LuceneUtils object to use for query weighting. (May be null.)
 * @param queryTerms Terms that will be parsed into a query
 * expression. If the string "NOT" appears, terms after this will be negated.
 */
public VectorSearcherCosine(
    VectorStore queryVecStore, VectorStore searchVecStore,
    LuceneUtils luceneUtils, FlagConfig flagConfig, String[] queryTerms)
        throws ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);
  this.queryVector = CompoundVectorBuilder.getQueryVector(
      queryVecStore, luceneUtils, flagConfig, queryTerms);
  if (this.queryVector.isZeroVector()) {
    throw new ZeroVectorException("Query vector is zero ... no results.");
  }
}
 
Example 18
/**
 * @param queryVecStore Vector store to use for query generation.
 * @param searchVecStore The vector store to search.
 * @param luceneUtils LuceneUtils object to use for query weighting. (May be null.)
 * @param queryVector Vector representing query
 * expression. If the string "NOT" appears, terms after this will be negated.
 */
public VectorSearcherCosine(
    VectorStore queryVecStore, VectorStore searchVecStore,
    LuceneUtils luceneUtils, FlagConfig flagConfig, Vector queryVector)
        throws ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);
  this.queryVector = queryVector;
  Vector testVector = searchVecStore.getAllVectors().nextElement().getVector();
  IncompatibleVectorsException.checkVectorsCompatible(queryVector, testVector);
  if (this.queryVector.isZeroVector()) {
    throw new ZeroVectorException("Query vector is zero ... no results.");
  }
}
 
Example 19
public VectorSearcherBoundProduct(VectorStore queryVecStore, VectorStore boundVecStore,
    VectorStore searchVecStore, LuceneUtils luceneUtils, FlagConfig flagConfig, String term1, String term2)
        throws ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);

  this.queryVector = CompoundVectorBuilder.getQueryVectorFromString(queryVecStore, null, flagConfig, term1);

  queryVector.release(CompoundVectorBuilder.getBoundProductQueryVectorFromString(
      flagConfig, boundVecStore, term2));

  if (this.queryVector.isZeroVector()) {
    throw new ZeroVectorException("Query vector is zero ... no results.");
  }
}
 
Example 20
public VectorSearcherBoundProduct(VectorStore elementalVecStore, VectorStore semanticVecStore, VectorStore predicateVecStore,
    VectorStore searchVecStore, LuceneUtils luceneUtils, FlagConfig flagConfig, String term1)
        throws ZeroVectorException {
  super(semanticVecStore, searchVecStore, luceneUtils, flagConfig);

  this.queryVector = CompoundVectorBuilder.getBoundProductQueryVectorFromString(
      flagConfig, elementalVecStore, semanticVecStore, predicateVecStore, luceneUtils, term1);

  if (this.queryVector.isZeroVector()) {
    throw new ZeroVectorException("Query vector is zero ... no results.");
  }
}
 
Example 21
/**
 * @param queryVecStore Vector store to use for query generation.
 * @param searchVecStore The vector store to search.
 * @param luceneUtils LuceneUtils object to use for query weighting. (May be null.)
 * @param queryVector Vector representing query
 * expression. If the string "NOT" appears, terms after this will be negated.
 */
public VectorSearcherBoundProduct(VectorStore queryVecStore,
    VectorStore searchVecStore,
    LuceneUtils luceneUtils,
    FlagConfig flagConfig,
    Vector queryVector)
        throws ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);
  this.queryVector = queryVector;
  Vector testVector = searchVecStore.getAllVectors().nextElement().getVector();
  IncompatibleVectorsException.checkVectorsCompatible(queryVector, testVector);
  if (this.queryVector.isZeroVector()) {
    throw new ZeroVectorException("Query vector is zero ... no results.");
  }
}
 
Example 22
public VectorSearcherBoundProductSubSpace(VectorStore queryVecStore, VectorStore boundVecStore,
    VectorStore searchVecStore, LuceneUtils luceneUtils, FlagConfig flagConfig, String term1, String term2)
        throws ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);

  disjunctSpace = new ArrayList<Vector>();
  Vector queryVector = queryVecStore.getVector(term1).copy();

  if (queryVector.isZeroVector()) {
    throw new ZeroVectorException("Query vector is zero ... no results.");
  }

  this.disjunctSpace = CompoundVectorBuilder.getBoundProductQuerySubSpaceFromString(
      flagConfig, boundVecStore, queryVector, term2);
}
 
Example 23
public VectorSearcherBoundProductSubSpace(VectorStore elementalVecStore, VectorStore semanticVecStore, VectorStore predicateVecStore,
    VectorStore searchVecStore, LuceneUtils luceneUtils, FlagConfig flagConfig, String term1)
        throws ZeroVectorException {
  super(semanticVecStore, searchVecStore, luceneUtils, flagConfig);

  disjunctSpace = new ArrayList<Vector>();
  this.disjunctSpace = CompoundVectorBuilder.getBoundProductQuerySubspaceFromString(
      flagConfig, elementalVecStore, semanticVecStore, predicateVecStore, term1);

}
 
Example 24
public VectorSearcherBoundProductSubSpace(VectorStore queryVecStore, VectorStore boundVecStore,
    VectorStore searchVecStore, LuceneUtils luceneUtils, FlagConfig flagConfig, ArrayList<Vector> incomingDisjunctSpace)
        throws ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);

  this.disjunctSpace = incomingDisjunctSpace;
}
 
Example 25
public VectorSearcherBoundMinimum(VectorStore queryVecStore, VectorStore boundVecStore,
    VectorStore searchVecStore, LuceneUtils luceneUtils, FlagConfig flagConfig, String term1, String term2)
        throws ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);

  disjunctSpace = new ArrayList<Vector>();
  Vector queryVector = queryVecStore.getVector(term1).copy();

  if (queryVector.isZeroVector()) {
    throw new ZeroVectorException("Query vector is zero ... no results.");
  }

  this.disjunctSpace = CompoundVectorBuilder.getBoundProductQuerySubSpaceFromString(
      flagConfig, boundVecStore, queryVector, term2);
}
 
Example 26
public VectorSearcherBoundMinimum(VectorStore elementalVecStore, VectorStore semanticVecStore, VectorStore predicateVecStore, 
    VectorStore searchVecStore, LuceneUtils luceneUtils, FlagConfig flagConfig, String term1)
        throws ZeroVectorException {
  super(semanticVecStore, searchVecStore, luceneUtils, flagConfig);

 this.disjunctSpace =  CompoundVectorBuilder.getBoundProductQuerySubspaceFromString(flagConfig, elementalVecStore, semanticVecStore, predicateVecStore, term1);
}
 
Example 27
public VectorSearcherBoundMinimum(VectorStore queryVecStore, VectorStore boundVecStore,
    VectorStore searchVecStore, LuceneUtils luceneUtils, FlagConfig flagConfig, ArrayList<Vector> incomingDisjunctSpace)
        throws ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);

  this.disjunctSpace = incomingDisjunctSpace;
}
 
Example 28
public VectorSearcherIntersection(VectorStore elementalVecStore, VectorStore semanticVecStore, VectorStore predicateVecStore, 
    VectorStore searchVecStore, LuceneUtils luceneUtils, FlagConfig flagConfig, String term1)
        throws ZeroVectorException {
  super(semanticVecStore, searchVecStore, luceneUtils, flagConfig);
  
 this.intersection=CompoundVectorBuilder.getBoundProductQueryIntersectionFromString(flagConfig, elementalVecStore, semanticVecStore, predicateVecStore, luceneUtils, term1);   
}
 
Example 29
/**
 * @param queryVecStore Vector store to use for query generation.
 * @param searchVecStore The vector store to search.
 * @param luceneUtils LuceneUtils object to use for query weighting. (May be null.)
 * @param queryTerms Terms that will be parsed and used to generate a query subspace.
 */
public VectorSearcherSubspaceSim(VectorStore queryVecStore,
    VectorStore searchVecStore,
    LuceneUtils luceneUtils,
    FlagConfig flagConfig,
    String[] queryTerms)
        throws ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);
  this.disjunctSpace = new ArrayList<Vector>();
  this.vectorType = flagConfig.vectortype();
  
  for (int i = 0; i < queryTerms.length; ++i) {
    System.out.println("\t" + queryTerms[i]);
    // There may be compound disjuncts, e.g., "A NOT B" as a single argument.
    String[] tmpTerms = queryTerms[i].split("\\s");
    Vector tmpVector = CompoundVectorBuilder.getQueryVector(
        queryVecStore, luceneUtils, flagConfig, tmpTerms);
    if (tmpVector != null) {
      this.disjunctSpace.add(tmpVector);
    }
  }
  if (this.disjunctSpace.size() == 0) {
    throw new ZeroVectorException("No nonzero input vectors ... no results.");
  }
  if (!vectorType.equals(VectorType.BINARY))
    VectorUtils.orthogonalizeVectors(this.disjunctSpace);
  else BinaryVectorUtils.orthogonalizeVectors(this.disjunctSpace);
}
 
Example 30
/**
 * @param queryVecStore Vector store to use for query generation.
 * @param searchVecStore The vector store to search.
 * @param permutationCache The permutations
 * @param luceneUtils LuceneUtils object to use for query weighting. (May be null.)
 * @param queryTerms Terms that will be parsed into a query
 * expression. If the string "?" appears, terms best fitting into this position will be returned
 */
public VectorSearcherPerm(VectorStore queryVecStore,
    VectorStore searchVecStore,
    VectorStore permutationCache,
    LuceneUtils luceneUtils,
    FlagConfig flagConfig,
    String[] queryTerms)
        throws IllegalArgumentException, ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);

  try {
    String[] permStrings = queryTerms[1].split(":");
    Vector toSuperpose   = queryVecStore.getVector(queryTerms[0]).copy();
    
    for (String permString:permStrings)
    {
    	theAvg = VectorFactory.createZeroVector(flagConfig.vectortype(), flagConfig.dimension());
        int[] thePermutation = ((PermutationVector) permutationCache.getVector(permString)).getCoordinates();
    	theAvg.superpose(toSuperpose,1, thePermutation);
    	toSuperpose = theAvg.copy();
    }	    
    //int[] thePermutation2 = PermutationUtils.getInversePermutation(thePermutation);
    } catch (IllegalArgumentException e) {
    logger.info("Couldn't create permutation VectorSearcher ...");
    throw e;
  }

  if (theAvg.isZeroVector()) {
    throw new ZeroVectorException("Permutation query vector is zero ... no results.");
  }
}