private Instance getSingleInstancePair(Instance anInstance, JCas aJCas) throws TextClassificationException { try { int jcasId = JCasUtil.selectSingle(aJCas, JCasId.class).getId(); if (addInstanceId) { anInstance.addFeature(InstanceIdFeature.retrieve(aJCas)); } for (FeatureExtractorResource_ImplBase featExt : featureExtractors) { if (!(featExt instanceof PairFeatureExtractor)) { throw new TextClassificationException( "Using non-pair FE in pair mode: " + featExt.getResourceName()); } JCas view1 = aJCas.getView(Constants.PART_ONE); JCas view2 = aJCas.getView(Constants.PART_TWO); anInstance.setOutcomes(getOutcomes(aJCas, null)); anInstance.setWeight(getWeight(aJCas, null)); anInstance.setJcasId(jcasId); anInstance.addFeatures(((PairFeatureExtractor) featExt).extract(view1, view2)); } } catch (CASException e) { throw new TextClassificationException(e); } return anInstance; }
private Instance getSingleInstancePair(Instance anInstance, JCas aJCas) throws TextClassificationException { try { int jcasId = JCasUtil.selectSingle(aJCas, JCasId.class).getId(); if (addInstanceId) { anInstance.addFeature(InstanceIdFeature.retrieve(aJCas)); } for (FeatureExtractorResource_ImplBase featExt : featureExtractors) { if (!(featExt instanceof PairFeatureExtractor)) { throw new TextClassificationException( "Using non-pair FE in pair mode: " + featExt.getResourceName()); } JCas view1 = aJCas.getView(Constants.PART_ONE); JCas view2 = aJCas.getView(Constants.PART_TWO); anInstance.setOutcomes(getOutcomes(aJCas, null)); anInstance.setWeight(getWeight(aJCas, null)); anInstance.setJcasId(jcasId); anInstance.addFeatures(((PairFeatureExtractor) featExt).extract(view1, view2)); } } catch (CASException e) { throw new TextClassificationException(e); } return anInstance; }