本文整理了Java中edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation.getAvailableViews()
方法的一些代码示例,展示了TextAnnotation.getAvailableViews()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextAnnotation.getAvailableViews()
方法的具体详情如下:
包路径:edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation
类名称:TextAnnotation
方法名:getAvailableViews
暂无
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-core-utilities
/**
* copy views from the relevant span from ta to newTA. If ta is smaller than newTA, map all constituents,
* changing offsets according to the value 'offset'.
* Otherwise, only map those constituents within the span sourceStartTokenIndex, sourceEndTokenIndex to newTA.
*
* @param ta
* @param newTA
* @param sourceStartTokenIndex
* @param sourceEndTokenIndex
* @param offset
*/
public static void copyViewsFromTo(TextAnnotation ta, TextAnnotation newTA, int sourceStartTokenIndex,
int sourceEndTokenIndex, int offset) {
for (String vuName : ta.getAvailableViews()) {
if (ViewNames.TOKENS.equals(vuName) || ViewNames.SENTENCE.equals(vuName))
continue;
copyViewFromTo(vuName, ta, newTA, sourceStartTokenIndex, sourceEndTokenIndex, offset);
}
}
代码示例来源:origin: CogComp/cogcomp-nlp
/**
* copy views from the relevant span from ta to newTA. If ta is smaller than newTA, map all constituents,
* changing offsets according to the value 'offset'.
* Otherwise, only map those constituents within the span sourceStartTokenIndex, sourceEndTokenIndex to newTA.
*
* @param ta
* @param newTA
* @param sourceStartTokenIndex
* @param sourceEndTokenIndex
* @param offset
*/
public static void copyViewsFromTo(TextAnnotation ta, TextAnnotation newTA, int sourceStartTokenIndex,
int sourceEndTokenIndex, int offset) {
for (String vuName : ta.getAvailableViews()) {
if (ViewNames.TOKENS.equals(vuName) || ViewNames.SENTENCE.equals(vuName))
continue;
copyViewFromTo(vuName, ta, newTA, sourceStartTokenIndex, sourceEndTokenIndex, offset);
}
}
代码示例来源:origin: CogComp/cogcomp-nlp
public static String printTextAnnotation(TextAnnotation ta ) throws IOException
{
StringBuilder bldr = new StringBuilder();
bldr.append( "TextAnnotation for text: " );
bldr.append( ta.getText() );
for ( String vName: ta.getAvailableViews() ) {
bldr.append(printView( ta.getView( vName )));
}
return bldr.toString();
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-core-utilities
public static String printTextAnnotation(TextAnnotation ta ) throws IOException
{
StringBuilder bldr = new StringBuilder();
bldr.append( "TextAnnotation for text: " );
bldr.append( ta.getText() );
for ( String vName: ta.getAvailableViews() ) {
bldr.append(printView( ta.getView( vName )));
}
return bldr.toString();
}
代码示例来源:origin: CogComp/cogcomp-nlp
static public void printTextAnnotation(PrintStream out, TextAnnotation ta) {
out.println("TextAnnotation with id: " + ta.getId());
String rawText = ta.getText();
out.println("Raw Text: " + rawText);
out.println(getLineFill());
out.println("TextAnnotation Views:");
for (String name : ta.getAvailableViews()) {
out.println("View Name: " + name);
out.println(ta.getView(name).toString());
out.println(getLineFill());
}
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-core-utilities
static public void printTextAnnotation(PrintStream out, TextAnnotation ta) {
out.println("TextAnnotation with id: " + ta.getId());
String rawText = ta.getText();
out.println("Raw Text: " + rawText);
out.println(getLineFill());
out.println("TextAnnotation Views:");
for (String name : ta.getAvailableViews()) {
out.println("View Name: " + name);
out.println(ta.getView(name).toString());
out.println(getLineFill());
}
}
代码示例来源:origin: CogComp/cogcomp-nlp
@Override
public TextAnnotation createAnnotatedTextAnnotation(String corpusId, String textId, String text)
throws AnnotatorException {
TextAnnotation ta = createBasicTextAnnotation(corpusId, textId, text);
if (annotationCache != null && annotationCache.contains(ta)) {
ta = annotationCache.getTextAnnotation(ta);
// clone the views
HashSet<String> views = new HashSet<>(viewProviders.keySet());
views.removeAll(ta.getAvailableViews());
if(views.size() == 0) {
// it contains the required views; otherwise continue
return ta;
}
}
for (String viewName : viewProviders.keySet())
addView(ta, viewName);
return ta;
}
代码示例来源:origin: CogComp/cogcomp-nlp
@Override
public TextAnnotation createAnnotatedTextAnnotation(String corpusId, String textId,
String text, Tokenizer.Tokenization tokenization) throws AnnotatorException {
TextAnnotation ta = createBasicTextAnnotation(corpusId, textId, text, tokenization);
if (annotationCache != null && annotationCache.contains(ta)) {
ta = annotationCache.getTextAnnotation(ta);
// clone the views
HashSet<String> views = new HashSet<>(viewProviders.keySet());
views.removeAll(ta.getAvailableViews());
if(views.size() == 0) {
// it contains the required views; otherwise continue
return ta;
}
}
for (String viewName : viewProviders.keySet())
addView(ta, viewName);
return ta;
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-curator
@Override
public TextAnnotation createAnnotatedTextAnnotation(String corpusId, String textId, String text)
throws AnnotatorException {
TextAnnotation ta = createBasicTextAnnotation(corpusId, textId, text);
if (annotationCache != null && annotationCache.contains(ta)) {
ta = annotationCache.getTextAnnotation(ta);
// clone the views
HashSet<String> views = new HashSet<>(viewProviders.keySet());
views.removeAll(ta.getAvailableViews());
if(views.size() == 0) {
// it contains the required views; otherwise continue
return ta;
}
}
for (String viewName : viewProviders.keySet())
addView(ta, viewName);
return ta;
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-curator
@Override
public TextAnnotation createAnnotatedTextAnnotation(String corpusId, String textId,
String text, Tokenizer.Tokenization tokenization) throws AnnotatorException {
TextAnnotation ta = createBasicTextAnnotation(corpusId, textId, text, tokenization);
if (annotationCache != null && annotationCache.contains(ta)) {
ta = annotationCache.getTextAnnotation(ta);
// clone the views
HashSet<String> views = new HashSet<>(viewProviders.keySet());
views.removeAll(ta.getAvailableViews());
if(views.size() == 0) {
// it contains the required views; otherwise continue
return ta;
}
}
for (String viewName : viewProviders.keySet())
addView(ta, viewName);
return ta;
}
代码示例来源:origin: CogComp/cogcomp-nlp
@Override
public TextAnnotation createAnnotatedTextAnnotation(String corpusId, String textId,
String text, Set<String> viewNames) throws AnnotatorException {
TextAnnotation ta = createBasicTextAnnotation(corpusId, textId, text);
if (annotationCache != null && annotationCache.contains(ta)) {
ta = annotationCache.getTextAnnotation(ta);
// clone the views
HashSet<String> views = new HashSet<>(viewProviders.keySet());
views.removeAll(ta.getAvailableViews());
if(views.size() == 0) {
// it contains the required views; otherwise continue
return ta;
}
}
for (String viewName : viewNames)
addView(ta, viewName);
return ta;
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-curator
@Override
public TextAnnotation createAnnotatedTextAnnotation(String corpusId, String textId,
String text, Set<String> viewNames) throws AnnotatorException {
TextAnnotation ta = createBasicTextAnnotation(corpusId, textId, text);
if (annotationCache != null && annotationCache.contains(ta)) {
ta = annotationCache.getTextAnnotation(ta);
// clone the views
HashSet<String> views = new HashSet<>(viewProviders.keySet());
views.removeAll(ta.getAvailableViews());
if(views.size() == 0) {
// it contains the required views; otherwise continue
return ta;
}
}
for (String viewName : viewNames)
addView(ta, viewName);
return ta;
}
代码示例来源:origin: CogComp/cogcomp-nlp
@Override
public TextAnnotation createAnnotatedTextAnnotation(String corpusId, String textId,
String text, Tokenizer.Tokenization tokenization, Set<String> viewNames)
throws AnnotatorException {
TextAnnotation ta = createBasicTextAnnotation(corpusId, textId, text, tokenization);
if (annotationCache != null && annotationCache.contains(ta)) {
ta = annotationCache.getTextAnnotation(ta);
// clone the views
HashSet<String> views = new HashSet<>(viewProviders.keySet());
views.removeAll(ta.getAvailableViews());
if(views.size() == 0) {
// it contains the required views; otherwise continue
return ta;
}
}
for (String viewName : viewNames)
addView(ta, viewName);
return ta;
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-curator
@Override
public TextAnnotation createAnnotatedTextAnnotation(String corpusId, String textId,
String text, Tokenizer.Tokenization tokenization, Set<String> viewNames)
throws AnnotatorException {
TextAnnotation ta = createBasicTextAnnotation(corpusId, textId, text, tokenization);
if (annotationCache != null && annotationCache.contains(ta)) {
ta = annotationCache.getTextAnnotation(ta);
// clone the views
HashSet<String> views = new HashSet<>(viewProviders.keySet());
views.removeAll(ta.getAvailableViews());
if(views.size() == 0) {
// it contains the required views; otherwise continue
return ta;
}
}
for (String viewName : viewNames)
addView(ta, viewName);
return ta;
}
代码示例来源:origin: CogComp/cogcomp-nlp
public static void main(String[] args) {
ServerClientAnnotator annotator = new ServerClientAnnotator();
String sentA = "This is the best sentence ever.";
annotator.setUrl("http://austen.cs.illinois.edu", "8080");
annotator.setViews(ViewNames.POS, ViewNames.LEMMA);
annotator.useCaching();
try {
TextAnnotation ta = annotator.annotate(sentA);
logger.info(ta.getAvailableViews().toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-pipeline-client
public static void main(String[] args) {
ServerClientAnnotator annotator = new ServerClientAnnotator();
String sentA = "This is the best sentence ever.";
annotator.setUrl("http://austen.cs.illinois.edu", "8080");
annotator.setViews(ViewNames.POS, ViewNames.LEMMA);
annotator.useCaching();
try {
TextAnnotation ta = annotator.annotate(sentA);
logger.info(ta.getAvailableViews().toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: CogComp/cogcomp-nlp
@Override
public TextAnnotation createAnnotatedTextAnnotation(String corpusId, String textId, String text, Set<String> viewsToAnnotate) throws AnnotatorException {
TextAnnotation ta = createBasicTextAnnotation(corpusId, textId, text);
// if it already contains its, return it.
if (!forceUpdate && !disableCache && annotationCache.contains(ta)) {
TextAnnotation taFromCache = annotationCache.getTextAnnotation(ta);
boolean containsAll = true;
for(String vu : viewsToAnnotate) {
if(!taFromCache.getAvailableViews().contains(vu)) {
containsAll = false;
break;
}
}
if(containsAll) return taFromCache;
}
return addViewsAndCache(ta, viewsToAnnotate, false);
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-core-utilities
@Override
public TextAnnotation createAnnotatedTextAnnotation(String corpusId, String textId, String text, Set<String> viewsToAnnotate) throws AnnotatorException {
TextAnnotation ta = createBasicTextAnnotation(corpusId, textId, text);
// if it already contains its, return it.
if (!forceUpdate && !disableCache && annotationCache.contains(ta)) {
TextAnnotation taFromCache = annotationCache.getTextAnnotation(ta);
boolean containsAll = true;
for(String vu : viewsToAnnotate) {
if(!taFromCache.getAvailableViews().contains(vu)) {
containsAll = false;
break;
}
}
if(containsAll) return taFromCache;
}
return addViewsAndCache(ta, viewsToAnnotate, false);
}
代码示例来源:origin: CogComp/cogcomp-nlp
@Override
protected void addView(TextAnnotation ta) throws AnnotatorException {
SpanLabelView view = new SpanLabelView(ViewNames.QUESTION_TYPE, ViewNames.QUESTION_TYPE, ta, 1.0);
assert ta.getAvailableViews().contains(ViewNames.SHALLOW_PARSE) && ta.getAvailableViews().contains(ViewNames.NER_CONLL) &&
ta.getAvailableViews().contains(ViewNames.NER_ONTONOTES): "the annotator does not have the required views ";
String fineLabel = fine.discreteValue(ta);
Double fineLabelScore = fine.scores(ta).getScore(fineLabel).score;
String coarseLabel = coarse.discreteValue(ta);
Double coarseLabelScore = coarse.scores(ta).getScore(coarseLabel).score;
Constituent cFine = new Constituent(fineLabel, fineLabelScore, ViewNames.QUESTION_TYPE,
ta, 0, ta.getTokens().length);
Constituent cCoarse = new Constituent(coarseLabel, coarseLabelScore, ViewNames.QUESTION_TYPE, ta, 0, ta.getTokens().length);
view.addConstituent(cCoarse);
view.addConstituent(cFine);
ta.addView(ViewNames.QUESTION_TYPE, view);
}
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-question-typer
@Override
protected void addView(TextAnnotation ta) throws AnnotatorException {
SpanLabelView view = new SpanLabelView(ViewNames.QUESTION_TYPE, ViewNames.QUESTION_TYPE, ta, 1.0);
assert ta.getAvailableViews().contains(ViewNames.SHALLOW_PARSE) && ta.getAvailableViews().contains(ViewNames.NER_CONLL) &&
ta.getAvailableViews().contains(ViewNames.NER_ONTONOTES): "the annotator does not have the required views ";
String fineLabel = fine.discreteValue(ta);
Double fineLabelScore = fine.scores(ta).getScore(fineLabel).score;
String coarseLabel = coarse.discreteValue(ta);
Double coarseLabelScore = coarse.scores(ta).getScore(coarseLabel).score;
Constituent cFine = new Constituent(fineLabel, fineLabelScore, ViewNames.QUESTION_TYPE,
ta, 0, ta.getTokens().length);
Constituent cCoarse = new Constituent(coarseLabel, coarseLabelScore, ViewNames.QUESTION_TYPE, ta, 0, ta.getTokens().length);
view.addConstituent(cCoarse);
view.addConstituent(cFine);
ta.addView(ViewNames.QUESTION_TYPE, view);
}
}
内容来源于网络,如有侵权,请联系作者删除!