Examples of diff_match_patch


Examples of name.fraser.neil.plaintext.diff_match_patch

  }
 
  private void assertHtmlEquals(String expected, String serialized) {
    // Compute the diff of expected vs. serialized, and disregard constructs that we don't
    // care about, such as whitespace deltas and differently-computed escape sequences.
    diff_match_patch dmp = new diff_match_patch();
    LinkedList<Diff> diffs = dmp.diff_main(expected, serialized);
    while (diffs.size() > 0) {
      Diff cur = diffs.removeFirst();
      switch (cur.operation) {
      case DELETE:
        if (StringUtils.isBlank(cur.text) || "amp;".equalsIgnoreCase(cur.text)) {
View Full Code Here

Examples of name.fraser.neil.plaintext.diff_match_patch

  public ShareObj(String file) {
    if (!idPattern.matcher(file).matches()) {
      throw new IllegalArgumentException("Illegal id " + file);
    }
    this.file = file;
    this.dmp = new diff_match_patch();
    this.dmp.Diff_Timeout = 0.5f;
    // List of unacknowledged edits sent to the server.
    this.editStack = new LinkedList<Object[]>();
  }
View Full Code Here

Examples of name.fraser.neil.plaintext.diff_match_patch

  public ShareObj(String file) {
    if (!idPattern.matcher(file).matches()) {
      throw new IllegalArgumentException("Illegal id " + file);
    }
    this.file = file;
    this.dmp = new diff_match_patch();
    this.dmp.Diff_Timeout = 0.5f;
    // List of unacknowledged edits sent to the server.
    this.editStack = new LinkedList<Object[]>();
  }
View Full Code Here

Examples of name.fraser.neil.plaintext.diff_match_patch

        history.setProperty(Page.DATE, now);
        history.setProperty(Page.UPDATE, p.isUpdate());
        history.setProperty(Page.USER, identity);

        // create the diff
        diff_match_patch dmp = new diff_match_patch();
        // create the diff
        LinkedList<Diff> diffs = dmp.diff_main(oldPage.getContent(),
            p.getContent());
        // make the diff human readable
        dmp.diff_cleanupSemantic(diffs);
        // convert the diff to html
        String diff = dmp.diff_prettyHtml(diffs);

        history.setProperty(Page.DIFF, new Text(diff));

        datastore.put(history);
      }
View Full Code Here

Examples of name.fraser.neil.plaintext.diff_match_patch

  }
 
  private void assertHtmlEquals(String expected, String serialized) {
    // Compute the diff of expected vs. serialized, and disregard constructs that we don't
    // care about, such as whitespace deltas and differently-computed escape sequences.
    diff_match_patch dmp = new diff_match_patch();
    LinkedList<Diff> diffs = dmp.diff_main(expected, serialized);
    while (!diffs.isEmpty()) {
      Diff cur = diffs.removeFirst();
      switch (cur.operation) {
      case DELETE:
        if (StringUtils.isBlank(cur.text) || "amp;".equalsIgnoreCase(cur.text)) {
View Full Code Here

Examples of name.fraser.neil.plaintext.diff_match_patch

        HtmlView htmlView = new HtmlView();
        StringBuffer newHtml = new StringBuffer();
        StringBuffer oldHtml = new StringBuffer();

        diff_match_patch dmp = new diff_match_patch();
        LinkedList<diff_match_patch.Diff> diffs = dmp.diff_main(oldContent, newContent);

        for (diff_match_patch.Diff diff : diffs) {
            String text = diff.text.replace("&", "&amp;").replace("<", "&lt;")
                    .replace(">", "&gt;").replace(XmlUtil.crlf, "<br>");
            if (diff.operation == diff_match_patch.Operation.INSERT) {
View Full Code Here

Examples of name.fraser.neil.plaintext.diff_match_patch

  }

  public static String runComparison(String s1, String s2) {
    s1 = s1.replace("<br/>", "\n");
    s2 = s2.replace("<br/>", "\n");
    diff_match_patch dmp = new diff_match_patch();
    dmp.Diff_EditCost = 30;
    LinkedList<Diff> ll = dmp.diff_main(s1, s2);
    dmp.diff_cleanupEfficiency(ll);
    return dmp.diff_prettyHtml(ll);
  }
View Full Code Here

Examples of name.fraser.neil.plaintext.diff_match_patch

  }

  private void assertHtmlEquals(String expected, String serialized) {
    // Compute the diff of expected vs. serialized, and disregard constructs that we don't
    // care about, such as whitespace deltas and differently-computed escape sequences.
    diff_match_patch dmp = new diff_match_patch();
    LinkedList<Diff> diffs = dmp.diff_main(expected, serialized);
    while (!diffs.isEmpty()) {
      Diff cur = diffs.removeFirst();
      switch (cur.operation) {
      case DELETE:
        if (StringUtils.isBlank(cur.text) || "amp;".equalsIgnoreCase(cur.text)) {
View Full Code Here

Examples of name.fraser.neil.plaintext.diff_match_patch

    Map<String, Object> properties = webSocketData.getNodeData();
    String patch                   = (String) properties.get("patch");

    if (node != null) {

      diff_match_patch dmp      = new diff_match_patch();
      String oldText            = node.getProperty(Content.content);
      LinkedList<Patch> patches = (LinkedList<Patch>) dmp.patch_fromText(patch);
      final Object[] results    = dmp.patch_apply(patches, oldText);

      try {
        node.setProperty(Content.content, results[0].toString());
       
      } catch (Throwable t) {
View Full Code Here

Examples of name.neil.fraser.plaintext.diff_match_patch

    // Since we can't tell which new paragraph mapped to which old one to do a straight up diff,
    // this method gets the edit distance between each remaining new paragraph
    // and each remaining old paragraph.  It finds the minimum edit distance for each new
    // paragraph, and if it's higher than the threshold,  we highlight it.
    if (!newParagraphs.isEmpty()) {
      diff_match_patch dmp = new diff_match_patch();
      for (Node newParagraph : newParagraphs) {
        int minEditDistance = Integer.MAX_VALUE;
        for (Node oldParagraph : oldParagraphs) {
          LinkedList<Diff> diffs = dmp.diff_main(
              getTextContent(oldParagraph), getTextContent(newParagraph));
          minEditDistance = Math.min(minEditDistance, modifiedLevenshteinDistance(diffs));
        }
        if (minEditDistance > EDIT_DISTANCE_THRESHOLD) {
          Element paragraphElement = (Element) newParagraph;
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.