Announcement

Collapse
No announcement yet.

Automatic "Align with..." - "Force realignment" option

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Automatic "Align with..." - "Force realignment" option

    It is pretty often case when the [almost] only differences are some text blocks (e.g. classes and/or functions) are reordered within same file.

    Let assume there are 2 blocks. Every alignment will show one block aligned, and the other one is in [erased + inserted] diff. In order to ensure there are no diffs in this other block, manual "Align with..." option is required. And this operation is often not convenient, especially when blocks are large and there are many reorders (search is not available).

    Is it possible to have one-click/shortcut "Force realignment" option:
    1) align selected line
    2) regular alignment algorithm on the lines before the selected line from both files and separately on the lines after.

  • #2
    Hello,

    Thanks for the feedback. Ordering is important to the comparison/alignment in the Text Compare.

    The main strategy would be to use a Tidy program to perform sorting. We have an example KB article here:
    http://www.scootersoftware.com/suppo...rnalconversion
    And a few other Tidy/Tidied variants here:
    http://www.scootersoftware.com/downl..._moreformatsv4

    The Align With command can act on multiple lines if you:
    - Select Multiple lines, right-click, Align With
    - Drag select multiple lines as the target

    How does this work for you?
    Aaron P Scooter Software

    Comment


    • #3
      I do not want to sort. Also I do not want to separately sorting rules for C++, C#, Powershell script, Erlang and others we use.

      I just want fast and automatic "Align with...":
      1. Select unaligned line (e.g. first line of moved block), which I'm sure can be aligned.
      2. Press single button (after binding it to the new magic command)
      3. Get files recompared when selected line (and all other lines of moved block) are aligned.

      Comment


      • #4
        Hello,

        Sorry, are you looking for a selection of a single line to weight it more and find "the correct match" on the other side?

        The Alignment Algorithm performs the line by line on load. Selecting a single line, it determined the best match (based on the Session Setting Alignment tab settings) and is already aligned to it. While your eye might see an obvious solution or better match, for the program to recognize a better match you would need to update the Session Settings -> Alignment Tab settings.

        I suggested the sorting methods because I assumed your lines were in a different order, so pushing one line down with an Align With pushes all lines below it further down; order is always important, and sorting is the only solution if paragraphs or methods need to be moved above or below other methods.

        Also, selecting multiple lines (shift select) to Align With a block instead of a single line forces all of the lines to re-compare within just the selection. When performing on a single line, similar to the On Load, the following lines may 'appear' to be better matches, but the current Alignment algorithm is finding a better match with the displayed pair.

        Are your blocks of text out of order and have you tried Patience Diff as an alternate alignment method? Ideally, by tweaking the settings, manual alignment of entire blocks is less necessary, with the exception of if entire blocks are out of order. If you would like, you can email in example files and your BCSupport.zip to support@scootersoftware.com and I can get a better look at your current comparison. If you can also include a full screen screenshot of a problem line and a link back to this forum thread, I'll be able to reconstruct your current comparison and review it.
        Aaron P Scooter Software

        Comment


        • #5
          Sorry, are you looking for a selection of a single line to weight it more and find "the correct match" on the other side?
          Exactly. I have manual "Align with..." and I want automatic "Align with...". With the only difference between them is automatic searching for the matching line (by giving it some very big weight) instead of manual selecting matching line.

          Comment


          • #6
            You can add a Line Weight in the File Format, Grammar tab, as a global setting for that file type. This weight is not absolute, and integrates into the algorithm. Have you customized the Text Compare's Session Settings, Alignment tab?
            Aaron P Scooter Software

            Comment


            • #7
              Well,

              This is the use case:

              Every day I need to compare 50 files, 10000 lines each with previous version, when most (but not all) changes in each file are reordering multiple blocks.
              Every day there are different 50 files, with different changes and there is no any pattern on the first line of the reordered blocks.

              Currently I use "Align with..." - and for each unmatched block I need to search for matching line (select, copy, paste in search...), remember it, choose "Align with...", scroll the buffer to the remembered line and click on it. This is very annoying and I can't see how Session settings can help, when there is no any pattern on the lines I want to match.


              I just want it AUTOMATIC!!! ))))

              I select the line, press SINGLE KEY and magic command AUTOMATICALLY changes Session settings, giving the selected line very large weight (also, removing weight from previous call) and recompares the buffers.

              That's it. And I KNOW how to achieve the result, but currently it is very far from SINGLE KEY press, and I need this operation hundreds of times every day.

              Comment


              • #8
                Please email in sample files to support@scootersoftware.com along with:
                - your current BCSupport.zip from the Help menu -> Support; Export
                - a full screen screenshot of the comparison with View menu -> Line Numbers enabled
                - an example of left line numbers you want to align with right line numbers
                - a link back to this forum thread for our reference

                This way I can re-create what you are comparing.

                There isn't a single command to select a line and give it more weight, and without testing the Line Weight settings that may not be sufficient. The manual Align With command is the opposite approach: it is throwing out automated attempts to determine a best match and replacing it with user input. While finding the best match is obvious to your eye reading your data, BC4's current settings are returning different results. This could be due to a number of factors, such as a too-small Skew Tolerance or Closeness Matching on files that have too similar of data. Not all alignment settings work with all files, and need to be updated depending on what is compared. For example, Patience Diff alignment helps with blocks that use brackets, as it is better at finding the concept of blocks defined that way.

                If you have a block of text that is aligning to different text instead of equal text, the expectation is it should be automatically aligning to the equal text and not need manual alignment or a single key command to do that. I can determine more specific instructions with the sample files, settings, and screenshot.
                Last edited by Aaron; 22-Jan-2020, 10:19 AM. Reason: update to email instructions to include forum thread link
                Aaron P Scooter Software

                Comment


                • #9
                  Two scenarios:
                  1. Take any file, e.g. https://docs.microsoft.com/en-us/pre...271(v%3Dvs.85) as a source
                  2. Put elements (books) in reverse order, save as target
                  3. Compare source to target and validate all elements from source are present and unchanged in target.
                  1. Same
                  2. Same
                  3. Modify elements (e.g. change date format)
                  4. Compare source to target and validate all elements from source are present in target and there are no changes except date format.

                  Comment


                  • #10
                    For scenario 1, BC4 always considers the Order important. Pushing the alignment to match one block would push all others out of the way. To tackle this, we use a Tidy or Sorting conversion process. For XML, you can download XML Sorted here:
                    http://www.scootersoftware.com/downl..._moreformatsv4
                    Or you can use any command line program for sorting the files, discussed here:
                    http://www.scootersoftware.com/suppo...rnalconversion

                    Enhancing our comparison to handle out of order sequences is something on our wishlist, but sorting would be required for BC4.

                    For scenario 2, what issue are you running into? Assuming the files are not in a scenario 1 state, the ordered data should line up and the date note would align side by side and show the date as a change (red text for the numeric values in the date). I can create my own sample files from your link, with a Find/Replace on a date to alter it in a clone, then compare the original to the altered clone. If the change is a static or specific change, it can even be ignored (either by generally ignoring the date node, or defining a Text Replacement for the type of change that's occurred). For example:
                    (\d\d\d\d)\-(\d\d)\-(\d\d)
                    with
                    $1-$3-$2

                    If you could send in the listed above information, I could more easily diagnose scenario 2 and help with what settings are needed.
                    Aaron P Scooter Software

                    Comment


                    • #11
                      I know the order is important. And the order is important for us. And that's why sorting is not good.

                      I just want to check there are no other changes between source and target, except blocks reordering. Thus, I need to match EACH block, one by one, and verify the block wasn't changed.
                      And I want to do it FAST.

                      Comment


                      • #12
                        My use case is to compare source with target and VERIFY, there are NO CHANGES except blocks reordering.

                        Sorting lines is not good enough - it may miss lines reordering within block or between blocks.
                        Sorting blocks is not possible - there is no pattern on block start/end.

                        Comment


                        • #13
                          Hello,

                          Would you be able to send in the sample files and screenshot requested above? I can add these files to our test cases for an adhoc block alignment.

                          For other users, BC4 does not support this type of command, and the closest example/workaround would be the RESX example (custom script) to tidy: http://www.scootersoftware.com/suppo...rnalconversion

                          You mention there's no pattern to the start/block, so given this description it wouldn't directly apply, but it could be a good sample case to send in that we can test against for an adhoc design, as you suggest.
                          Aaron P Scooter Software

                          Comment

                          Working...
                          X