/** Converts a Proto FieldPath to its API counterpart. */ private FieldPath convertPath(TestDefinition.FieldPath fieldPath) { return FieldPath.of(fieldPath.getFieldList().toArray(new String[0])); }
public static void printUnits(List<UnitConfig> unitConfigList) throws InterruptedException, CouldNotPerformException { // sort by scope Collections.sort(unitConfigList, new Comparator<UnitConfig>() { @Override public int compare(UnitConfig o1, UnitConfig o2) { try { return ScopeGenerator.generateStringRep(o1.getScope()).compareTo(ScopeGenerator.generateStringRep(o2.getScope())); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory("Could not sort scope!", ex, System.err); return 0; } } }); // calculate max unit label length int maxUnitLabelLength = 0; int maxLocationUnitLabelLength = 0; int maxScopeLength = 0; int maxAliasLength = 0; for (final UnitConfig unitConfig : unitConfigList) { maxUnitLabelLength = Math.max(maxUnitLabelLength, unitConfig.getLabel().length()); maxLocationUnitLabelLength = Math.max(maxLocationUnitLabelLength, getLocationLabel(unitConfig).length()); maxScopeLength = Math.max(maxScopeLength, ScopeGenerator.generateStringRep(unitConfig.getScope()).length()); maxAliasLength = Math.max(maxAliasLength, Arrays.toString(unitConfig.getAliasList().toArray()).length()); } // print for (final UnitConfig unitConfig : unitConfigList) { printUnit(unitConfig, maxAliasLength, maxUnitLabelLength, maxLocationUnitLabelLength, maxScopeLength); } }
public static com.quorum.tessera.api.model.SendRequest toModel(com.quorum.tessera.grpc.api.SendRequest grpcObject) { com.quorum.tessera.api.model.SendRequest sendRequest = new com.quorum.tessera.api.model.SendRequest(); sendRequest.setTo(grpcObject.getToList().toArray(new String[0])); if (!grpcObject.getFrom().isEmpty()) { sendRequest.setFrom(grpcObject.getFrom()); } sendRequest.setPayload(grpcObject.getPayload().toByteArray()); return sendRequest; }
public static com.quorum.tessera.api.model.SendRequest toModel(com.quorum.tessera.grpc.api.SendRequest grpcObject) { com.quorum.tessera.api.model.SendRequest sendRequest = new com.quorum.tessera.api.model.SendRequest(); sendRequest.setTo(grpcObject.getToList().toArray(new String[0])); if (!grpcObject.getFrom().isEmpty()) { sendRequest.setFrom(grpcObject.getFrom()); } sendRequest.setPayload(grpcObject.getPayload().toByteArray()); return sendRequest; }
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; }
break; case REPEATED_STRING: opArgs[i] = arg.getStringArrayValuesList().toArray( new String[arg.getStringArrayValuesCount()]); break;
break; case REPEATED_STRING: opArgs[i] = arg.getStringArrayValuesList().toArray( new String[arg.getStringArrayValuesCount()]); break;
String[] newValues = new String[c.getAnnotationBoundary().getChangeCount()]; if (c.getAnnotationBoundary().getEndCount() > 0) { c.getAnnotationBoundary().getEndList().toArray(ends);