当前位置: 首页>>代码示例>>Java>>正文


Java VectorStoreWriter.writeVectors方法代码示例

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


在下文中一共展示了VectorStoreWriter.writeVectors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import pitt.search.semanticvectors.VectorStoreWriter; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
  FlagConfig flagConfig = null;
  try {
    flagConfig = FlagConfig.getFlagConfig(args);
    args = flagConfig.remainingArgs;
  } catch (IllegalArgumentException e) {
    System.err.println(usageMessage);
    throw e;
  }

  if (flagConfig.remainingArgs.length != 1) {
    throw new IllegalArgumentException("Wrong number of arguments after parsing command line flags.\n" + usageMessage);
  }

  VerbatimLogger.info("Building vector index of table in file: " + args[0] + "\n");
  BufferedReader fileReader = new BufferedReader(new FileReader(args[0]));
  String[] columnHeaders = fileReader.readLine().split(",");
  ArrayList<String[]> dataRows = new ArrayList<>();
  String dataLine;
  while((dataLine = fileReader.readLine()) != null) {
    String[] dataEntries = dataLine.split(",");
    if (dataEntries.length != columnHeaders.length) {
      throw new IllegalArgumentException(String.format(
          "Column headers have length %d and this row has length %d. This indicates a data error or a csv parsing error."
          + "\nColumn headers:%s\nData row: %s\n",
          columnHeaders.length, dataEntries.length,
          StringUtils.join(columnHeaders), StringUtils.join(dataEntries)));
    }
    dataRows.add(dataEntries);
  }
  fileReader.close();
  
  Table table = new Table(flagConfig, columnHeaders, dataRows);
  VectorStoreWriter.writeVectors(flagConfig.termvectorsfile(), flagConfig, table.getRowVectorStore());

  queryForSpecialValues(table);
  //queryForName(table, "J. Adams");
 // queryForName(table, "T. Roosevelt");
  
}
 
开发者ID:semanticvectors,项目名称:semanticvectors,代码行数:41,代码来源:TableIndexer.java

示例2: createNGrams

import pitt.search.semanticvectors.VectorStoreWriter; //导入方法依赖的package包/类
public void createNGrams(String fileOut, FlagConfig flagConfig, int numGrams )
{
	BeagleNGramVectors bngv;
	BeagleUtils utils = BeagleUtils.getInstance();

	long time;

	try
	{
		time = System.currentTimeMillis();

		bngv = new BeagleNGramVectors(
		    flagConfig, "index", 5, 2, new String[] {"contents"}, numGrams, "stoplist.txt");

		time = System.currentTimeMillis() - time;

		System.out.println("\nTime to process: " + time/1000 + " secs.");
		System.out.println("\nNumber of convolutions: " + utils.getNumConvolutions());

		VectorStoreWriter.writeVectors(
		    fileOut + "_" + flagConfig.dimension() + "_" + numGrams + ".bin", flagConfig, bngv);

		VectorStore indexVectors = bngv.getIndexVectors();
		VectorStoreWriter.writeVectors(
		    fileOut + "_" + flagConfig.dimension() + "_" + numGrams + "_index.bin", flagConfig, indexVectors);

		bngv = null;
		System.gc();
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
}
 
开发者ID:semanticvectors,项目名称:semanticvectors,代码行数:35,代码来源:BeagleTest.java

示例3: main

import pitt.search.semanticvectors.VectorStoreWriter; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
  FlagConfig flagConfig = null;
  try {
    flagConfig = FlagConfig.getFlagConfig(args);
    args = flagConfig.remainingArgs;
  } catch (IllegalArgumentException e) {
    System.err.println(usageMessage);
    throw e;
  }
  
  VerbatimLogger.info("Building vector index of table in file: " + args[0] + "\n");
  BufferedReader fileReader = new BufferedReader(new FileReader(args[0]));
  String[] columnHeaders = fileReader.readLine().split(",");
  ArrayList<String[]> dataRows = new ArrayList<>();
  String dataLine;
  while((dataLine = fileReader.readLine()) != null) {
    String[] dataEntries = dataLine.split(",");
    if (dataEntries.length != columnHeaders.length) {
      throw new IllegalArgumentException(String.format(
          "Column headers have length %d and this row has length %d. This indicates a data error or a csv parsing error."
          + "\nColumn headers:%s\nData row: %s\n",
          columnHeaders.length, dataEntries.length,
          StringUtils.join(columnHeaders), StringUtils.join(dataEntries)));
    }
    dataRows.add(dataEntries);
  }
  fileReader.close();
  
  Table table = new Table(flagConfig, columnHeaders, dataRows);
  VectorStoreWriter.writeVectors(flagConfig.termvectorsfile(), flagConfig, table.getRowVectorStore());
  queryForSpecialValues(table);
}
 
开发者ID:tuxdna,项目名称:semanticvectors-googlecode,代码行数:33,代码来源:TableIndexer.java


注:本文中的pitt.search.semanticvectors.VectorStoreWriter.writeVectors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。