use of edu.illinois.cs.cogcomp.core.datastructures.ViewTypes in project cogcomp-nlp by CogComp.
the class CuratorClient method getTextAnnotationView.
public edu.illinois.cs.cogcomp.core.datastructures.textannotation.View getTextAnnotationView(TextAnnotation ta, String viewName) throws TException, AnnotationFailedException, ServiceUnavailableException, SocketException {
edu.illinois.cs.cogcomp.core.datastructures.textannotation.View view;
Record record = addRecordViewFromCurator(ta.getText(), TextAnnotationUtilities.getSentenceList(ta), viewName);
ViewTypes viewType = ViewNames.getViewType(viewName);
if (viewType == ViewTypes.TOKEN_LABEL_VIEW) {
Labeling labeling = record.getLabelViews().get(convertCuratorViewName(viewName));
view = CuratorDataStructureInterface.alignLabelingToTokenLabelView(viewName, ta, labeling);
} else if (viewType == ViewTypes.SPAN_LABEL_VIEW) {
boolean allowOverlappingSpans = false;
if (viewName.equals(ViewNames.WIKIFIER))
allowOverlappingSpans = true;
Labeling labeling = record.getLabelViews().get(convertCuratorViewName(viewName));
view = CuratorDataStructureInterface.alignLabelingToSpanLabelView(viewName, ta, labeling, allowOverlappingSpans);
} else if (viewType == ViewTypes.DEPENDENCY_VIEW) {
Forest depForest = record.getParseViews().get(convertCuratorViewName(viewName));
view = CuratorDataStructureInterface.alignForestToDependencyView(viewName, ta, depForest);
} else if (viewType == ViewTypes.PARSE_VIEW) {
Forest parseForest = record.getParseViews().get(convertCuratorViewName(viewName));
view = CuratorDataStructureInterface.alignForestToParseTreeView(viewName, ta, parseForest);
} else if (viewType == ViewTypes.PREDICATE_ARGUMENT_VIEW) {
Forest forest = record.getParseViews().get(convertCuratorViewName(viewName));
view = CuratorDataStructureInterface.alignForestToPredicateArgumentView(viewName, ta, forest);
} else if (viewType == ViewTypes.COREF_VIEW) {
Clustering corefClustering = record.getClusterViews().get(convertCuratorViewName(viewName));
view = CuratorDataStructureInterface.alignClusteringToCoreferenceView(viewName, ta, corefClustering);
} else
throw new AnnotationFailedException("Unrecognised view type " + viewType);
return view;
}