• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java VectorStoreReader类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中pitt.search.semanticvectors.VectorStoreReader的典型用法代码示例。如果您正苦于以下问题:Java VectorStoreReader类的具体用法?Java VectorStoreReader怎么用?Java VectorStoreReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

VectorStoreReader类属于pitt.search.semanticvectors包,在下文中一共展示了VectorStoreReader类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: printNearestPredicate

点赞 3

import pitt.search.semanticvectors.VectorStoreReader; //导入依赖的package包/类
/**
 * 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();
  }
}
 

开发者ID:semanticvectors,
项目名称:semanticvectors,
代码行数:26,
代码来源:PsiUtils.java

示例2: SemanticVectorSearcher

点赞 3

import pitt.search.semanticvectors.VectorStoreReader; //导入依赖的package包/类
public SemanticVectorSearcher(Environment env) {
	super(env);

	try {
		// How to use SemanticVectors comes from their Wiki.
		// The search function takes many arguments, which are what we are
		// storing as fields here.
		fconfig = FlagConfig.getFlagConfig(
				new String[]{"-luceneindexpath", env.getConfOrDie("lucene_index"),
						"-docvectorsfile", "data/semanticvectors/docvectors.bin",
						"-termvectorsfile", "data/semanticvectors/termvectors.bin"});
		queryVecReader =
				VectorStoreReader.openVectorStore(
						fconfig.termvectorsfile(), fconfig);
		resultsVecReader =
				VectorStoreReader.openVectorStore(
						fconfig.docvectorsfile(), fconfig);
		luceneUtils = new LuceneUtils(fconfig); 
	} catch (IOException e) {
		e.printStackTrace();
	}
	
	Score.register("SEMVEC_RANK", -1, Merge.Mean);
	Score.register("SEMVEC_SCORE", -1, Merge.Mean);
	Score.register("SEMVEC_PRESENT", 0.0, Merge.Sum);
}
 

开发者ID:SeanTater,
项目名称:uncc2014watsonsim,
代码行数:27,
代码来源:SemanticVectorSearcher.java

示例3: openVectorStores

点赞 2

import pitt.search.semanticvectors.VectorStoreReader; //导入依赖的package包/类
private void openVectorStores(String termFileName,String docFilename)
{
	try 
	{
		if (!useRamStores)
		{
			termVecReader = VectorStoreReader.openVectorStore(termFileName,flagConfig);
			docVecReader = VectorStoreReader.openVectorStore(docFilename,flagConfig);
		}
		else
		{
			termVecReader = null;
			docVecReader = null;
			System.gc();
			VectorStoreRAM termRamReader = new VectorStoreRAM(flagConfig);
			termRamReader.initFromFile(termFileName);
			VectorStoreRAM docRamReader = new VectorStoreRAM(flagConfig);
			docRamReader.initFromFile(docFilename);
			termVecReader =  termRamReader;
			docVecReader = docRamReader;
		}
	} 
	catch (Exception e) 
	{
		logger.error("Failed to load semantic vectors stores",e);
		throw new APIException(APIException.CANT_LOAD_CONTENT_MODEL);
	}
	
	
}
 

开发者ID:SeldonIO,
项目名称:seldon-server,
代码行数:31,
代码来源:SemVectorsPeer.java

示例4: testQuery

点赞 2

import pitt.search.semanticvectors.VectorStoreReader; //导入依赖的package包/类
public void testQuery(FlagConfig flagConfig, String searchfile, String indexfile, String query )
{
	VectorSearcher vs;
	LuceneUtils lUtils = null;
	CloseableVectorStore queryVecReader, searchVecReader;
	LinkedList<SearchResult> results;
	int numResults = 20;

	BeagleUtils utils = BeagleUtils.getInstance();
	utils.setFFTCacheSize(100);

	try
	{
		queryVecReader = VectorStoreReader.openVectorStore(indexfile, flagConfig);
		searchVecReader = VectorStoreReader.openVectorStore(searchfile, flagConfig);

		//BeagleCompoundVecBuilder bcb = new BeagleCompoundVecBuilder ();

		String[] queryTerms = query.split(" ");

		// Create VectorSearcher and search for nearest neighbors.
		vs = new BeagleVectorSearcher( queryVecReader, searchVecReader, lUtils, flagConfig, queryTerms);
		System.err.print("Searching term vectors, searchtype BEAGLE ... ");
		queryVecReader.close();
		searchVecReader.close();

		results = vs.getNearestNeighbors(numResults);

	}
	catch (Exception e)
	{
		System.err.println(e.getMessage());
		results = new LinkedList<SearchResult>();
	}

	// Print out results.
	if (results.size() > 0) {
		System.err.println("Search output follows ...\n");
		for (SearchResult result: results) {
			System.out.println(result.getScore() + ":" +
                                                  ((ObjectVector)result.getObjectVector()).getObject().toString());
		}
	} else {
		System.err.println("No search output.");
	}
}
 

开发者ID:semanticvectors,
项目名称:semanticvectors,
代码行数:47,
代码来源:BeagleTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)