Examples of EditDistance


Examples of bgu.bio.algorithms.alignment.EditDistance

        return result.toString();
      } else if (command.equals("script.ed")) {
        String str1 = obj.optString("string1").toUpperCase();
        String str2 = obj.optString("string2").toUpperCase();
        EditDistance ed = new EditDistance(str1, str2,
            new IdentityEditDistanceScoringMatrix());
        if (str1 == null || str2 == null)
          return error("got no strings");

        ed.buildMatrix();
        int score = (int) ed.getAlignmentScore();
        String[] res = ed.printAlignments();

        result.put("command", "OK");
        result.put("score", score);
        result.put("line1", res[0]);
        result.put("middle", res[1]);
View Full Code Here

Examples of bgu.bio.algorithms.alignment.EditDistance

      response.setResponse("No Strings are given");
      return response;
    }
    string1 = string1 == null ? "" : string1;
    string2 = string2 == null ? "" : string2;
    EditDistance ed = new EditDistance(string1, string2,
        new IdentityEditDistanceScoringMatrix());

    int score = (int) ed.getAlignmentScore();
    String[] res = ed.printAlignments();
    response.setResponse(Arrays.toString(res));
    return response;
  }
View Full Code Here

Examples of de.lmu.ifi.dbs.elki.evaluation.clustering.EditDistance

    ypos = addBarChart(svgp, parent, ypos, "Purity", 1, setm.purity());
    ypos = addBarChart(svgp, parent, ypos, "Inverse Purity", 1, setm.inversePurity());

    ypos = addHeader(svgp, parent, ypos, "Editing-distance measures");

    EditDistance edit = cont.getEdit();
    ypos = addBarChart(svgp, parent, ypos, "F1-Measure", 1, edit.f1Measure());
    ypos = addBarChart(svgp, parent, ypos, "Precision", 1, edit.editDistanceFirst());
    ypos = addBarChart(svgp, parent, ypos, "Recall", 1, edit.editDistanceSecond());

    ypos = addHeader(svgp, parent, ypos, "Gini measures");

    final MeanVariance gini = cont.averageSymmetricGini();
    ypos = addBarChart(svgp, parent, ypos, "Mean +-" + FormatUtil.format(gini.getSampleStddev(), FormatUtil.NF4), 1, gini.getMean());
View Full Code Here

Examples of edu.stanford.nlp.util.EditDistance

   */
  public static List<Integer> getSubListIndex(String[] l1, String[] l2, String[] subl2, Set<String> englishWords, HashSet<String> seenFuzzyMatches,
      int minLen4Fuzzy) {
    if (l1.length > l2.length)
      return null;
    EditDistance editDistance = new EditDistance(true);
    List<Integer> allIndices = new ArrayList<Integer>();
    boolean matched = false;
    int index = -1;
    int lastUnmatchedIndex = 0;
    for (int i = 0; i < l2.length;) {

      for (int j = 0; j < l1.length;) {
        boolean d1 = false, d2 = false;
        boolean compareFuzzy = true;
        if (englishWords.contains(l2[i]) || englishWords.contains(subl2[i]) || l2[i].length() <= minLen4Fuzzy || subl2[i].length() <= minLen4Fuzzy)
          compareFuzzy = false;
        if (compareFuzzy == false || l1[j].length() <= minLen4Fuzzy) {
          d1 = l1[j].equals(l2[i]) ? true : false;
          if (!d1)
            d2 = subl2[i].equals(l1[j]) ? true : false;
        } else {
          String combo = l1[j] + "#" + l2[i];
          if (l1[j].equals(l2[i]) || seenFuzzyMatches.contains(combo))
            d1 = true;
          else {
            d1 = editDistance.score(l1[j], l2[i]) <= 1;
            if (!d1) {
              String combo2 = l1[j] + "#" + subl2[i];
              if (l1[j].equals(subl2[i]) || seenFuzzyMatches.contains(combo2))
                d2 = true;
              else {
                d2 = editDistance.score(l1[j], subl2[i]) <= 1;
                if (d2) {
                  // System.out.println(l1[j] + " matched with " + subl2[i]);
                  seenFuzzyMatches.add(combo2);
                }
              }
View Full Code Here

Examples of edu.stanford.nlp.util.EditDistance

   * deletion, or insertion.  If not match exists, returns null.
   */
  private static String getOneSubstitutionMatch(String word, Set<String> set) {
    // TODO (?) pass the EditDistance around more places to make this
    // more efficient.  May not really matter.
    EditDistance ed = new EditDistance();
    for(String cur : set) {
      if(isOneSubstitutionMatch(word, cur, ed))
        return cur;
    }
    return null;
View Full Code Here

Examples of edu.stanford.nlp.util.EditDistance

        s = s.substring(0, start) + s.substring(end);
        // err.println("; Result is " + s);
      }
    }
    if(!foundMultiplier) {
      EditDistance ed = new EditDistance();
      for (String moneyTag : moneyMultipliers.keySet()) {
        if(isOneSubstitutionMatch(origSSplit[origSSplit.length - 1],
                                  moneyTag, ed)) {
          s = s.replaceAll(moneyTag, "");
          multiplier *= moneyMultipliers.get(moneyTag);
View Full Code Here

Examples of org.spockframework.runtime.condition.EditDistance

    if (!expr.isEqualityComparison(String.class, GString.class)) return null;

    // values can't be null here
    String str1 = expr.getChildren().get(0).getValue().toString();
    String str2 = expr.getChildren().get(1).getValue().toString();
    EditDistance dist = new EditDistance(str1, str2);
    return String.format("false\n%d difference%s (%d%% similarity)\n%s",
        dist.getDistance(), dist.getDistance() == 1 ? "" : "s", dist.getSimilarityInPercent(),
        new EditPathRenderer().render(str1, str2, dist.calculatePath()));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.