CCExtractor / CCExtractor/sample-platform

[Feature Request] Improve comparison algorithm to handle frame offsets intelligently (GSoC Qualification)

Open
#1,079 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
30
Forks
85
Avg merge
6d 21h
Merged PRs (30d)
12

Description

### Context
According to the "Sample Platform NG" GSoC project brief, one of the major goals is to improve the comparison algorithm. Currently, the comparison system is quite rigid, evaluating results strictly line-by-line. If a single frame (subtitle frame) is missing or slightly offset in the output, it causes a chain reaction where all subsequent frames are treated as a mismatch, causing the entire test to fail unnecessarily.

### Current Behavior
In [mod_test/nicediff/diff.py](cci:7://file:///c:/Users/amn2k/Desktop/CCExtractor/GSoC-sample-platform/mod_test/nicediff/diff.py:0:0-0:0) (around line 144 to 157 in [get_html_diff](cci:1://file:///c:/Users/amn2k/Desktop/CCExtractor/GSoC-sample-platform/mod_test/nicediff/diff.py:123:0-217:15)), the logic iterates through `use` length and compares `test_correct_lines[line] == test_res_lines[line]`.
This naive 1-to-1 index matching means that if `test_res_lines` drops line index 5, then index 6 of the result is compared against index 5 of the expected output, index 7 vs index 6, leading to a 100% mismatch from that point onwards.

### Expected Behavior
The comparison algorithm should be smart enough to detect insertions, deletions, and offsets. If a single frame is dropped, the diff should highlight *only* that specific dropped frame as an error, and successfully resync/align the remaining lines that match.

### Proposed Solution
I propose rewriting the core logic in [mod_test/nicediff/diff.py](cci:7://file:///c:/Users/amn2k/Desktop/CCExtractor/GSoC-sample-platform/mod_test/nicediff/diff.py:0:0-0:0) (specifically [get_html_diff](cci:1://file:///c:/Users/amn2k/Desktop/CCExtractor/GSoC-sample-platform/mod_test/nicediff/diff.py:123:0-217:15) and the event generation) to leverage a Sequence Matching algorithm (such as Python's built-in `difflib.SequenceMatcher` or a similar longest-common-subsequence approach).
This will allow us to:
1. Identify the exact opcode (`replace`, `delete`, `insert`, `equal`) for block ranges.
2. Gracefully handle offsets so the rest of the valid output remains marked as "Passed".
3. Render a much more accurate and readable HTML diff for the developers debugging the test suite.

### Goal
I am applying for GSoC for this project under the mentorship of @carlos.fernandez and @canihavesomecoffee. I would love to take this up as my qualification task and submit a PR fixing this core comparison logic. Let me know if I have the green light to proceed with this!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.