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


Java InputReader.InputWord方法代码示例

本文整理汇总了Java中edu.uw.easysrl.main.InputReader.InputWord方法的典型用法代码示例。如果您正苦于以下问题:Java InputReader.InputWord方法的具体用法?Java InputReader.InputWord怎么用?Java InputReader.InputWord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.uw.easysrl.main.InputReader的用法示例。


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

示例1: parseNBest

import edu.uw.easysrl.main.InputReader; //导入方法依赖的package包/类
@Override
public List<Parse> parseNBest(List<InputReader.InputWord> sentence) {
    List<Scored<SyntaxTreeNode>> parses = parser.doParsing(
            new InputReader.InputToParser(sentence, null, null, false));
    if (parses == null || parses.size() == 0) {
        return null;
    }
    return parses.stream().map(p -> getParse(sentence, p, dependencyGenerator)).collect(Collectors.toList());
}
 
开发者ID:uwnlp,项目名称:hitl_parsing,代码行数:10,代码来源:BaseCcgParser.java

示例2: getNBestList

import edu.uw.easysrl.main.InputReader; //导入方法依赖的package包/类
public static Optional<NBestList> getNBestList(final BaseCcgParser parser, int sentenceId,
                                     final List<InputReader.InputWord> inputSentence) {
    return Optional
        .ofNullable(parser.parseNBest(sentenceId, inputSentence))
        .map(ImmutableList::copyOf)
        .map(NBestList::new);
}
 
开发者ID:uwnlp,项目名称:hitl_parsing,代码行数:8,代码来源:NBestList.java

示例3: BioinferCCGCorpus

import edu.uw.easysrl.main.InputReader; //导入方法依赖的package包/类
private BioinferCCGCorpus(final ImmutableList<ImmutableList<InputReader.InputWord>> inputSentences,
                          final ImmutableList<ImmutableList<String>> sentences,
                          final ImmutableList<ImmutableList<String>> postags,
                          final ImmutableList<ImmutableList<Category>> goldCategories) {
    this.inputSentences = inputSentences;
    this.sentences = sentences;
    this.postags = postags;
    this.goldCategories = goldCategories;
}
 
开发者ID:uwnlp,项目名称:hitl_parsing,代码行数:10,代码来源:BioinferCCGCorpus.java

示例4: readTest

import edu.uw.easysrl.main.InputReader; //导入方法依赖的package包/类
public static Optional<BioinferCCGCorpus> readTest() {
    POSTagger postagger = POSTagger.getStanfordTagger(Util.getFile(BaseCcgParser.modelFolder + "/posTagger"));
    List<ImmutableList<InputReader.InputWord>> inputSentences = new ArrayList<>();
    List<ImmutableList<String>> sentences = new ArrayList<>();
    try {
        BufferedReader reader = new BufferedReader(new FileReader(new File(BioinferTestFile)));
        String line;
        while ((line = reader.readLine()) != null) {
            if (line.trim().isEmpty()) {
                continue;
            }
            String[] tokens = line.split("\\s+");
            List<InputReader.InputWord> inputs = new ArrayList<>();
            List<String> words = new ArrayList<>();
            for (String tok : tokens) {
                words.add(tok);
                inputs.add(new InputReader.InputWord(tok, "", ""));
            }
            if (words.size() > 0) {
                List<InputReader.InputWord> taggedInputs = postagger.tag(inputs);
                inputSentences.add(ImmutableList.copyOf(taggedInputs));
                sentences.add(ImmutableList.copyOf(words));
            }
        }

    } catch (IOException e) {
        System.err.println(e.getMessage());
        e.printStackTrace();
        return Optional.empty();
    }
    System.out.println(String.format("Read %d sentences from %s.", sentences.size(), BioinferTestFile));
    return Optional.of(new BioinferCCGCorpus(ImmutableList.copyOf(inputSentences), ImmutableList.copyOf(sentences),
            ImmutableList.of(), ImmutableList.of()));
}
 
开发者ID:uwnlp,项目名称:hitl_parsing,代码行数:35,代码来源:BioinferCCGCorpus.java

示例5: makeParseData

import edu.uw.easysrl.main.InputReader; //导入方法依赖的package包/类
private static ParseData makeParseData(List<List<InputReader.InputWord>> sentenceInputWords,
                                       List<Parse> goldParses) {
    ImmutableList<ImmutableList<InputReader.InputWord>> thisSentences = sentenceInputWords
            .stream()
            .map(ImmutableList::copyOf)
            .collect(toImmutableList());
    ImmutableList<Parse> thisGoldParses = goldParses.stream().allMatch(p -> p != null) ?
            goldParses.stream().collect(toImmutableList()) :
            ImmutableList.of();
    return new ParseData(thisSentences, thisGoldParses);
}
 
