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


Java Pair类代码示例

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


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

示例1: main

import edu.cmu.lti.util.Pair; //导入依赖的package包/类
/**
 * Given a language pair and a test set filename, evaluates the classifier
 * for that language pair on the test set.
 * 
 * @param args command-line args: <languagePair> <testSetFileName>
 * @throws Exception
 */
public static void main (String[] args) throws Exception {
    if (args.length < 3 || args.length > 4 || (args.length == 3 && args[2].equals("--eval"))) {
        System.err.println("USAGE: QuestionClassifierFactory <questionLang> <corpusLang> (<questionFile> | --eval <goldStandardXmlFile>)\n");
        System.err.println(" - <questionLang> and <corpusLang> must be one of the following:");
        System.err.println("      en_US, ja_JP, jp_JP, zh_TW, zh_CN");
        System.err.println(" - Writes the result of classification for each input question to STDOUT");
        System.err.println("      if only a <questionFile> is given");
        System.err.println(" - Otherwise, writes classification accuracy to STDOUT if --eval and ");
        System.err.println("      a <goldStandardXmlFile> are given");
        System.err.println("   -- in this case, classification errors can be seen if logging ");
        System.err.println("        is set to DEBUG in conf/log4j.properties");
        System.exit(0);
    }
    
    QuestionClassifier classifier = QuestionClassifierFactory.getInstance(
            new Pair<Language,Language>(
                    Language.valueOf(args[0]),
                    Language.valueOf(args[1])));
    
    if (args.length == 3 && !args[2].equals("--eval"))
            classifier.classifySet(args[2]);
    else if (args.length == 4 && args[2].equals("--eval"))  
        classifier.evaluate(args[3]);
}
 
开发者ID:claritylab,项目名称:lucida,代码行数:32,代码来源:QuestionClassifierFactory.java

示例2: initialize

import edu.cmu.lti.util.Pair; //导入依赖的package包/类
@Override
public void initialize(UimaContext aContext)
		throws ResourceInitializationException {
	super.initialize(aContext);

	try {
		// Ephyra is going to need this...
		WordNetWrapper.initialize();

		// Question Classification initialization
		Language en_US = Language.valueOf("en_US");
		Pair<Language, Language> languagePair = new Pair<Language, Language>(en_US, en_US);
		qc = QuestionClassifierFactory.getInstance(languagePair);
		if (qc == null)
			throw new Exception("QuestionClassifier initialization failed");
	} catch (Exception e) {
		throw new ResourceInitializationException(e);
	}
}
 
开发者ID:brmson,项目名称:blanqa,代码行数:20,代码来源:EphyraAnswerTypeExtractor.java

示例3: getInstance

import edu.cmu.lti.util.Pair; //导入依赖的package包/类
/**
 * Returns a QuestionClassifier for the specified Language Pair. Configure which
 * QuestionClassifier is associated with each Language Pair in this class's properties 
 * file.
 */
public static QuestionClassifier getInstance(Pair<Language, Language> languagePair) throws Exception {
    QuestionClassifier classifier = null;
    Properties properties = propertyMap.get(languagePair.getFirst()+"_"+languagePair.getSecond());
    String classifierType = properties.getProperty("classifierType");
    if (classifierType == null) 
        throw new Exception("Required property classifierType is undefined for language pair "+languagePair);
    classifier = (QuestionClassifier)Class.forName(classifierType).newInstance();
    classifier.setLanguagePair(languagePair);
    classifier.initialize();
    return classifier;
}
 
开发者ID:claritylab,项目名称:lucida,代码行数:17,代码来源:QuestionClassifierFactory.java

示例4: main

import edu.cmu.lti.util.Pair; //导入依赖的package包/类
/**
 * Calls <code>runExperiment()</code> or <code>trainAndSave()</code>, depending
 * on whether the <code>--train</code> command-line argument is specified.  Also
 * requires two properties files as input arguments: one for specifying the experiments
 * to run and one for configuring  {@link info.ephyra.questionanalysis.atype.extractor.EnglishFeatureExtractor
 *   EnglishFeatureExtractor}
 * 
 * @param args input arguments: "[--train] &lt;Experimenter-properties&gt; &lt;qa.properties&gt;"
 * @throws Exception
 */
