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


Java Parameters类代码示例

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


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

示例1: getConstructor

import org.galagosearch.tupleflow.Parameters; //导入依赖的package包/类
public Constructor getConstructor() throws Exception {
    for (Constructor constructor : nodeClass.getConstructors()) {
        Class[] types = constructor.getParameterTypes();
     
        // The constructor needs at least one parameter.
        if (types.length < 1)
            continue;
        // The first class needs to be a Parameters object.
        if (!Parameters.class.isAssignableFrom(types[0]))
            continue;
        // Check arguments for valid argument types.
        boolean validTypes = true;
        for (int i = 1; i < types.length; ++i) {
            if (!isStructuredIteratorOrArray(types[i])) {
                validTypes = false;
                break;
            }
        }
        // If everything looks good, return this constructor.
        if (validTypes) {
            return constructor;
        }
    }
    
    throw new Exception("No reasonable constructors were found for " + nodeClass.toString());
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:27,代码来源:NodeType.java

示例2: store

import org.galagosearch.tupleflow.Parameters; //导入依赖的package包/类
public void store(Parameters p) {
    if (!p.containsKey("collectionLength")) {
        p.add("collectionLength", Long.toString(
                                                  getCollectionLength()));
    }
    if (!p.containsKey("averageDocumentLength")) {
        p.add("averageDocumentLength", Double.toString(
                                                       getAverageDocumentLength()));
    }
    if (!p.containsKey("termCount")) {
        p.add("termCount", Long.toString(getTermCount()));
    }
    if (!p.containsKey("documentCount")) {
        p.add("documentCount",
                                               Long.toString(getDocumentCount()));
    }
    if (!p.containsKey("collectionProbability")) {
        p.add("collectionProbability", Double.toString(
                                                       getCollectionProbability()));
    }
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:22,代码来源:StatisticsGatherer.java

示例3: getFeatureClassName

import org.galagosearch.tupleflow.Parameters; //导入依赖的package包/类
public String getFeatureClassName(Parameters parameters) throws Exception {
    if (parameters.containsKey("class")) {
        return parameters.get("class");
    }

    String name = parameters.get("name", parameters.get("default", (String) null));

    if (name == null) {
        throw new Exception(
                "Didn't find 'class', 'name', or 'default' parameter in this feature description.");
    }

    OperatorSpec operatorType = featureLookup.get(name);

    if (operatorType == null) {
        throw new Exception("Couldn't find a class for the feature named " + name + ".");
    }

    return operatorType.className;
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:21,代码来源:FeatureFactory.java

示例4: getIterator

import org.galagosearch.tupleflow.Parameters; //导入依赖的package包/类
/**
 * Given a query node, generates the corresponding iterator object that can be used
 * for structured retrieval.  This method just calls getClass() on the node,
 * then instantiates the resulting class.
 * 
 * If the class returned by getClass() is a ScoringFunction, it must contain
 * a constructor that takes a single Parameters object.  If the class returned by 
 * getFeatureClass() is some kind of StructuredIterator (either a ScoreIterator,
 * ExtentIterator or CountIterator), it must take a Parameters object and an
 * ArrayList of DocumentDataIterators as parameters.
 */
public StructuredIterator getIterator(Node node, ArrayList<StructuredIterator> childIterators) throws Exception {
    NodeType type = getNodeType(node);
    
    Constructor constructor = type.getConstructor();
    Class[] types = type.getParameterTypes(1 + childIterators.size());
        
    if (!isUsableConstructor(types, childIterators)) {
        throw new Exception("Couldn't find a reasonable constructor.");
    }
    
    Parameters parametersCopy = new Parameters();
    parametersCopy.copy(node.getParameters());
    Object[] args = argsForConstructor(constructor.getParameterTypes(),
                                       parametersCopy,
                                       childIterators);
    RequiredStatistics required =
        type.getIteratorClass().getAnnotation(RequiredStatistics.class);
    if (required != null) {
        for (String statistic : required.statistics()) {
            parametersCopy.add(statistic, parameters.get(statistic, null));
        }
    }
    return (StructuredIterator) constructor.newInstance(args);
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:36,代码来源:FeatureFactory.java

示例5: StructuredIndex

import org.galagosearch.tupleflow.Parameters; //导入依赖的package包/类
public StructuredIndex(String filename) throws IOException {
    manifest = new Parameters();
    manifest.parse(filename + File.separator + "manifest");
    documentLengths = new DocumentLengthsReader(filename + File.separator + "documentLengths");
    documentNames = new DocumentNameReader(filename + File.separator + "documentNames");

    File partsDirectory = new File(filename + File.separator + "parts");
    parts = new HashMap<String, StructuredIndexPartReader>();
    for (File part : partsDirectory.listFiles()) {
        StructuredIndexPartReader reader = openIndexPart(part.getAbsolutePath());
        if (reader == null) {
            continue;
        }
        parts.put(part.getName(), reader);
    }
    
    initializeIndexOperators();
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:19,代码来源:StructuredIndex.java

示例6: handleBuild

import org.galagosearch.tupleflow.Parameters; //导入依赖的package包/类
private static void handleBuild(String[] args) throws Exception {
    if (args.length <= 1) {
        commandHelpBuild();
        return;
    }

    // handle --links and --stemming flags
    String[][] filtered = Utility.filterFlags(Utility.subarray(args, 2));

    String[] flags = filtered[0];
    String[] docs = filtered[1];

    Parameters p = new Parameters(flags);
    boolean useLinks = p.get("links", false);
    boolean stemming = p.get("stemming", true);

    BuildIndex build = new BuildIndex();
    Job job = build.getIndexJob(args[1], docs, useLinks, stemming);
    ErrorStore store = new ErrorStore();
    JobExecutor.runLocally(job, store);
    if (store.hasStatements()) {
        System.out.println(store.toString());
    }
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:25,代码来源:App.java

示例7: handleSearch

import org.galagosearch.tupleflow.Parameters; //导入依赖的package包/类
private static void handleSearch(String[] args) throws Exception {
    if (args.length <= 1) {
        commandHelp("search");
        return;
    }

    String indexPath = args[1];
    String[][] filtered = Utility.filterFlags(Utility.subarray(args, 2));
    String[] flags = filtered[0];
    String[] corpusFiles = filtered[1];

    // Any flag marked '--parameters' marks a parameters file.
    // We trim that part of the flag off so that the Parameters object will
    // load it as a parameters file.
    for (int i = 0; i < flags.length; ++i) {
        flags[i] = flags[i].replace("--parameters=", "");
    }

    Parameters p = new Parameters(flags);
    Retrieval retrieval = Retrieval.instance(indexPath, p);
    handleSearch(retrieval, getDocumentStore(corpusFiles));
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:23,代码来源:App.java

示例8: getSplitStage

import org.galagosearch.tupleflow.Parameters; //导入依赖的package包/类
public Stage getSplitStage(String[] inputs) throws IOException {
    Stage stage = new Stage("inputSplit");
    stage.add(new StageConnectionPoint(ConnectionPointType.Output, "splits",
                                       new DocumentSplit.FileNameStartKeyOrder()));

    Parameters p = new Parameters();
    for (String input : inputs) {
        File inputFile = new File(input);
        
        if (inputFile.isFile()) {
            p.add("filename", input);
        } else if (inputFile.isDirectory()) {
            p.add("directory", input);
        } else {
            throw new IOException("Couldn't find file/directory: " + input);
        }
    }

    stage.add(new Step(DocumentSource.class, p));
    stage.add(Utility.getSorter(new DocumentSplit.FileNameStartKeyOrder()));
    stage.add(new OutputStep("splits"));
    return stage;
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:24,代码来源:BuildIndex.java

示例9: getLinkCombineStage

import org.galagosearch.tupleflow.Parameters; //导入依赖的package包/类
public Stage getLinkCombineStage() {
    Stage stage = new Stage("linkCombine");

    stage.add(new StageConnectionPoint(ConnectionPointType.Input, "documentUrls",
                                       new DocumentData.UrlOrder()));
    stage.add(new StageConnectionPoint(ConnectionPointType.Input, "links",
                                       new ExtractedLink.DestUrlOrder()));
    stage.add(new StageConnectionPoint(ConnectionPointType.Output, "anchorText",
                                       new AdditionalDocumentText.IdentifierOrder()));

    Parameters p = new Parameters();
    p.add("documentDatas", "documentUrls");
    p.add("extractedLinks", "links");
    stage.add(new Step(LinkCombiner.class, p));
    stage.add(new Step(AnchorTextCreator.class));
    stage.add(Utility.getSorter(new AdditionalDocumentText.IdentifierOrder()));
    stage.add(new OutputStep("anchorText"));

    return stage;
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:21,代码来源:BuildIndex.java

示例10: buildIndex

import org.galagosearch.tupleflow.Parameters; //导入依赖的package包/类
public void buildIndex() throws FileNotFoundException, IOException {
    File temporary = Utility.createTemporary();

    // Build an encoded document:
    document = new Document();
    document.identifier = "doc-identifier";
    document.text = "This is the text part.";
    document.metadata.put("Key", "Value");
    document.metadata.put("Something", "Else");
    
    Parameters parameters = new Parameters();
    parameters.add("filename", temporary.getAbsolutePath());
    DocumentIndexWriter writer = new DocumentIndexWriter(new FakeParameters(parameters));
    writer.process(document);
    writer.close();

    temporaryName = temporary.getAbsolutePath();
    assertTrue(IndexReader.isIndexFile(temporaryName));
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:20,代码来源:IndexReaderSplitParserTest.java

示例11: DirichletScorer

import org.galagosearch.tupleflow.Parameters; //导入依赖的package包/类
public DirichletScorer(Parameters parameters, CountIterator iterator) throws IOException {
    super(iterator);

    mu = parameters.get("mu", 1500);
    if (parameters.containsKey("collectionProbability")) {
        background = parameters.get("collectionProbability", 0.0001);
    } else {
        long collectionLength = parameters.get("collectionLength", (long)0);
        long count = 0;
        
        while (!iterator.isDone()) {
            count += iterator.count();
            iterator.nextDocument();
        }
        
        background = (double)count / (double)collectionLength;
        iterator.reset();
    }
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:20,代码来源:DirichletScorer.java

示例12: testHasMatch

import org.galagosearch.tupleflow.Parameters; //导入依赖的package包/类
public void testHasMatch() throws IOException {
    FakeScoreIterator one = new FakeScoreIterator(docsA, scoresA);
    FakeScoreIterator two = new FakeScoreIterator(docsB, scoresB);
    FakeScoreIterator[] iterators = { one, two };

    Parameters anyParameters = new Parameters();
    FilteredCombinationIterator instance = new FilteredCombinationIterator(anyParameters,
                                                                           iterators);

    assertFalse(instance.hasMatch(1));
    assertFalse(instance.hasMatch(2));
    assertFalse(instance.hasMatch(3));
    assertFalse(instance.hasMatch(10));

    instance.moveTo(10);
    assertTrue(instance.hasMatch(10));
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:18,代码来源:FilteredCombinationIteratorTest.java

示例13: testScore

import org.galagosearch.tupleflow.Parameters; //导入依赖的package包/类
public void testScore() throws IOException {
    FakeScoreIterator one = new FakeScoreIterator(docsA, scoresA);
    FakeScoreIterator two = new FakeScoreIterator(docsB, scoresB);
    FakeScoreIterator[] iterators = { one, two };

    Parameters anyParameters = new Parameters();
    ScoreCombinationIterator instance = new FilteredCombinationIterator(anyParameters, iterators);
    
    for (int i = 0; i < docsTogether.length; i++) {
        assertFalse(instance.isDone());
        instance.moveTo(docsTogether[i]);
        assertTrue(instance.hasMatch(docsTogether[i]));
        assertEquals(scoresTogether[i], instance.score(docsTogether[i], 100));

        instance.movePast(docsTogether[i]);
    }

    assertTrue(instance.isDone());
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:20,代码来源:FilteredCombinationIteratorTest.java

示例14: testNextCandidateAny

import org.galagosearch.tupleflow.Parameters; //导入依赖的package包/类
public void testNextCandidateAny() throws IOException {
    FakeScoreIterator one = new FakeScoreIterator(docsA, scoresA);
    FakeScoreIterator two = new FakeScoreIterator(docsB, scoresB);
    FakeScoreIterator[] iterators = { one, two };

    Parameters anyParameters = new Parameters();
    UnfilteredCombinationIterator instance = new UnfilteredCombinationIterator(anyParameters,
                                                                               iterators);

    assertEquals(2, instance.nextCandidate());
    instance.movePast(2);
    assertEquals(4, instance.nextCandidate());
    instance.movePast(4);
    assertEquals(5, instance.nextCandidate());
    instance.movePast(5);
    assertEquals(6, instance.nextCandidate());
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:18,代码来源:UnfilteredCombinationIteratorTest.java

示例15: testScore

import org.galagosearch.tupleflow.Parameters; //导入依赖的package包/类
public void testScore() throws IOException {
    FakeScoreIterator one = new FakeScoreIterator(docsA, scoresA);
    FakeScoreIterator two = new FakeScoreIterator(docsB, scoresB);
    FakeScoreIterator[] iterators = { one, two };

    Parameters anyParameters = new Parameters();
    UnfilteredCombinationIterator instance = new UnfilteredCombinationIterator(anyParameters,
                                                                               iterators);

    for (int i = 0; i < 12; i++) {
        assertFalse(instance.isDone());
        assertTrue(instance.hasMatch(docsTogether[i]));
        assertEquals(scoresTogether[i], instance.score(docsTogether[i], 100));

        instance.movePast(docsTogether[i]);
    }

    assertTrue(instance.isDone());
}
 
开发者ID:jjfiv,项目名称:galagosearch,代码行数:20,代码来源:UnfilteredCombinationIteratorTest.java


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