开发者ID:uwnlp,项目名称:hitl_parsing,代码行数:12,代码来源:ParseDataLoader.java

示例6: loadFromTestPool

import edu.uw.easysrl.main.InputReader; //导入方法依赖的package包/类
public static Optional<ParseData> loadFromTestPool(boolean includeGold) {
    if (includeGold) {
        System.err.println("### Waring ### Reading test data with gold parses.");
    }
    POSTagger postagger = POSTagger.getStanfordTagger(Util.getFile(BaseCcgParser.modelFolder + "/posTagger"));
    List<List<InputReader.InputWord>> sentenceInputWords = new ArrayList<>();
    List<Parse> goldParses = new ArrayList<>();
    Iterator<ParallelCorpusReader.Sentence> sentenceIterator;
    try {
        sentenceIterator = ParallelCorpusReader.READER.readCcgTestSet();
    } catch (IOException e) {
        System.out.println(String.format("Failed to read %d sentences.", sentenceInputWords.size()));
        return Optional.empty();
    }
    while (sentenceIterator.hasNext()) {
        ParallelCorpusReader.Sentence sentence = sentenceIterator.next();
        List<InputReader.InputWord> taggedInput = postagger.tag(sentence.getInputWords());
        sentenceInputWords.add(taggedInput);
        Set<ResolvedDependency> goldDependencies = CCGBankEvaluation
                .asResolvedDependencies(sentence.getCCGBankDependencyParse().getDependencies());
        if (includeGold) {
            goldParses.add(new Parse(sentence.getCcgbankParse(), sentence.getLexicalCategories(), goldDependencies));
        } else {
            goldParses.add(null);
        }
    }
    System.out.println(String.format("Read %d sentences.", sentenceInputWords.size()));
    return Optional.of(makeParseData(sentenceInputWords, goldParses));
}
 
开发者ID:uwnlp,项目名称:hitl_parsing,代码行数:30,代码来源:ParseDataLoader.java

示例7: parse

import edu.uw.easysrl.main.InputReader; //导入方法依赖的package包/类
@Override
public Parse parse(int sentenceId, List<InputReader.InputWord> sentence) {
    final InputReader.InputToParser input = taggedSentences == null ?
            new InputReader.InputToParser(sentence, null, null, false) :
            new InputReader.InputToParser(sentence, null, taggedSentences.get(sentenceId), true);
    List<Scored<SyntaxTreeNode>> parses = parser.doParsing(input);
    if (parses == null || parses.size() == 0) {
        System.err.println("Unable to parse:\t" + taggedSentences);
        return null;
    }
    return getParse(sentence, parses.get(0), dependencyGenerator);
}
 
开发者ID:uwnlp,项目名称:hitl_parsing,代码行数:13,代码来源:BaseCcgParser.java

示例8: getParse

import edu.uw.easysrl.main.InputReader; //导入方法依赖的package包/类
protected Parse getParse(final List<InputReader.InputWord> sentence, final Scored<SyntaxTreeNode> scoredParse,
                         DependencyGenerator dependencyGenerator) {
    SyntaxTreeNode ccgParse = scoredParse.getObject();
    List<Category> categories = ccgParse.getLeaves().stream().map(SyntaxTreeNode::getCategory)
            .collect(Collectors.toList());
    Set<UnlabelledDependency> unlabelledDeps = new HashSet<>();
    dependencyGenerator.generateDependencies(ccgParse, unlabelledDeps);
    Set<ResolvedDependency> dependencies = CCGBankEvaluation.convertDeps(sentence, unlabelledDeps)
                    .stream()
                    .filter(x -> x.getHead() != x.getArgument())
                    .filter(x -> frequentDependenciesSet.contains(x.getCategory() + "." +  x.getArgNumber()))
                    .collect(Collectors.toSet());
    return new Parse(scoredParse.getObject(), categories, dependencies, scoredParse.getScore());
}
 
开发者ID:uwnlp,项目名称:hitl_parsing,代码行数:15,代码来源:BaseCcgParser.java

示例9: parseNBestWithConstraint

import edu.uw.easysrl.main.InputReader; //导入方法依赖的package包/类
public List<Parse> parseNBestWithConstraint(int sentenceId, List<InputReader.InputWord> sentence,
                                            Set<Constraint> constraintSet) {
    if (sentence.size() > maxSentenceLength) {
        System.err.println("Skipping sentence of length " + sentence.size());
        return null;
    }
    final InputReader.InputToParser input = taggedSentences == null ?
            new InputReader.InputToParser(sentence, null, null, false) :
            new InputReader.InputToParser(sentence, null, taggedSentences.get(sentenceId), true);
    List<Scored<SyntaxTreeNode>> parses = parser.parseWithConstraints(input, constraintSet);
    return (parses == null || parses.size() == 0) ? null :
            parses.stream().map(p -> getParse(sentence, p, dependencyGenerator)).collect(Collectors.toList());

}
 
