本文整理汇总了Java中pitt.search.semanticvectors.LuceneUtils类的典型用法代码示例。如果您正苦于以下问题:Java LuceneUtils类的具体用法?Java LuceneUtils怎么用?Java LuceneUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LuceneUtils类属于pitt.search.semanticvectors包,在下文中一共展示了LuceneUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()));
}
}
示例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.");
}
}
示例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.");
}
}
示例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);
}
示例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.");
}
}
示例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.");
}
}
示例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.");
}
}
示例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.");
}
}
示例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.");
}
}
示例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);
}
示例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;
}
示例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);
}
}
示例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.");
}
}
示例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);
}
示例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);
}