當前位置: 首頁>>代碼示例>>Java>>正文


Java CoreLabel.tag方法代碼示例

本文整理匯總了Java中edu.stanford.nlp.ling.CoreLabel.tag方法的典型用法代碼示例。如果您正苦於以下問題:Java CoreLabel.tag方法的具體用法?Java CoreLabel.tag怎麽用?Java CoreLabel.tag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在edu.stanford.nlp.ling.CoreLabel的用法示例。


在下文中一共展示了CoreLabel.tag方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: tokenize

import edu.stanford.nlp.ling.CoreLabel; //導入方法依賴的package包/類
public LinkedList<String> tokenize(String text) {
    LinkedList<String> res = new LinkedList<>();
    if (text != null) {
        Annotation qaTokens = new Annotation(text);
        pipelineTokens.annotate(qaTokens);
        List<CoreMap> qssTokens = qaTokens.get(CoreAnnotations.SentencesAnnotation.class);
        for (CoreMap sentenceTokens : qssTokens) {
            ArrayList<CoreLabel> tokens = (ArrayList<CoreLabel>) sentenceTokens.get(CoreAnnotations.TokensAnnotation.class);
            for (CoreLabel t : tokens) {
                String lemma = t.lemma();
                String pos = t.tag();
                if (!stopwords.contains(lemma)) {
                    String rep = representativeProvider.getRepresentative(lemma, pos);
                    if (!stopwords.contains(rep)) {
                        res.add(rep);
                    }
                }
            }
        }
    }
    return res;
}
 
開發者ID:UCLA-BD2K,項目名稱:aztec-text-analysis-tools,代碼行數:23,代碼來源:Tokenizer.java

示例2: preprocess

import edu.stanford.nlp.ling.CoreLabel; //導入方法依賴的package包/類
public Concept preprocess(Concept c) {

		if (this.tagger == null)
			this.tagger = new MaxentTagger("ext_models/pos_tagger/english-left3words-distsim.tagger");
		if (this.ner == null)
			this.ner = CRFClassifier.getClassifierNoExceptions("ext_models/ner/english.all.3class.distsim.crf.ser.gz");

		List<CoreLabel> words = tokFactory.getTokenizer(new StringReader(c.name)).tokenize();
		tagger.tagCoreLabels(words);
		words = ner.classifySentence(words);
		words = this.addLemmas(words);

		List<PToken> tokens = new ArrayList<PToken>();
		for (CoreLabel word : words) {
			PToken t = new PToken(word.originalText());
			t.pos = word.tag();
			t.neTag = word.get(CoreAnnotations.AnswerAnnotation.class);
			t.lemma = word.get(LemmaAnnotation.class);
			tokens.add(t);
		}
		c.tokenList = tokens;

		return c;
	}
 
開發者ID:UKPLab,項目名稱:ijcnlp2017-cmaps,代碼行數:25,代碼來源:NonUIMAPreprocessor.java

示例3: simpleTokenization

import edu.stanford.nlp.ling.CoreLabel; //導入方法依賴的package包/類
public LinkedList<String> simpleTokenization(String text) {
    LinkedList<String> res = new LinkedList<>();
    if (text != null) {
        Annotation qaTokens = new Annotation(text);
        pipelineTokens.annotate(qaTokens);
        List<CoreMap> qssTokens = qaTokens.get(CoreAnnotations.SentencesAnnotation.class);
        for (CoreMap sentenceTokens : qssTokens) {
            ArrayList<CoreLabel> tokens = (ArrayList<CoreLabel>) sentenceTokens.get(CoreAnnotations.TokensAnnotation.class);
            for (CoreLabel t : tokens) {
                String lemma = t.lemma();
                String pos = t.tag();
                if ((pos.startsWith("N") || pos.startsWith("V")) && !stopwords.contains(lemma)) {
                    res.add(lemma);
                }
            }
        }
    }
    return res;
}
 
開發者ID:UCLA-BD2K,項目名稱:aztec-text-analysis-tools,代碼行數:20,代碼來源:Tokenizer.java

示例4: tokenizeBySentence

import edu.stanford.nlp.ling.CoreLabel; //導入方法依賴的package包/類
public LinkedList<LinkedList<String>> tokenizeBySentence(String text, LinkedList<int[]> boundaries) {
    LinkedList<LinkedList<String>> res = new LinkedList<>();
    if (text != null) {
        Annotation qaTokens = new Annotation(text);
        pipelineTokens.annotate(qaTokens);
        List<CoreMap> qssTokens = qaTokens.get(CoreAnnotations.SentencesAnnotation.class);
        for (CoreMap sentenceTokens : qssTokens) {
            ArrayList<CoreLabel> tokens = (ArrayList<CoreLabel>) sentenceTokens.get(CoreAnnotations.TokensAnnotation.class);
            LinkedList<String> sentence=new LinkedList<>();
            boolean first=true;
            int[] bounds=new int[2];
            CoreLabel last=null;
            for (CoreLabel t : tokens) {
                if (first) {
                    bounds[0]=t.beginPosition();
                    first=false;
                }
                last=t;
                String lemma = t.lemma();
                String pos = t.tag();
                if (!stopwords.contains(lemma)) {
                    String rep = representativeProvider.getRepresentative(lemma, pos);
                    if (!stopwords.contains(rep)) {
                        sentence.add(rep);
                    }
                }
            }
            bounds[1]=last.endPosition();
            if (sentence.size()>0) {
                res.add(sentence);
                boundaries.add(bounds);
            }
        }
    }
    return res;
}
 
開發者ID:UCLA-BD2K,項目名稱:aztec-text-analysis-tools,代碼行數:37,代碼來源:Tokenizer.java


注:本文中的edu.stanford.nlp.ling.CoreLabel.tag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。