开发者ID:uwnlp,项目名称:hitl_parsing,代码行数:15,代码来源:BaseCcgParser.java

示例10: cacheSupertags

import edu.uw.easysrl.main.InputReader; //导入方法依赖的package包/类
public void cacheSupertags(ImmutableList<ImmutableList<InputReader.InputWord>> inputSentences) {
    if (batchTagger != null) {
        System.err.println("Batch tagging " + inputSentences.size() + " sentences ...");
        taggedSentences = batchTagger.tagBatch(inputSentences.parallelStream()
                .map(s -> s.stream().collect(Collectors.toList())))
                .collect(GuavaCollectors.toImmutableList());
    }
}
 
开发者ID:uwnlp,项目名称:hitl_parsing,代码行数:9,代码来源:BaseCcgParser.java

示例11: getInputSentences

import edu.uw.easysrl.main.InputReader; //导入方法依赖的package包/类
public ImmutableList<ImmutableList<InputReader.InputWord>> getInputSentences() {
    return inputSentences;
}
 
开发者ID:uwnlp,项目名称:hitl_parsing,代码行数:4,代码来源:BioinferCCGCorpus.java

示例12: getInputSentence

import edu.uw.easysrl.main.InputReader; //导入方法依赖的package包/类
public ImmutableList<InputReader.InputWord> getInputSentence(int sentenceId) {
    return inputSentences.get(sentenceId);
}
 
开发者ID:uwnlp,项目名称:hitl_parsing,代码行数:4,代码来源:BioinferCCGCorpus.java

示例13: readDev

import edu.uw.easysrl.main.InputReader; //导入方法依赖的package包/类
public static Optional<BioinferCCGCorpus> readDev() {
    POSTagger postagger = POSTagger.getStanfordTagger(Util.getFile(BaseCcgParser.modelFolder + "/posTagger"));
    List<ImmutableList<InputReader.InputWord>> inputSentences = new ArrayList<>();
    List<ImmutableList<String>> sentences = new ArrayList<>(), postags = new ArrayList<>();
    List<ImmutableList<Category>> goldCategories = new ArrayList<>();
    try {
        BufferedReader reader = new BufferedReader(new FileReader(new File(BioinferDevFile)));
        String line;
        while ((line = reader.readLine()) != null) {
            if (line.trim().isEmpty()) {
                continue;
            }
            String[] segments = line.split("\\s+");
            List<InputReader.InputWord> inputs = new ArrayList<>();
            List<String> words = new ArrayList<>(), pos = new ArrayList<>();
            List<Category> categories = new ArrayList<>();
            for (String seg : segments) {
                String[] info = seg.split("\\|");
                words.add(info[0]);
                pos.add(info[1]);
                categories.add(Category.valueOf(info[2]));
                inputs.add(new InputReader.InputWord(info[0], "", ""));
            }
            if (words.size() > 0) {
                List<InputReader.InputWord> taggedInputs = postagger.tag(inputs);
                //System.out.println(taggedInputs.stream().map(InputReader.InputWord::toString).collect(Collectors.joining(" ")));
                inputSentences.add(ImmutableList.copyOf(taggedInputs));
                sentences.add(ImmutableList.copyOf(words));
                postags.add(ImmutableList.copyOf(pos));
                goldCategories.add(ImmutableList.copyOf(categories));
            }
        }

    } catch (IOException e) {
        System.err.println(e.getMessage());
        e.printStackTrace();
        return Optional.empty();
    }
    System.out.println(String.format("Read %d sentences from %s.", sentences.size(), BioinferDevFile));
    return Optional.of(new BioinferCCGCorpus(ImmutableList.copyOf(inputSentences), ImmutableList.copyOf(sentences),
            ImmutableList.copyOf(postags), ImmutableList.copyOf(goldCategories)));
}
 
开发者ID:uwnlp,项目名称:hitl_parsing,代码行数:43,代码来源:BioinferCCGCorpus.java

示例14: getSentenceInputWords

import edu.uw.easysrl.main.InputReader; //导入方法依赖的package包/类
public ImmutableList<ImmutableList<InputReader.InputWord>> getSentenceInputWords() {
    return sentenceInputWords;
}
 
开发者ID:uwnlp,项目名称:hitl_parsing,代码行数:4,代码来源:ParseData.java

示例15: getCategoryScores

import edu.uw.easysrl.main.InputReader; //导入方法依赖的package包/类
@Override
public Map<Category, Double> getCategoryScores(List<InputReader.InputWord> sentence, int wordIndex,
		double weight, Collection<Category> categories) {
	throw new UnsupportedOperationException("Not supported yet.");
}
 
开发者ID:uwnlp,项目名称:EasySRL,代码行数:6,代码来源:TaggerflowRemoteLSTM.java


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