本文整理汇总了Java中se.lth.cs.srl.pipeline.Pipeline类的典型用法代码示例。如果您正苦于以下问题:Java Pipeline类的具体用法?Java Pipeline怎么用?Java Pipeline使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Pipeline类属于se.lth.cs.srl.pipeline包,在下文中一共展示了Pipeline类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCompletePipeline
import se.lth.cs.srl.pipeline.Pipeline; //导入依赖的package包/类
public static CompletePipeline getCompletePipeline(FullPipelineOptions options) throws ZipException, IOException, ClassNotFoundException{
Preprocessor pp=Language.getLanguage().getPreprocessor(options);
Parse.parseOptions=options.getParseOptions();
SemanticRoleLabeler srl;
if(options.reranker){
srl=new Reranker(Parse.parseOptions);
} else {
ZipFile zipFile=new ZipFile(Parse.parseOptions.modelFile);
if(Parse.parseOptions.skipPI){
srl=Pipeline.fromZipFile(zipFile, new Step[]{Step.pd,Step.ai,Step.ac});
} else {
srl=Pipeline.fromZipFile(zipFile);
}
zipFile.close();
}
CompletePipeline pipeline=new CompletePipeline(pp,srl);
return pipeline;
}
示例2: getCompletePipeline
import se.lth.cs.srl.pipeline.Pipeline; //导入依赖的package包/类
public static CompletePipeline getCompletePipeline(
FullPipelineOptions options) throws ZipException, IOException,
ClassNotFoundException {
Preprocessor pp = Language.getLanguage().getPreprocessor(options);
Parse.parseOptions = options.getParseOptions();
if(options.semaforserver!=null) {
Parse.parseOptions.skipPD = true;
Parse.parseOptions.skipPI = true;
}
SemanticRoleLabeler srl;
if (options.reranker) {
srl = new Reranker(Parse.parseOptions);
} else {
ZipFile zipFile = new ZipFile(Parse.parseOptions.modelFile);
if (Parse.parseOptions.skipPI) {
srl = Pipeline.fromZipFile(zipFile, new Step[] { Step.pd,
Step.ai, Step.ac });
} else {
srl = Pipeline.fromZipFile(zipFile);
}
zipFile.close();
}
CompletePipeline pipeline = new CompletePipeline(pp, srl);
return pipeline;
}
示例3: learn
import se.lth.cs.srl.pipeline.Pipeline; //导入依赖的package包/类
private static void learn() throws IOException {
ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(
new FileOutputStream(learnOptions.modelFile)));
if (learnOptions.trainReranker) {
new Reranker(learnOptions, zos);
} else {
BrownCluster bc = Learn.learnOptions.brownClusterFile == null ? null
: new BrownCluster(Learn.learnOptions.brownClusterFile);
WordEmbedding we = Learn.learnOptions.wordEmbeddingFile == null ? null
: new WordEmbedding(Learn.learnOptions.wordEmbeddingFile);
SentenceReader reader = new AllCoNLL09Reader(
learnOptions.inputCorpus);
Pipeline.trainNewPipeline(reader, learnOptions.getFeatureFiles(),
zos, bc, we);
}
zos.close();
}
示例4: main
import se.lth.cs.srl.pipeline.Pipeline; //导入依赖的package包/类
public static void main(String[] args) throws Exception{
long startTime=System.currentTimeMillis();
parseOptions=new ParseOptions(args);
SemanticRoleLabeler srl;
if(parseOptions.useReranker){
srl = new Reranker(parseOptions);
//srl = Reranker.fromZipFile(zipFile,parseOptions.skipPI,parseOptions.global_alfa,parseOptions.global_aiBeam,parseOptions.global_acBeam);
} else {
ZipFile zipFile=new ZipFile(parseOptions.modelFile);
srl = parseOptions.skipPI ? Pipeline.fromZipFile(zipFile,new Step[]{Step.pd,Step.ai,Step.ac}) : Pipeline.fromZipFile(zipFile);
zipFile.close();
}
SentenceWriter writer=new CoNLL09Writer(parseOptions.output);
SentenceReader reader=parseOptions.skipPI ? new SRLOnlyCoNLL09Reader(parseOptions.inputCorpus) : new DepsOnlyCoNLL09Reader(parseOptions.inputCorpus);
int senCount=0;
for(Sentence s:reader){
senCount++;
if(senCount%100==0)
System.out.println("Parsing sentence "+senCount);
srl.parseSentence(s);
writer.write(s);
}
writer.close();
reader.close();
long totalTime=System.currentTimeMillis()-startTime;
System.out.println("Done.");
System.out.println(srl.getStatus());
System.out.println();
System.out.println("Total execution time: "+Util.insertCommas(totalTime)+"ms");
}
示例5: learn
import se.lth.cs.srl.pipeline.Pipeline; //导入依赖的package包/类
private static void learn() throws IOException {
ZipOutputStream zos=new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(learnOptions.modelFile)));
if(learnOptions.trainReranker){
new Reranker(learnOptions,zos);
} else {
BrownCluster bc=Learn.learnOptions.brownClusterFile==null?null:new BrownCluster(Learn.learnOptions.brownClusterFile);
SentenceReader reader=new AllCoNLL09Reader(learnOptions.inputCorpus);
Pipeline.trainNewPipeline(reader, learnOptions.getFeatureFiles(), zos,bc);
}
zos.close();
}
示例6: main
import se.lth.cs.srl.pipeline.Pipeline; //导入依赖的package包/类
public static void main(String[] args) throws ZipException, IOException,
ClassNotFoundException {
HttpOptions options = new HttpOptions();
options.parseCmdLineArgs(args);
String error = FileExistenceVerifier
.verifyCompletePipelineAllNecessaryModelFiles(options);
if (error != null) {
System.err.println(error);
System.err.println("Aborting.");
System.exit(1);
}
Parse.parseOptions = options.getParseOptions();
Parse.parseOptions.skipPD = true;
Parse.parseOptions.skipPI = true;
SemanticRoleLabeler srl;
if (options.reranker) {
srl = new Reranker(Parse.parseOptions);
} else {
ZipFile zipFile = new ZipFile(Parse.parseOptions.modelFile);
if (Parse.parseOptions.skipPI) {
srl = Pipeline.fromZipFile(zipFile, new Step[] { Step.ai,
Step.ac });// ,Step.po,Step.ao});
} else {
srl = Pipeline.fromZipFile(zipFile);
}
zipFile.close();
}
HttpPipeline.setupHttpPipeline(options, new FramatHttpPipeline(srl,
HttpPipeline.imageCache, options.l, options.sentenceMaxLength,
options));
System.out.println("done.");
}
示例7: MateSrlBeModel
import se.lth.cs.srl.pipeline.Pipeline; //导入依赖的package包/类
private MateSrlBeModel(File mateModel) {
LOGGER.info("Loading model for Mate Tools (verb to be)");
try {
ZipFile zipFile;
zipFile = new ZipFile(mateModel);
labeler = Pipeline.fromZipFile(zipFile);
zipFile.close();
} catch (Exception e) {
LOGGER.error(e.getMessage());
}
Language.setLanguage(Language.L.valueOf("eng"));
}
示例8: MateSrlModel
import se.lth.cs.srl.pipeline.Pipeline; //导入依赖的package包/类
private MateSrlModel(File mateModel) {
LOGGER.info("Loading model for Mate Tools");
try {
ZipFile zipFile;
zipFile = new ZipFile(mateModel);
labeler = Pipeline.fromZipFile(zipFile);
zipFile.close();
} catch (Exception e) {
LOGGER.error(e.getMessage());
}
Language.setLanguage(Language.L.valueOf("eng"));
}
示例9: iterate
import se.lth.cs.srl.pipeline.Pipeline; //导入依赖的package包/类
private static double iterate(SelectionState inputState) throws IOException{
int size=inputState.additional.size();
double[] scores=new double[size];
//Map<Step,FeatureSet> featureSet=new HashMap<Step,FeatureSet>();
Map<Step,FeatureSet> featureSets=new HashMap<Step,FeatureSet>();
FeatureSet featureSet=new FeatureSet(inputState.current);
featureSets.put(options.step,featureSet);
// List<FeatureSet> combinations=new ArrayList<FeatureSet>();
// for(int i=0;i<size;++i){
// FeatureSet fs=startingSet.clone();
// fs.get(options.POSPrefix).add(inputState.additional.get(i));
// combinations.add(fs);
// }
AbstractScorer scorer=getScorer(options.step);
int k_max=(options.crossValidated?options.partitions:1);
List<Feature> featureList=featureSet.get(options.POSPrefix);
for(int k=0;k<k_max;++k){
for(int i=0;i<size;++i){
featureList.add(inputState.additional.get(i));
scorer.reset();
//File output=new File(CorpusStruct.corpusDir,"out-"+k+"_"+i);
SentenceReader reader=new DepsOnlyCoNLL09Reader(CorpusStruct.parts.get(k));
Iterator<Sentence> it=reader.iterator();
featureSets.put(options.step,featureSet);
Pipeline p=Pipeline.trainNewPipeline(CorpusStruct.trainingSets.get(k),fg,null,featureSets);
for(Sentence gold:CorpusStruct.testSets.get(k)){
Sentence parsed=it.next();
p.parseSentence(parsed);
scorer.accScore(gold, parsed);
}
scores[i]+=scorer.getAvgScore();
featureList.remove(featureList.size()-1);
}
System.out.println("Cross: "+k);
}
double bestScore=0;
int bestIndex=-1;
for(int i=0,length=scores.length;i<length;++i){
double avg=scores[i]/k_max;
if(avg>bestScore){
bestScore=avg;
bestIndex=i;
}
}
double increase=bestScore-inputState.score;
if(increase>0){
inputState.score=bestScore;
Feature newFeature=inputState.additional.remove(bestIndex);
inputState.current.get(options.POSPrefix).add(newFeature);
inputState.comments.add("F1: "+bestScore+", increase: "+increase);
} else {
System.out.println("negative increase.");
}
return increase;
}
示例10: main
import se.lth.cs.srl.pipeline.Pipeline; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
long startTime = System.currentTimeMillis();
parseOptions = new ParseOptions(args);
SemanticRoleLabeler srl;
if (parseOptions.useReranker) {
srl = new Reranker(parseOptions);
// srl =
// Reranker.fromZipFile(zipFile,parseOptions.skipPI,parseOptions.global_alfa,parseOptions.global_aiBeam,parseOptions.global_acBeam);
} else {
ZipFile zipFile = new ZipFile(parseOptions.modelFile);
srl = parseOptions.skipPD ? Pipeline.fromZipFile(zipFile,
new Step[] { Step.ai, Step.ac })
: parseOptions.skipPI ? Pipeline.fromZipFile(zipFile,
new Step[] { Step.pd, Step.ai, Step.ac /*
* ,Step.po,
* Step.ao
*/})
: Pipeline.fromZipFile(zipFile);
zipFile.close();
}
SentenceWriter writer = null;
if (parseOptions.printXML)
writer = new FrameNetXMLWriter(parseOptions.output);
else
writer = new CoNLL09Writer(parseOptions.output);
SentenceReader reader = parseOptions.skipPI ? new SRLOnlyCoNLL09Reader(
parseOptions.inputCorpus) : new DepsOnlyCoNLL09Reader(
parseOptions.inputCorpus);
int senCount = 0;
for (Sentence s : reader) {
senCount++;
if (senCount % 100 == 0)
System.out.println("Parsing sentence " + senCount);
srl.parseSentence(s);
if (parseOptions.writeCoref)
writer.specialwrite(s);
else
writer.write(s);
}
writer.close();
reader.close();
long totalTime = System.currentTimeMillis() - startTime;
System.out.println("Done.");
System.out.println(srl.getStatus());
System.out.println();
System.out.println("Total execution time: "
+ Util.insertCommas(totalTime) + "ms");
}