本文整理汇总了Java中pitt.search.semanticvectors.LuceneUtils类的典型用法代码示例。如果您正苦于以下问题:Java LuceneUtils类的具体用法?Java LuceneUtils怎么用?Java LuceneUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LuceneUtils类属于pitt.search.semanticvectors包,在下文中一共展示了LuceneUtils类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: findSimilarUsersFromTerms
import pitt.search.semanticvectors.LuceneUtils; //导入依赖的package包/类
/**
* 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()));
}
}
开发者ID:SeldonIO,项目名称:seldon-server,代码行数:33,代码来源:SemVectorsPeer.java
示例2: VectorStoreRecommenderCosine
import pitt.search.semanticvectors.LuceneUtils; //导入依赖的package包/类
/**
* @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.");
}
}
开发者ID:SeldonIO,项目名称:seldon-server,代码行数:25,代码来源:VectorStoreRecommender.java
示例3: BeagleVectorSearcher
import pitt.search.semanticvectors.LuceneUtils; //导入依赖的package包/类
/**
* @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.
*/
public BeagleVectorSearcher(VectorStore queryVecStore, VectorStore searchVecStore,
LuceneUtils luceneUtils,
FlagConfig flagConfig,
String[] queryTerms)
throws ZeroVectorException
{
super(queryVecStore, searchVecStore, luceneUtils, flagConfig);
BeagleCompoundVecBuilder bcvb = new BeagleCompoundVecBuilder(flagConfig);
queryVector = new RealVector(bcvb.getNGramQueryVector(queryVecStore, queryTerms));
if (this.queryVector.isZeroVector()) {
throw new ZeroVectorException("Query vector is zero ... no results.");
}
}
开发者ID:semanticvectors,项目名称:semanticvectors,代码行数:23,代码来源:BeagleVectorSearcher.java
示例4: SemanticVectorSearcher
import pitt.search.semanticvectors.LuceneUtils; //导入依赖的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
示例5: VectorSearcherBoundProduct
import pitt.search.semanticvectors.LuceneUtils; //导入依赖的package包/类
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.");
}
}
开发者ID:tuxdna,项目名称:semanticvectors-googlecode,代码行数:19,代码来源:VectorSearcher.java
示例6: VectorSearcherMaxSim
import pitt.search.semanticvectors.LuceneUtils; //导入依赖的package包/类
/**
* @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.");
}
}
开发者ID:tuxdna,项目名称:semanticvectors-googlecode,代码行数:30,代码来源:VectorSearcher.java
示例7: VectorSearcherMinSim
import pitt.search.semanticvectors.LuceneUtils; //导入依赖的package包/类
/**
* @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.");
}
}
开发者ID:tuxdna,项目名称:semanticvectors-googlecode,代码行数:30,代码来源:VectorSearcher.java
示例8: VectorSearcherPerm
import pitt.search.semanticvectors.LuceneUtils; //导入依赖的package包/类
/**
* @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.");
}
}
开发者ID:tuxdna,项目名称:semanticvectors-googlecode,代码行数:28,代码来源:VectorSearcher.java
示例9: BalancedVectorSearcherPerm
import pitt.search.semanticvectors.LuceneUtils; //导入依赖的package包/类
/**
* @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.");
}
}
开发者ID:tuxdna,项目名称:semanticvectors-googlecode,代码行数:29,代码来源:VectorSearcher.java
示例10: VectorStorePredictor
import pitt.search.semanticvectors.LuceneUtils; //导入依赖的package包/类
public VectorStorePredictor(String queryTerm,
VectorStore queryVecStore,
VectorStore searchVecStore,
LuceneUtils luceneUtils)
{
this.queryVecStore = queryVecStore;
this.searchVecStore = searchVecStore;
this.luceneUtils = luceneUtils;
queryVector = CompoundVectorBuilder.getQueryVectorFromString(queryVecStore,
luceneUtils,
flagConfig,
queryTerm);
}
开发者ID:SeldonIO,项目名称:seldon-server,代码行数:15,代码来源:VectorStorePredictor.java
示例11: VectorStoreRecommender
import pitt.search.semanticvectors.LuceneUtils; //导入依赖的package包/类
/**
* Performs basic initialization; subclasses should normally call super() to use this.
* @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.)
*/
public VectorStoreRecommender(VectorStore queryVecStore,
VectorStore searchVecStore,
LuceneUtils luceneUtils,
Set<String> exclusions,
Set<String> inclusions,
String minDoc) {
this.queryVecStore = queryVecStore;
this.searchVecStore = searchVecStore;
this.luceneUtils = luceneUtils;
this.exclusions = exclusions;
this.inclusions = inclusions;
this.minDoc = minDoc;
}
开发者ID:SeldonIO,项目名称:seldon-server,代码行数:20,代码来源:VectorStoreRecommender.java
示例12: VectorSearcher
import pitt.search.semanticvectors.LuceneUtils; //导入依赖的package包/类
/**
* Performs basic initialization; subclasses should normally call super() to use this.
* @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 flagConfig Flag configuration (cannot be null).
*/
public VectorSearcher(VectorStore queryVecStore, VectorStore searchVecStore,
LuceneUtils luceneUtils, FlagConfig flagConfig) {
this.flagConfig = flagConfig;
this.searchVecStore = searchVecStore;
this.luceneUtils = luceneUtils;
if (flagConfig.expandsearchspace()) {
this.searchVecStore = expandSearchSpace(searchVecStore, flagConfig);
}
}
开发者ID:tuxdna,项目名称:semanticvectors-googlecode,代码行数:17,代码来源:VectorSearcher.java
示例13: VectorSearcherCosine
import pitt.search.semanticvectors.LuceneUtils; //导入依赖的package包/类
/**
* @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.");
}
}
开发者ID:tuxdna,项目名称:semanticvectors-googlecode,代码行数:19,代码来源:VectorSearcher.java
示例14: VectorSearcherBoundProductSubSpace
import pitt.search.semanticvectors.LuceneUtils; //导入依赖的package包/类
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);
}
开发者ID:tuxdna,项目名称:semanticvectors-googlecode,代码行数:16,代码来源:VectorSearcher.java
示例15: VectorSearcherBoundMinimum
import pitt.search.semanticvectors.LuceneUtils; //导入依赖的package包/类
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);
}
开发者ID:tuxdna,项目名称:semanticvectors-googlecode,代码行数:16,代码来源:VectorSearcher.java
示例16: VectorSearcherSubspaceSim
import pitt.search.semanticvectors.LuceneUtils; //导入依赖的package包/类
/**
* @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>();
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);
}
开发者ID:tuxdna,项目名称:semanticvectors-googlecode,代码行数:33,代码来源:VectorSearcher.java
示例17: AnalogySearcher
import pitt.search.semanticvectors.LuceneUtils; //导入依赖的package包/类
public AnalogySearcher(
VectorStore queryVecStore, VectorStore searchVecStore,
LuceneUtils luceneUtils, FlagConfig flagConfig, String[] queryTriple) {
super(queryVecStore, searchVecStore, luceneUtils, flagConfig);
Vector term0 = CompoundVectorBuilder.getQueryVectorFromString(queryVecStore, luceneUtils, flagConfig, queryTriple[0]);
Vector term1 = CompoundVectorBuilder.getQueryVectorFromString(queryVecStore, luceneUtils, flagConfig, queryTriple[1]);
Vector term2 = CompoundVectorBuilder.getQueryVectorFromString(queryVecStore, luceneUtils, flagConfig, queryTriple[2]);
Vector relationVec = term0.copy();
relationVec.bind(term1);
this.queryVector = term2.copy();
this.queryVector.release(relationVec);
}
开发者ID:tuxdna,项目名称:semanticvectors-googlecode,代码行数:13,代码来源:VectorSearcher.java
示例18: getDocAvgTermFreqs
import pitt.search.semanticvectors.LuceneUtils; //导入依赖的package包/类
public void getDocAvgTermFreqs() throws IOException
{
BufferedWriter fileWriter = new BufferedWriter(new FileWriter(resultsFile));
//Map<Integer,String> idMap = new HashMap<Integer,String>();
FlagConfig config = FlagConfig.getFlagConfig(new String[] {"-luceneindexpath",luceneIndex});
LuceneUtils lu = new LuceneUtils(config);
TermsEnum termEnum = null;
TermsEnum terms = lu.getTermsForField("contents").iterator(termEnum);
BytesRef bytes;
int tc = 0;
Map<String,TermSum> docStats = new HashMap<String, TermSum>();
while ((bytes = terms.next()) != null)
{
if (( tc % 10000 == 0 ) || ( tc < 10000 && tc % 1000 == 0 )) {
System.out.println("Processed " + tc + " terms ... ");
}
tc++;
Term term = new Term("contents", bytes);
//fileWriter.write(term.text()+"\n");
//String token = term.text();
int termfreq = lu.getGlobalTermFreq(term);
DocsEnum docsEnum = lu.getDocsForTerm(term);
while (docsEnum.nextDoc() != DocsEnum.NO_MORE_DOCS)
{
String docName = lu.getDoc(docsEnum.docID()).getField(config.docidfield()).stringValue();
TermSum stats = docStats.get(docName);
if (stats == null)
stats = new TermSum();
stats.sum += termfreq;
stats.terms += 1;
docStats.put(docName, stats);
}
}
System.out.println("Output results to file");
for(Map.Entry<String, TermSum> e : docStats.entrySet())
{
float avg = e.getValue().sum/(float)e.getValue().terms;
fileWriter.write(""+e.getKey()+","+avg+"\n");
}
fileWriter.close();
}
开发者ID:SeldonIO,项目名称:semantic-vectors-lucene-tools,代码行数:44,代码来源:GetAvgTermFreq.java
示例19: testQuery
import pitt.search.semanticvectors.LuceneUtils; //导入依赖的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
注:本文中的pitt.search.semanticvectors.LuceneUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论