Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2012
    Posts
    9

    Default Matching algorithm when inserting xml elements

    In the attached screen shots, you can see two different ways of matching the same inserted xml element. BC3 seems to switch between them arbitrarily. With only one change, it shows as desired. With an earlier change, it highlights the 'wrong' closing tag. Is there anything I can go to influence this?

    It would be great if I could click within the mismatch, and flip between the two ways of looking at it.

    This problem also affects many other languages, eg, C++ method braces and SQL procedures.

  2. #2
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    4,728

    Default

    Changing BC's alignment setting might change this, but it doesn't currently provide a good way to control this behavior.

    To change alignment in the Text Compare, select "Session > Session Settings". Go to the "Alignment" tab. Change from "Standard method" to "Alternate method".

    Improving the alignment algorithm is on our wish list for a future version of BC.
    Chris K Scooter Software

  3. #3
    Join Date
    Feb 2012
    Posts
    9

    Default

    Thanks Chris. Changing to alternate did not make any difference. Using Unaligned, simply shows the remainder of the file as mismatched from the opening tag of the new element. Changing the Standard alignment skew, or the closeness option didn't make any difference.

    I notice that Google have released a diff-match-patch suite. How does its algorithm compare with BCs? I wonder if it has control over whether to match the previous, or next closing delimiter, when inserts occur.

  4. #4
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,893

    Default

    Hello,

    Our current algorithm goes line by line, and does not currently match based on the syntax of the language of the file. It is something we are looking into.

    In the meantime, you can highlight multiple lines (an entire node section), and right click and choose Align With, then highlight an entire other node section to force an alignment. You can also do one line at a time.

    If you would like, please send in a pair of sample files to support@scootersoftware.com. Please also include a link to this forum thread. We can then add the files to our test cases to check against them as we try out new features.
    Aaron P Scooter Software

  5. #5
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,893

    Default

    It looks like the GoogleCode project for diff-match-patch is based on the Myer's diff algorithm, which is the same algorithm our Alternate Alignment setting is based on. They might be doing some extra work to help their results, but the basic algorithm would be similar.
    Aaron P Scooter Software

  6. #6
    Join Date
    Feb 2012
    Posts
    9

    Default

    Hello. It has been 3 years since this discussion. I never sent the files in, but I wonder if this aspect of matching has been improved? In the attached image, it should be possible to show all 6 lines with the text 'this.' highlighted as having been inserted. Thanks!
    Attached Images Attached Images

  7. #7
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,893

    Default

    BC4 tweaks the Standard and Myers alignment, while also adding the Patience Diff alignment algorithm. If you are unable to send in files, you can try out our BC4 trial without removing or altering your BC3 install:
    http://www.scootersoftware.com/download.php

    The alignment settings are controlled in the Text Compare's Session menu -> Session Settings, Alignment tab.
    Aaron P Scooter Software

  8. #8
    Join Date
    Feb 2012
    Posts
    9

    Default Same problem in BC4

    I have upgraded to BC4 and tested the different Alignment settings. None of them make any difference! According to the F1 help, they do not have any effect on the alignment of the mismatch ON A SINGLE LINE.

    What I'm asking for, is that when you find a line that doesn't match then:

    while (character before frame == last character in the frame)
    shift the frame back one character.

    Ideally you would then repeat that for each block of changes - shift it backwards while the characters before the block match the characters at the end of the block.

    I have the attached files (renamed to .txt).

    Hope that makes sense.

    Thanks!
    Attached Files Attached Files

  9. #9
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,893

    Default

    Ah, thanks for the example files and clarification. I missed that earlier this post was about both line alignment and character alignment.

    For character (within a line) alignment, we appreciate the example files. The best workaround in the current version is to define a grammar that matches on different logical parts of your line. In these files, you can define a grammar, type Basic, that matches on the "this." prefix, and that then helps influence the character alignment and gets the results you expect. By defining different concepts for your files, this can help the character alignment shift and find matches.
    Aaron P Scooter Software

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •