StringComparator left = new StringComparator(pl.toString()); StringComparator right = new StringComparator(pr.toString()); org.eclipse.compare.internal.LCSSettings settings = new org.eclipse.compare.internal.LCSSettings(); String word = left.getLeaf(i); i<(rd[x].leftStart()+rd[x].leftLength()); i++) { String word = left.getLeaf(i); i<(rd[x].rightStart()+rd[x].rightLength()); i++) { String word = right.getLeaf(i); log.debug(word); rightWordCounter++;
public double getMatchRatio(StringComparator other) { LCSSettings settings = new LCSSettings(); settings.setUseGreedyMethod(true); settings.setPowLimit(1.5); settings.setTooLong(150 * 150); RangeDifference[] differences = RangeDifferencer.findDifferences( settings, other, this); int distanceOther = 0; for (RangeDifference d : differences) { distanceOther += d.leftLength(); } int distanceThis = 0; for (RangeDifference d : differences) { distanceThis += d.rightLength(); } return ((0.0 + distanceOther) / other.getRangeCount() + (0.0 + distanceThis) / getRangeCount()) / 2; } }
StringComparator left = new StringComparator(pl.toString()); StringComparator right = new StringComparator(pr.toString()); org.eclipse.compare.internal.LCSSettings settings = new org.eclipse.compare.internal.LCSSettings(); String word = left.getLeaf(i); i<(rd[x].leftStart()+rd[x].leftLength()); i++) { String word = left.getLeaf(i); i<(rd[x].rightStart()+rd[x].rightLength()); i++) { String word = right.getLeaf(i); log.debug(word); rightWordCounter++;
public double getMatchRatio(StringComparator other) { LCSSettings settings = new LCSSettings(); settings.setUseGreedyMethod(true); settings.setPowLimit(1.5); settings.setTooLong(150 * 150); RangeDifference[] differences = RangeDifferencer.findDifferences( settings, other, this); int distanceOther = 0; for (RangeDifference d : differences) { distanceOther += d.leftLength(); } int distanceThis = 0; for (RangeDifference d : differences) { distanceThis += d.rightLength(); } return ((0.0 + distanceOther) / other.getRangeCount() + (0.0 + distanceThis) / getRangeCount()) / 2; } }
private static String toRangeString(StringComparator sc, int start, int length, boolean space) { // This method only exists for debug... StringBuilder result = new StringBuilder(); for (int x=start; x<(start+length); x++) { if (space) { result.append(sc.getLeaf(x) + " "); } else { result.append(sc.getLeaf(x)); } } return result.toString(); }
private static String toRangeString(StringComparator sc, int start, int length, boolean space) { // This method only exists for debug... StringBuilder result = new StringBuilder(); for (int x=start; x<(start+length); x++) { if (space) { result.append(sc.getLeaf(x) + " "); } else { result.append(sc.getLeaf(x)); } } return result.toString(); }