Examples of POSTagger


Examples of opennlp.ccg.parse.postagger.POSTagger

        }
       
        // should we use the tagging dictionaries (yes if there is no prior model).
        boolean useWordDictionary = (wDictS != null);
        boolean usePOSDictionary = (pDictS != null);
        POSTagger pTagger = (posConfigS == null) ? null : POSTagger.posTaggerFactory(posConfigS);
        TaggingAlgorithm alg = (opts.get("taggingalgorithm") == null || opts.get("taggingalgorithm").equals("forward-backward")) ?
            TaggingAlgorithm.FORWARDBACKWARD : TaggingAlgorithm.FORWARD;
        MaxentModel mem = new ZLMEM(new File(maxentModS));
        //STTaggerWordDictionary wd,STTaggerPOSDictionary pd,  int K, MaxentModel mo, FeatureExtractor fexer,
        //String tagSequenceModel, Constants.TaggingAlgorithm alg, POSTagger posTagger
View Full Code Here

Examples of opennlp.ccg.parse.postagger.POSTagger

            } catch (IOException ex) {
                Logger.getLogger(STFex.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        STFex fexer = new STFex(stPriorMod);       
        POSTagger posT = (posConfig == null) ? null : POSTagger.posTaggerFactory(posConfig);
       
        if(posT != null) { fexer.useMultiPOS(true); } else { fexer.useMultiPOS(false); }
       
        for(List<Word> sentence : corp) {
            Map<Integer, TaggedWord> sent = new HashMap<Integer, TaggedWord>(sentence.size());
            int index = 0;               
            if(posT == null) {               
                for(Word w : sentence) { sent.put(index++, new TaggedWord(w)); }           
            } else {
                List<TaggedWord> posTagging = posT.tagSentence(sentence);
                for(TaggedWord tw : posTagging) { sent.put(index++, tw); }
            }
            List<Collection<Pair<String,Double>>> ftss = fexer.getSentenceFeatures(sent, true);           
            for(Collection<Pair<String,Double>> fts : ftss) {
                index = 0;
View Full Code Here

Examples of opennlp.tools.lang.english.PosTagger

    super.initialize(aContext);

    try {
      // Get configuration parameter values
      String modelFile = (String) aContext.getConfigParameterValue(MODEL_FILE_PARAM);
      tagger = new PosTagger(modelFile, (Dictionary) null);
    } catch (Exception e) {
      throw new ResourceInitializationException(e);
    }
  }
View Full Code Here

Examples of opennlp.tools.postag.POSTagger

    }
    @Test
    public void testLoadEnPOS() throws IOException{
        POSModel model = openNLP.getPartOfSpeachModel("en");
        Assert.assertNotNull(model);
        POSTagger posTagger = openNLP.getPartOfSpeechTagger("en");
        Assert.assertNotNull(posTagger);
    }
View Full Code Here

Examples of opennlp.tools.postag.POSTagger

    }
    @Test
    public void testLoadMissingPOS() throws IOException{
        POSModel model = openNLP.getPartOfSpeachModel("ru");
        Assert.assertNull(model);
        POSTagger posTagger = openNLP.getPartOfSpeechTagger("ru");
        Assert.assertNull(posTagger);
    }
View Full Code Here

Examples of opennlp.tools.postag.POSTagger

     
      File d = new File(dataDir);
     
      MaxentModel buildModel = null;
      MaxentModel checkModel = null;
      POSTagger posTagger = null;
      Chunker chunker = null;
      HeadRules headRules = null;

      if (!d.isDirectory()) {
        FileInputStream fis = new FileInputStream(d);
View Full Code Here

Examples of opennlp.tools.postag.POSTagger

    @Override
    public void computeEnhancements(ContentItem ci) throws EngineException {
        AnalysedText at = initAnalysedText(this,analysedTextFactory,ci);
        String language = getLanguage(this, ci, true);
       
        POSTagger posTagger = getPOSTagger(language);
        if(posTagger == null){
            //this means that the POS tagger became unavailable in-between
            //the call to canEnhance and computeEnhancement
            throw new EngineException("PosTagger for langauge '"+language
                + "is not available.");
View Full Code Here

Examples of org.fnlp.nlp.cn.tag.POSTagger

  public static void loadTag(String path) throws LoadModelException {
    if(pos==null){

      String file = path+posModel;
      if(seg==null)
        pos = new POSTagger(file);
      else{
        pos = new POSTagger(seg,file);         
      }
    }
  }
View Full Code Here

Examples of org.fnlp.nlp.cn.tag.POSTagger

  /**
   * 只输入句子,不带词性
   * @throws Exception
   */
  private static void test(String word) throws Exception {   
    POSTagger tag = new POSTagger("../models/seg.m","../models/pos.m");
    String[][] s = tag.tag2Array(word);
    try {
      DependencyTree tree = parser.parse2T(s[0],s[1]);
      System.out.println(tree.toString());
      String stree = parser.parse2String(s[0],s[1],true);
      System.out.println(stree);
View Full Code Here

Examples of org.fnlp.nlp.cn.tag.POSTagger

   */
  public static void main(String[] args) throws Exception {

   
    CWSTagger cws = new CWSTagger("../models/seg.m");
    tag = new POSTagger(cws,"../models/pos.m");
   
    System.out.println("得到支持的词性标签集合");
    System.out.println(tag.getSupportedTags());
    System.out.println(tag.getSupportedTags().size());
    System.out.println("\n");
   
    String str = "媒体计算研究所成立了,高级数据挖掘很难。乐phone很好!";
    String s = tag.tag(str);
    System.out.println("处理未分词的句子");
    System.out.println(s);
   
    System.out.println("使用英文标签");
    tag.SetTagType("en");   
    System.out.println(tag.getSupportedTags());
    System.out.println(tag.getSupportedTags().size());
    s = tag.tag(str);
    System.out.println(s);   
    System.out.println();
   
    CWSTagger cws2 = new CWSTagger("../models/seg.m", new Dictionary("../models/dict.txt"));
   
    //bool值指定该dict是否用于cws分词(分词和词性可以使用不同的词典)
    tag = new POSTagger(cws2, "../models/pos.m"
        , new Dictionary("../models/dict.txt"), true);//true就替换了之前的dict.txt
    tag.removeDictionary(false);//不移除分词的词典
    tag.setDictionary(new Dictionary("../models/dict.txt"), false);//设置POS词典,分词使用原来设置
   
    String str2 = "媒体计算研究所成立了,高级数据挖掘很难。乐phone很好!";
    String s2 = tag.tag(str2);
    System.out.println("处理未分词的句子,使用词典");
    System.out.println(s2);
    System.out.println();
   
    Dictionary dict = new Dictionary();
    dict.add("媒体计算","mypos1","mypos2");
    dict.add("乐phone","专有名");
    tag.setDictionary(dict, true);
    String s22 = tag.tag(str2);
    System.out.println(s22);
    System.out.println();
   
    POSTagger tag1 = new POSTagger("../models/pos.m");
    String str1 = "媒体计算 研究所 成立 了 , 高级 数据挖掘 很 难";
    String[] w = str1.split(" ");
    String[] s1 = tag1.tagSeged(w);
    System.out.println("直接处理分好词的句子:++++++++++");
    for(int i=0;i<s1.length;i++){
      System.out.print(w[i]+"/"+s1[i]+" ");
    }
    System.out.println("\n");
   
    POSTagger tag3 = new POSTagger("../models/pos.m", new Dictionary("../models/dict.txt"));
    String str3 = "媒体计算 研究所 成立 了 , 高级 数据挖掘 很 难 ";
    String[] w3 = str3.split(" ");
    String[] s3 = tag3.tagSeged(w3);
    System.out.println("直接处理分好词的句子,使用词典");
    for(int i=0;i<s3.length;i++){
      System.out.print(w3[i]+"/"+s3[i]+" ");
    }
    System.out.println("\n");
   
    //????????????????????????????
   
    System.out.println("重新构造");
    cws = new CWSTagger("../models/seg.m");
    tag = new POSTagger(cws,"../models/pos.m");
    str = "媒体计算研究所成立了, 高级数据挖掘很难";
    System.out.println(tag.tag(str));
    String[][] sa = tag.tag2Array(str);
    for(int i = 0; i < sa.length; i++) {
      for(int j = 0; j < sa[i].length; j++) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.