public static void main(String[] args) throws Exception {

    if (args.length != 1) {
        System.err.println("USAGE: Experimenter <questionLang> <corpusLang>");
        System.exit(0);
    }
    Pair<Language,Language> languagePair = new Pair<Language,Language>(
            Language.valueOf(args[0]),
            Language.valueOf(args[1]));
    Experimenter er = new Experimenter(languagePair);
    er.runExperiments();
}
 
开发者ID:claritylab,项目名称:lucida,代码行数:23,代码来源:Experimenter.java

示例5: Experimenter

import edu.cmu.lti.util.Pair; //导入依赖的package包/类
public Experimenter(Pair<Language,Language> languagePair) {
    this.languagePair = languagePair;
}
 
开发者ID:claritylab,项目名称:lucida,代码行数:4,代码来源:Experimenter.java

示例6: HierarchicalClassifierTrainer

import edu.cmu.lti.util.Pair; //导入依赖的package包/类
public HierarchicalClassifierTrainer(Pair<Language,Language> languagePair){
       this.languagePair = languagePair;
}
 
开发者ID:claritylab,项目名称:lucida,代码行数:4,代码来源:HierarchicalClassifierTrainer.java

示例7: main

import edu.cmu.lti.util.Pair; //导入依赖的package包/类
public static void main(String[] args)throws Exception{

        if (args.length > 3 || args.length < 2 || (args.length == 3 && !args[0].equals("--train"))) {
            System.err.println("Usage:");
            System.err.println("java HierarchicalClassifierTrainer [--train] <questionLang> <corpusLang>\n");
            System.err.println(" - <questionLang> and <corpusLang> must be one of the following:");
            System.err.println("     en_US, ja_JP, jp_JP, zh_TW, zh_CN");
            System.err.println(" - Outputs a trained model in the current directory if --train is used.");
            System.err.println(" - Otherwise, performs an evaluation using the configuration in the");
            System.err.println("     properties file and outputs a report describing the results.");
            System.exit(0);
        }
        
        boolean train = false;
        int langPairInd = 0;
        if (args[0].equals("--train")) {
            train = true;
            langPairInd++;
        }
        
        Pair<Language,Language> languagePair = new Pair<Language,Language>(
                Language.valueOf(args[langPairInd]),
                Language.valueOf(args[langPairInd+1]));
        
        HierarchicalClassifierTrainer qct=new HierarchicalClassifierTrainer(languagePair);
        qct.initialize();
        
        if (train) {
            System.out.println("Training classifier...");
            qct.trainClassifier();
            qct.saveClassifier();
            System.out.println("Classifier saved.");
        } else {
            System.out.println("Running experiment...");
            Evaluation eval=qct.runExperiment();
            FileUtil.writeFile(qct.createReport(),args[0]+".report"+System.currentTimeMillis()+".txt","UTF-8");

            ViewerFrame frame=new ViewerFrame(args[0],eval.toGUI());
            frame.setVisible(true);
        }

    }
 
开发者ID:claritylab,项目名称:lucida,代码行数:43,代码来源:HierarchicalClassifierTrainer.java

示例8: setLanguagePair

import edu.cmu.lti.util.Pair; //导入依赖的package包/类
/**
 * @param languagePair the languagePair to set
 */
public void setLanguagePair(Pair<Language,Language> languagePair) {
    this.languagePair = languagePair;
}
 
开发者ID:claritylab,项目名称:lucida,代码行数:7,代码来源:QuestionClassifier.java

示例9: getLanguagePair

import edu.cmu.lti.util.Pair; //导入依赖的package包/类
/**
 * @return the languagePair
 */
public Pair<Language,Language> getLanguagePair() {
    return this.languagePair;
}
 
开发者ID:claritylab,项目名称:lucida,代码行数:7,代码来源:QuestionClassifier.java


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