本文整理汇总了Java中edu.stanford.nlp.ling.CoreAnnotations.OriginalTextAnnotation类的典型用法代码示例。如果您正苦于以下问题:Java OriginalTextAnnotation类的具体用法?Java OriginalTextAnnotation怎么用?Java OriginalTextAnnotation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OriginalTextAnnotation类属于edu.stanford.nlp.ling.CoreAnnotations包,在下文中一共展示了OriginalTextAnnotation类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: TokenizedCoreLabelWrapper
import edu.stanford.nlp.ling.CoreAnnotations.OriginalTextAnnotation; //导入依赖的package包/类
/**
*
*/
public TokenizedCoreLabelWrapper(final CoreLabel cl) {
this.value = cl.get(ValueAnnotation.class);
this.text = cl.get(TextAnnotation.class);
LOGGER.trace("Wrapping token text: {}", this.text);
this.originalText = cl.get(OriginalTextAnnotation.class);
this.before = cl.get(BeforeAnnotation.class);
this.after = cl.get(AfterAnnotation.class);
this.startSentenceOffset = cl.get(CharacterOffsetBeginAnnotation.class);
this.endSentenceOffset = cl.get(CharacterOffsetEndAnnotation.class);
this.startOffset = Optional.ofNullable(cl.get(TokenBeginAnnotation.class));
this.endOffset = Optional.ofNullable(cl.get(TokenEndAnnotation.class));
LOGGER.trace("TokenBegin: {}", this.startOffset);
LOGGER.trace("TokenEnd: {}", this.endOffset);
this.idx = cl.get(IndexAnnotation.class);
this.sentenceIdx = cl.get(SentenceIndexAnnotation.class);
LOGGER.trace("Got sentence idx: {}", this.sentenceIdx);
}
开发者ID:hltcoe,项目名称:concrete-stanford-deprecated2,代码行数:24,代码来源:TokenizedCoreLabelWrapper.java
示例2: getNext
import edu.stanford.nlp.ling.CoreAnnotations.OriginalTextAnnotation; //导入依赖的package包/类
/** Make the next token.
*
* @param txt What the token should be
* @param originalText The original String that got transformed into txt
*/
private Object getNext(String txt, String originalText) {
if (tokenFactory == null) {
throw new RuntimeException(this.getClass().getName() + ": Token factory is null.");
}
if (invertible) {
//String str = prevWordAfter.toString();
//prevWordAfter.setLength(0);
CoreLabel word = (CoreLabel) tokenFactory.makeToken(txt, yychar, yylength());
word.set(OriginalTextAnnotation.class, originalText);
//word.set(BeforeAnnotation.class, str);
//prevWord.set(AfterAnnotation.class, str);
//prevWord = word;
return word;
} else {
return tokenFactory.makeToken(txt, yychar, yylength());
}
}
开发者ID:amark-india,项目名称:eventspotter,代码行数:23,代码来源:ArabicLexer.java
示例3: buildMention
import edu.stanford.nlp.ling.CoreAnnotations.OriginalTextAnnotation; //导入依赖的package包/类
public Mention buildMention(Annotation annotation, int sentId,
int startToken, int endToken) {
CoreMap sentAnn = annotation.get(SentencesAnnotation.class).get(sentId);
List<CoreLabel> tokens = sentAnn.get(TokensAnnotation.class);
// create a Mention object
Mention.Builder m = Mention.newBuilder();
m.setStart(startToken);
m.setEnd(endToken);
for (int i = 0; i < tokens.size(); i++) {
m.addTokens(tokens.get(i).get(OriginalTextAnnotation.class));
m.addPosTags(tokens.get(i).get(PartOfSpeechAnnotation.class));
}
m.setEntityName("");
m.setFileid("on-the-fly");
m.setSentid(sentId);
// dependency
String depStr = StanfordDependencyResolver.getString(sentAnn);
if (depStr != null) {
for (String d : depStr.split("\t")) {
Matcher match = Preprocessing.depPattern.matcher(d);
if (match.find()) {
m.addDeps(Dependency.newBuilder().setType(match.group(1))
.setGov(Integer.parseInt(match.group(3)) - 1)
.setDep(Integer.parseInt(match.group(5)) - 1)
.build());
} else {
}
}
}
return m.build();
}
开发者ID:zhangcongle,项目名称:NewsSpikeRe,代码行数:34,代码来源:FigerSystem.java
示例4: buildMention
import edu.stanford.nlp.ling.CoreAnnotations.OriginalTextAnnotation; //导入依赖的package包/类
public Mention buildMention(Annotation annotation, int sentId, int startToken, int endToken) {
CoreMap sentAnn = annotation.get(SentencesAnnotation.class).get(sentId);
List<CoreLabel> tokens = sentAnn.get(TokensAnnotation.class);
// create a Mention object
Mention.Builder m = Mention.newBuilder();
m.setStart(startToken);
m.setEnd(endToken);
for (int i = 0; i < tokens.size(); i++) {
m.addTokens(tokens.get(i).get(OriginalTextAnnotation.class));
m.addPosTags(tokens.get(i).get(PartOfSpeechAnnotation.class));
}
m.setEntityName("");
m.setFileid("on-the-fly");
m.setSentid(sentId);
// dependency
String depStr = StanfordDependencyResolver.getString(sentAnn);
if (depStr != null) {
for (String d : depStr.split("\t")) {
Matcher match = Preprocessing.depPattern.matcher(d);
if (match.find()) {
m.addDeps(
Dependency.newBuilder().setType(match.group(1)).setGov(Integer.parseInt(match.group(3)) - 1)
.setDep(Integer.parseInt(match.group(5)) - 1).build());
} else {
}
}
}
return m.build();
}
开发者ID:zhangcongle,项目名称:NewsSpikeRe,代码行数:32,代码来源:ParseStanfordFigerReverb.java
示例5: process
import edu.stanford.nlp.ling.CoreAnnotations.OriginalTextAnnotation; //导入依赖的package包/类
@Override
public SymmetricalWordAlignment process(Sequence<IString> inputSequence) {
List<CoreLabel> labeledTokens = ProcessorTools.toCharacterSequence(inputSequence);
labeledTokens = classifier.classify(labeledTokens);
List<CoreLabel> outputTokens = ProcessorTools.toPostProcessedSequence(labeledTokens);
List<String> outputStrings = new ArrayList<>();
for (CoreLabel label : outputTokens) {
outputStrings.add(label.word());
}
Sequence<IString> outputSequence = IStrings.toIStringSequence(outputStrings);
SymmetricalWordAlignment alignment = new SymmetricalWordAlignment(inputSequence, outputSequence);
// Reconstruct the alignment by iterating over the target
for (int outputIndex = 0, inputIndex = 0, outputSize = outputTokens.size(), inputSize = inputSequence.size();
outputIndex < outputSize && inputIndex < inputSize; ++outputIndex) {
String outputToken = outputTokens.get(outputIndex).get(OriginalTextAnnotation.class);
String inputCandidate = inputSequence.get(inputIndex).toString();
if (outputToken.equals(inputCandidate)) {
// Unigram alignment
alignment.addAlign(inputIndex, outputIndex);
++inputIndex;
} else {
// one-to-many alignment (output-to-input)
String[] originalTokens = outputToken.split("\\s+");
int newInputIndex = findSubsequenceStart(originalTokens, inputSequence, inputIndex);
if (newInputIndex < 0) {
System.err.printf("Unable to find |%s| in |%s|%n", outputToken, inputSequence.toString());
} else {
inputIndex = newInputIndex;
for (int i = 0; i < originalTokens.length; ++i) {
alignment.addAlign(inputIndex, outputIndex);
++inputIndex;
}
}
}
}
return alignment;
}
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:40,代码来源:CRFPostprocessor.java
示例6: getNext
import edu.stanford.nlp.ling.CoreAnnotations.OriginalTextAnnotation; //导入依赖的package包/类
/**
* Make the next token.
*
* @param txt
* What the token should be
* @param current
* The original String that got transformed into txt
*/
private Object getNext(String txt, String current) {
if (invertible) {
CoreLabel word = (CoreLabel) tokenFactory.makeToken(txt, yychar, yylength());
word.set(OriginalTextAnnotation.class, current);
word.set(BeforeAnnotation.class, prevWord.getString(AfterAnnotation.class));
prevWord = word;
return word;
} else {
return tokenFactory.makeToken(txt, yychar, yylength());
}
}
开发者ID:begab,项目名称:kpe,代码行数:20,代码来源:HunPTBLexer.java
示例7: NGram
import edu.stanford.nlp.ling.CoreAnnotations.OriginalTextAnnotation; //导入依赖的package包/类
public NGram(String[] originalForms, String[] lemmas) {
for (int i = 0; i < originalForms.length; ++i) {
CoreLabel cl = new CoreLabel();
cl.set(TextAnnotation.class, originalForms[i]);
cl.set(OriginalTextAnnotation.class, originalForms[i]);
cl.set(LemmaAnnotation.class, lemmas[i]);
cl.set(PartOfSpeechAnnotation.class, "dummy");
add(cl);
}
setNormalizedForm();
}
开发者ID:begab,项目名称:kpe,代码行数:12,代码来源:NGram.java
示例8: getNext
import edu.stanford.nlp.ling.CoreAnnotations.OriginalTextAnnotation; //导入依赖的package包/类
/** Make the next token.
* @param txt What the token should be
* @param originalText The original String that got transformed into txt
*/
private Object getNext(String txt, String originalText) {
if (invertible) {
String str = prevWordAfter.toString();
prevWordAfter.setLength(0);
CoreLabel word = (CoreLabel) tokenFactory.makeToken(txt, yychar, yylength());
word.set(OriginalTextAnnotation.class, originalText);
word.set(BeforeAnnotation.class, str);
prevWord.set(AfterAnnotation.class, str);
prevWord = word;
return word;
} else {
return tokenFactory.makeToken(txt, yychar, yylength());
}
}
开发者ID:amark-india,项目名称:eventspotter,代码行数:19,代码来源:PTBLexer.java
示例9: setOriginalText
import edu.stanford.nlp.ling.CoreAnnotations.OriginalTextAnnotation; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void setOriginalText(String originalText) {
set(CoreAnnotations.OriginalTextAnnotation.class, originalText);
}
开发者ID:amark-india,项目名称:eventspotter,代码行数:7,代码来源:CoreLabel.java
示例10: originalText
import edu.stanford.nlp.ling.CoreAnnotations.OriginalTextAnnotation; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public String originalText() {
return getString(OriginalTextAnnotation.class);
}
开发者ID:amark-india,项目名称:eventspotter,代码行数:7,代码来源:CoreLabel.java
注:本文中的edu.stanford.nlp.ling.CoreAnnotations.OriginalTextAnnotation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论