本文整理汇总了Java中org.cleartk.ml.jar.GenericJarClassifierFactory类的典型用法代码示例。如果您正苦于以下问题:Java GenericJarClassifierFactory类的具体用法?Java GenericJarClassifierFactory怎么用?Java GenericJarClassifierFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GenericJarClassifierFactory类属于org.cleartk.ml.jar包,在下文中一共展示了GenericJarClassifierFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: classifyTestFile
import org.cleartk.ml.jar.GenericJarClassifierFactory; //导入依赖的package包/类
public static void classifyTestFile(String modelDirectory, File testPosFile, String language)
throws ResourceInitializationException, UIMAException, IOException {
CollectionReader testPosFileReader = FilesCollectionReader.getCollectionReaderWithSuffixes(testPosFile.getAbsolutePath(),
NERReader.CONLL_VIEW, testPosFile.getName());
AnalysisEngine nerReader = createEngine(NERReader.class);
AnalysisEngine snowballStemmer = createEngine(SnowballStemmer.class, SnowballStemmer.PARAM_LANGUAGE, language);
AnalysisEngine nerAnnotator = createEngine(NERAnnotator.class,
NERAnnotator.PARAM_FEATURE_EXTRACTION_FILE, "src/main/resources/feature/features.xml",
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH, modelDirectory + "model.jar");
AnalysisEngine nerWriter = createEngine(NERWriter.class,
NERWriter.PARAM_NULL_TYPE, "O",
NERWriter.PARAM_EXPECTED_ENTITY_TYPE_NUM, 9,
NERWriter.PARAM_FILENAME, "src/test/resources/evaluation/eval.txt",
NERWriter.PARAM_VERBOSE, true);
runPipeline(
testPosFileReader,
nerReader,
snowballStemmer,
nerAnnotator,
nerWriter);
}
开发者ID:floschne,项目名称:NLP_ProjectNER,代码行数:26,代码来源:ExecuteNER.java
示例2: main
import org.cleartk.ml.jar.GenericJarClassifierFactory; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Options options = CliFactory.parseArguments(Options.class, args);
CollectionReader reader = UriCollectionReader.getCollectionReaderFromDirectory(options.getTestDirectory(),
UriCollectionReader.RejectSystemFiles.class, UriCollectionReader.RejectSystemDirectories.class);
AggregateBuilder builder = new AggregateBuilder();
builder.add(UriToDocumentTextAnnotator.getDescription());
builder.add(SentenceAnnotator.getDescription());
builder.add(TokenAnnotator.getDescription());
builder.add(PosTaggerAnnotator.getDescription());
builder.add(DefaultSnowballStemmer.getDescription("English"));
builder.add(AnalysisEngineFactory.createEngineDescription(QuestionCategoryAnnotator.class,
CleartkAnnotator.PARAM_IS_TRAINING, false, GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
JarClassifierBuilder.getModelJarFile(options.getModelsDirectory())));
SimplePipeline.runPipeline(reader, builder.createAggregateDescription(),
AnalysisEngineFactory.createEngineDescription(PrintClassificationsAnnotator.class));
}
开发者ID:utk4rsh,项目名称:question-classifier,代码行数:17,代码来源:App.java
示例3: getEngineDescription
import org.cleartk.ml.jar.GenericJarClassifierFactory; //导入依赖的package包/类
public static AnalysisEngineDescription getEngineDescription(String genderModelUrl)
throws ResourceInitializationException {
String tmpView = "tmp:Dramatis Personae";
AggregateBuilder b = new AggregateBuilder();
b.add(AnalysisEngineFactory.createEngineDescription(PrepareClearTk.class, PrepareClearTk.PARAM_VIEW_NAME,
tmpView, PrepareClearTk.PARAM_ANNOTATION_TYPE, DramatisPersonae.class,
PrepareClearTk.PARAM_SUBANNOTATIONS, Arrays.asList(Figure.class, FigureType.class)));
b.add(AnalysisEngineFactory.createEngineDescription(BreakIteratorSegmenter.class,
BreakIteratorSegmenter.PARAM_WRITE_SENTENCE, false), CAS.NAME_DEFAULT_SOFA, tmpView);
b.add(AnalysisEngineFactory.createEngineDescription(ClearTkGenderAnnotator.class,
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH, genderModelUrl), CAS.NAME_DEFAULT_SOFA, tmpView);
b.add(AnalysisEngineFactory.createEngineDescription(MapBackFeature.class, MapBackFeature.PARAM_ANNOTATION_TYPE,
Figure.class, MapBackFeature.PARAM_VIEW_NAME, tmpView, MapBackFeature.PARAM_FEATURE_NAME, "Gender"));
return b.createAggregateDescription();
}
开发者ID:quadrama,项目名称:DramaNLP,代码行数:19,代码来源:ClearTkGenderAnnotator.java
示例4: classifyTestFile
import org.cleartk.ml.jar.GenericJarClassifierFactory; //导入依赖的package包/类
public static void classifyTestFile(File aClassifierJarPath, File testPosFile, File outputFile,
File aNodeResultFile, List<Integer> aSentencesIds, String dataZipFile)
throws UIMAException, IOException
{
runPipeline(
FilesCollectionReader.getCollectionReaderWithSuffixes(testPosFile.getAbsolutePath(),
NERReader.CONLL_VIEW, testPosFile.getName()),
createEngine(NERReader.class, NERReader.DATA_ZIP_FILE, dataZipFile),
createEngine(NERAnnotator.class, NERAnnotator.PARAM_FEATURE_EXTRACTION_FILE,
aClassifierJarPath.getAbsolutePath() + "/feature.xml",
NERAnnotator.FEATURE_FILE, aClassifierJarPath.getAbsolutePath(),
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
aClassifierJarPath.getAbsolutePath() + "/model.jar"),
createEngine(EvaluatedNERWriter.class, EvaluatedNERWriter.OUTPUT_FILE, outputFile,
EvaluatedNERWriter.IS_GOLD, false, EvaluatedNERWriter.NOD_OUTPUT_FILE,
aNodeResultFile, EvaluatedNERWriter.SENTENCES_ID, aSentencesIds));
}
开发者ID:tudarmstadt-lt,项目名称:GermaNER,代码行数:18,代码来源:GermaNERMain.java
示例5: testAnnotatorDescriptor
import org.cleartk.ml.jar.GenericJarClassifierFactory; //导入依赖的package包/类
@Test
public void testAnnotatorDescriptor() throws Exception {
HideOutput hider = new HideOutput();
BuildTestExamplePosModel.main();
hider.restoreOutput();
String modelFileName = JarClassifierBuilder.getModelJarFile(
ExamplePosAnnotator.DEFAULT_OUTPUT_DIRECTORY).getPath();
AnalysisEngineDescription posTaggerDescription = ExamplePosAnnotator.getClassifierDescription(modelFileName);
AnalysisEngine engine = AnalysisEngineFactory.createEngine(posTaggerDescription);
Object classifierJar = engine.getConfigParameterValue(GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH);
Assert.assertEquals(modelFileName, classifierJar);
engine.collectionProcessComplete();
}
开发者ID:ClearTK,项目名称:cleartk,代码行数:17,代码来源:ExamplePosAnnotatorTest.java
示例6: buildExtractAggregate
import org.cleartk.ml.jar.GenericJarClassifierFactory; //导入依赖的package包/类
public AggregateBuilder buildExtractAggregate() throws ResourceInitializationException {
AggregateBuilder builder = new AggregateBuilder();
builder.add(AnalysisEngineFactory.createEngineDescription(
XMIReader.class,
XMIReader.PARAM_XMI_DIRECTORY,
this.xmiDirectory));
// This will extract the features for summarization
builder.add(AnalysisEngineFactory.createEngineDescription(
SumBasicAnnotator.class,
CleartkAnnotator.PARAM_IS_TRAINING,
false,
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
JarClassifierBuilder.getModelJarFile(this.modelDirectory),
SumBasicAnnotator.PARAM_TOKEN_FIELD,
this.tokenField.name(),
SumBasicAnnotator.PARAM_STOPWORDS_URI,
this.stopwordsFile.toURI()));
if (this.sentencesOutFile != null && this.outputSentences) {
builder.add(SummarySentenceWriterAnnotator.getDescription(sentencesOutFile, this.outputScores));
}
return builder;
}
开发者ID:ClearTK,项目名称:cleartk,代码行数:26,代码来源:SumBasic.java
示例7: CrfClassifier
import org.cleartk.ml.jar.GenericJarClassifierFactory; //导入依赖的package包/类
/**
* Constructor, creates an AnalysisEngine with a CRF classifier.
*/
public CrfClassifier(String configurationFile) {
try {
initialise(configurationFile);
classifier = createEngine(AspectAnnotator.class,
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
crfModelFolder + "model.jar");
} catch (ResourceInitializationException e) {
e.printStackTrace();
}
}
开发者ID:uhh-lt,项目名称:LT-ABSA,代码行数:15,代码来源:CrfClassifier.java
示例8: classifyTestFile
import org.cleartk.ml.jar.GenericJarClassifierFactory; //导入依赖的package包/类
private void classifyTestFile(File testPosFile, String language, String evaluationOutputFile, String featureExtractorConfigFile)
throws UIMAException, IOException {
CollectionReader testPosFileReader = FilesCollectionReader.getCollectionReaderWithSuffixes(testPosFile.getAbsolutePath(),
NERReader.CONLL_VIEW, testPosFile.getName());
AnalysisEngine nerReader = createEngine(NERReader.class);
AnalysisEngine snowballStemmer = createEngine(SnowballStemmer.class, SnowballStemmer.PARAM_LANGUAGE, language);
AnalysisEngine nerAnnotator = createEngine(NERAnnotator.class,
NERAnnotator.PARAM_FEATURE_EXTRACTION_FILE, FEATURE_EXTRACTOR_CONFIG_DIRECTORY + featureExtractorConfigFile,
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH, getModelDir() + "model.jar");
AnalysisEngine nerWriter = createEngine(NERWriter.class,
NERWriter.PARAM_NULL_TYPE, "O",
NERWriter.PARAM_EXPECTED_ENTITY_TYPE_NUM, 9,
NERWriter.PARAM_FILENAME, EVALUATION_OUTPUT_DIRECTORY + evaluationOutputFile,
NERWriter.PARAM_VERBOSE, false);
runPipeline(
testPosFileReader,
nerReader,
snowballStemmer,
nerAnnotator,
nerWriter);
}
开发者ID:floschne,项目名称:NLP_ProjectNER,代码行数:28,代码来源:ExecuteFeatureAblationTest.java
示例9: CrfClassifier
import org.cleartk.ml.jar.GenericJarClassifierFactory; //导入依赖的package包/类
/**
* Constructor, creates an AnalysisEngine with a CRF classifier.
* @param modelDirectory the directory where the model is located
*/
public CrfClassifier(String modelDirectory) {
try {
classifier = AnalysisEngineFactory.createEngine(AspectAnnotator.class,
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
modelDirectory + "model.jar");
} catch (ResourceInitializationException e) {
e.printStackTrace();
}
}
开发者ID:uhh-lt,项目名称:GermEval2017-Baseline,代码行数:14,代码来源:CrfClassifier.java
示例10: getClassifierDescription
import org.cleartk.ml.jar.GenericJarClassifierFactory; //导入依赖的package包/类
public static AnalysisEngineDescription getClassifierDescription(String modelFileName)
throws ResourceInitializationException {
return AnalysisEngineFactory.createEngineDescription(
ExamplePosAnnotator.class,
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
modelFileName);
}
开发者ID:ClearTK,项目名称:cleartk,代码行数:8,代码来源:ExamplePosAnnotator.java
示例11: main
import org.cleartk.ml.jar.GenericJarClassifierFactory; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Options options = CliFactory.parseArguments(Options.class, args);
// ////////////////////////////////////////
// Create collection reader to load URIs
// ////////////////////////////////////////
CollectionReader reader = UriCollectionReader.getCollectionReaderFromDirectory(
options.getTestDirectory(),
UriCollectionReader.RejectSystemFiles.class,
UriCollectionReader.RejectSystemDirectories.class);
// ////////////////////////////////////////
// Create document classification pipeline
// ////////////////////////////////////////
AggregateBuilder builder = new AggregateBuilder();
// Convert URIs in CAS URI View to Plain Text
builder.add(UriToDocumentTextAnnotator.getDescription());
// NLP pre-processing components
builder.add(SentenceAnnotator.getDescription()); // Sentence segmentation
builder.add(TokenAnnotator.getDescription()); // Tokenization
builder.add(DefaultSnowballStemmer.getDescription("English")); // Stemming
// Simple document classification annotator
builder.add(AnalysisEngineFactory.createEngineDescription(
BasicDocumentClassificationAnnotator.class,
CleartkAnnotator.PARAM_IS_TRAINING,
false,
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
JarClassifierBuilder.getModelJarFile(options.getModelsDirectory())));
// //////////////////////////////////////////////////////////////////////////////
// Run pipeline and classify documents
// //////////////////////////////////////////////////////////////////////////////
SimplePipeline.runPipeline(
reader,
builder.createAggregateDescription(),
AnalysisEngineFactory.createEngineDescription(PrintClassificationsAnnotator.class));
}
开发者ID:ClearTK,项目名称:cleartk,代码行数:41,代码来源:RunModel.java
示例12: getClassifierDescription
import org.cleartk.ml.jar.GenericJarClassifierFactory; //导入依赖的package包/类
public static AnalysisEngineDescription getClassifierDescription(File classifierJarFile)
throws ResourceInitializationException {
return AnalysisEngineFactory.createEngineDescription(
DocumentClassificationAnnotator.class,
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
classifierJarFile.toString());
}
开发者ID:ClearTK,项目名称:cleartk,代码行数:8,代码来源:DocumentClassificationAnnotator.java
示例13: main
import org.cleartk.ml.jar.GenericJarClassifierFactory; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Options options = CliFactory.parseArguments(Options.class, args);
// a reader that loads the URIs of the text file
CollectionReader reader = UriCollectionReader.getCollectionReaderFromFiles(Arrays.asList(options.getTextFile()));
// assemble the classification pipeline
AggregateBuilder aggregate = new AggregateBuilder();
// an annotator that loads the text from the training file URIs
aggregate.add(UriToDocumentTextAnnotator.getDescription());
// annotators that identify sentences, tokens and part-of-speech tags in the text
aggregate.add(SentenceAnnotator.getDescription());
aggregate.add(TokenAnnotator.getDescription());
aggregate.add(PosTaggerAnnotator.getDescription());
// our NamedEntityChunker annotator, configured to classify on the new texts
aggregate.add(AnalysisEngineFactory.createEngineDescription(
NamedEntityChunker.class,
CleartkSequenceAnnotator.PARAM_IS_TRAINING,
false,
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
JarClassifierBuilder.getModelJarFile(options.getModelDirectory())));
// a very simple annotator that just prints out any named entities we found
aggregate.add(AnalysisEngineFactory.createEngineDescription(PrintNamedEntityMentions.class));
// run the classification pipeline on the new texts
SimplePipeline.runPipeline(reader, aggregate.createAggregateDescription());
}
开发者ID:ClearTK,项目名称:cleartk,代码行数:32,代码来源:RunNamedEntityChunker.java
示例14: getAnnotatorDescription
import org.cleartk.ml.jar.GenericJarClassifierFactory; //导入依赖的package包/类
public AnalysisEngineDescription getAnnotatorDescription(File directory, Model.Params params)
throws ResourceInitializationException {
return AnalysisEngineFactory.createEngineDescription(
this.annotatorClass,
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
JarClassifierBuilder.getModelJarFile(this.getModelDirectory(directory, params)));
}
开发者ID:ClearTK,项目名称:cleartk,代码行数:8,代码来源:Model.java
示例15: getAnnotatorDescription
import org.cleartk.ml.jar.GenericJarClassifierFactory; //导入依赖的package包/类
public AnalysisEngineDescription getAnnotatorDescription(String modelFileName)
throws ResourceInitializationException {
AnalysisEngineDescription desc = getBaseDescription();
ResourceCreationSpecifierFactory.setConfigurationParameters(
desc,
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
modelFileName);
return desc;
}
开发者ID:ClearTK,项目名称:cleartk,代码行数:10,代码来源:CleartkInternalModelFactory.java
示例16: getClassifier
import org.cleartk.ml.jar.GenericJarClassifierFactory; //导入依赖的package包/类
/**
* Gets the classifier associated with name. If it does not exist, this method will use the
* {@link ClassifierFactory} specified at initialization to create a new one.
*
* @param name
* The name of the classifier
* @return The classifier associated with the name
*/
protected Classifier<OUTCOME_TYPE> getClassifier(String name)
throws ResourceInitializationException {
if (classifiers.containsKey(name)) {
return classifiers.get(name);
}
File classifierJarPath = new File(this.classifierJarPathRoot, name);
UimaContextAdmin contextAdmin = (UimaContextAdmin) this.uimaContext;
ConfigurationManager manager = contextAdmin.getConfigurationManager();
manager.setConfigParameterValue(contextAdmin.getQualifiedContextName()
+ GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH, classifierJarPath.getPath());
// create the factory and instantiate the classifier
ClassifierFactory<?> factory = InitializableFactory.create(
uimaContext,
classifierFactoryClassName,
ClassifierFactory.class);
Classifier<?> untypedClassifier;
try {
untypedClassifier = factory.createClassifier();
} catch (IOException e) {
throw new ResourceInitializationException(e);
}
Classifier<OUTCOME_TYPE> classifier = ReflectionUtil.uncheckedCast(untypedClassifier);
ReflectionUtil.checkTypeParameterIsAssignable(
CleartkMultiAnnotator.class,
"OUTCOME_TYPE",
this,
Classifier.class,
"OUTCOME_TYPE",
classifier);
InitializableFactory.initialize(untypedClassifier, this.getContext());
this.classifiers.put(name, classifier);
return classifier;
}
开发者ID:ClearTK,项目名称:cleartk,代码行数:45,代码来源:CleartkMultiAnnotator.java
示例17: testJarClassifierFactory
import org.cleartk.ml.jar.GenericJarClassifierFactory; //导入依赖的package包/类
@Test
public void testJarClassifierFactory() throws Exception {
JarClassifierFactory<String> factory = new JarClassifierFactory<String>();
// train and package a simple classifier
MostFrequentStringDataWriter writer = new MostFrequentStringDataWriter(this.outputDirectory);
writer.write(new Instance<String>("X"));
writer.finish();
MostFrequentStringClassifierBuilder builder = writer.getClassifierBuilder();
builder.trainClassifier(this.outputDirectory);
builder.packageClassifier(this.outputDirectory);
// move the classifier to the classpath
File modelDir = new File("target/test-classes");
File modelFile = JarClassifierBuilder.getModelJarFile(modelDir);
File outputModelFile = JarClassifierBuilder.getModelJarFile(this.outputDirectory);
FileUtils.moveFile(outputModelFile, modelFile);
// test File
factory.initialize(UimaContextFactory.createUimaContext(
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
modelFile));
factory.createClassifier();
// test URI
factory.initialize(UimaContextFactory.createUimaContext(
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
modelFile.toURI()));
factory.createClassifier();
// test classpath
factory.initialize(UimaContextFactory.createUimaContext(
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
"/model.jar"));
factory.createClassifier();
Assert.assertTrue(modelFile.delete());
}
开发者ID:ClearTK,项目名称:cleartk,代码行数:39,代码来源:ClassifierFactoryTest.java
示例18: testBadFileName
import org.cleartk.ml.jar.GenericJarClassifierFactory; //导入依赖的package包/类
@Test
public void testBadFileName() throws Throwable {
try {
CleartkAnnotator<String> classifierAnnotator = new StringTestAnnotator();
classifierAnnotator.initialize(UimaContextFactory.createUimaContext(
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
new File(outputDirectoryName, "asdf.jar").getPath()));
classifierAnnotator.classifier.classify(InstanceFactory.createInstance("hello", 1, 1).getFeatures());
fail("expected exception for invalid classifier name");
} catch (ResourceInitializationException e) {
}
}
开发者ID:ClearTK,项目名称:cleartk,代码行数:13,代码来源:CleartkAnnotatorTest.java
示例19: testBadFileName
import org.cleartk.ml.jar.GenericJarClassifierFactory; //导入依赖的package包/类
@Test
public void testBadFileName() throws Throwable {
try {
CleartkSequenceAnnotator<String> classifierAnnotator = new StringTestAnnotator();
classifierAnnotator.initialize(UimaContextFactory.createUimaContext(
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
new File(outputDirectoryName, "asdf.jar").getPath()));
classifierAnnotator.classify(Collections.singletonList(InstanceFactory.createInstance(
"hello",
1,
1)));
fail("expected exception for invalid classifier name");
} catch (ResourceInitializationException e) {
}
}
开发者ID:ClearTK,项目名称:cleartk,代码行数:16,代码来源:CleartkSequenceAnnotatorTest.java
示例20: testBadName
import org.cleartk.ml.jar.GenericJarClassifierFactory; //导入依赖的package包/类
@Test
public void testBadName() throws Throwable {
try {
StringTestAnnotator multiClassifierAnnotator = new StringTestAnnotator();
multiClassifierAnnotator.initialize(UimaContextFactory.createUimaContext(
GenericJarClassifierFactory.PARAM_CLASSIFIER_JAR_PATH,
outputDirectoryName));
multiClassifierAnnotator.getClassifier("asdf").classify(
InstanceFactory.createInstance("hello", 1, 1).getFeatures());
fail("expected exception for invalid classifier name");
} catch (ResourceInitializationException e) {
}
}
开发者ID:ClearTK,项目名称:cleartk,代码行数:14,代码来源:CleartkMultiAnnotatorTest.java
注:本文中的org.cleartk.ml.jar.GenericJarClassifierFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论