BagOfWordsSimilarity extends BagOfWordsScoring implements
		DistanceCalculation { @Override public DistanceValue calculation(JCas aCas) throws DistanceComponentException { double distance = 0.0d; double unnormalized = 0.0d; Vector<Double> scoresVector; try { scoresVector = calculateScores(aCas); } catch (ScoringComponentException e) { throw new DistanceComponentException(e.getMessage()); } unnormalized = scoresVector.get(0); distance = 1.0d - unnormalized; return new SimilarityValue(distance, unnormalized); }  @Override String getComponentName(); @Override String getInstanceName(); @Override DistanceValue calculation(JCas aCas);  }
@Test public void test() { BagOfWordsSimilarity bs = new BagOfWordsSimilarity(); JCas cas = null; OpenNLPTaggerEN lap = null; File inputFile = new File("./src/test/resources/small.xml"); File outputDir = new File("./target/EN/"); if (!outputDir.exists()) { outputDir.mkdirs(); } try { lap = new OpenNLPTaggerEN(); lap.processRawInputFormat(inputFile, outputDir); for (File xmi : outputDir.listFiles()) { if (!xmi.getName().endsWith(".xmi")) { continue; } cas = PlatformCASProber.probeXmi(xmi, System.out); DistanceValue bowsim = bs.calculation(cas); System.out.println(bowsim.getDistance()); System.out.println(bowsim.getUnnormalizedValue()); System.out.println(bs.calculateScores(cas)); cas.reset(); } } catch(LAPException e) { System.err.println(e.getMessage()); } catch (DistanceComponentException e) { System.err.println(e.getMessage()); } catch (ScoringComponentException e) { System.err.println(e.getMessage()); } }