String value = doc.metadata.get(metadataKey); if (!value.isEmpty()) { ta.addAttribute(metadataKey, value);
String value = doc.metadata.get(metadataKey); if (!value.isEmpty()) { ta.addAttribute(metadataKey, value);
String value = doc.metadata.get(metadataKey); if (!value.isEmpty()) { ta.addAttribute(metadataKey, value);
String value = doc.metadata.get(metadataKey); if (!value.isEmpty()) { ta.addAttribute(metadataKey, value);
String value = doc.metadata.get(metadataKey); if (!value.isEmpty()) { ta.addAttribute(metadataKey, value);
public static TextAnnotation readTextAnnotation(TextAnnotationProto taImpl) throws Exception { String corpusId = taImpl.getCorpusId(); String id = taImpl.getId(); String text = taImpl.getText(); String[] tokens = taImpl.getTokensList().toArray(new String[0]); Pair<Pair<String, Double>, int[]> sentences = readSentences(taImpl.getSentences()); IntPair[] offsets = TokenUtils.getTokenOffsets(text, tokens); TextAnnotation ta = new TextAnnotation(corpusId, id, text, offsets, tokens, sentences.getSecond()); for (ViewProto view : taImpl.getViewsList()) { String viewName = view.getViewName(); List<View> topKViews = new ArrayList<>(); for (ViewDataProto viewData : view.getViewDataList()) { topKViews.add(readViewData(viewData, ta)); } if (viewName.equals(ViewNames.SENTENCE)) ta.removeView(viewName); ta.addTopKView(viewName, topKViews); if (viewName.equals(ViewNames.SENTENCE)) ta.setSentences(); } for (Map.Entry<String, String> entry: taImpl.getPropertiesMap().entrySet()) { ta.addAttribute(entry.getKey(), entry.getValue()); } return ta; }
public static TextAnnotation readTextAnnotation(TextAnnotationProto taImpl) throws Exception { String corpusId = taImpl.getCorpusId(); String id = taImpl.getId(); String text = taImpl.getText(); String[] tokens = taImpl.getTokensList().toArray(new String[0]); Pair<Pair<String, Double>, int[]> sentences = readSentences(taImpl.getSentences()); IntPair[] offsets = TokenUtils.getTokenOffsets(text, tokens); TextAnnotation ta = new TextAnnotation(corpusId, id, text, offsets, tokens, sentences.getSecond()); for (ViewProto view : taImpl.getViewsList()) { String viewName = view.getViewName(); List<View> topKViews = new ArrayList<>(); for (ViewDataProto viewData : view.getViewDataList()) { topKViews.add(readViewData(viewData, ta)); } if (viewName.equals(ViewNames.SENTENCE)) ta.removeView(viewName); ta.addTopKView(viewName, topKViews); if (viewName.equals(ViewNames.SENTENCE)) ta.setSentences(); } for (Map.Entry<String, String> entry: taImpl.getPropertiesMap().entrySet()) { ta.addAttribute(entry.getKey(), entry.getValue()); } return ta; }