Private
Public Access
docs(curation): correct FuzzyAnchor docstring (add get_context helper, replace 'anchor_lines' with actual field names)
This commit is contained in:
@@ -83,13 +83,24 @@ Text slices defined by line numbers become invalid when files are modified (line
|
|||||||
```python
|
```python
|
||||||
# src/fuzzy_anchor.py
|
# src/fuzzy_anchor.py
|
||||||
class FuzzyAnchor:
|
class FuzzyAnchor:
|
||||||
|
@staticmethod
|
||||||
|
def get_context(lines: list[str], index: int, count: int, direction: int) -> list[str]:
|
||||||
|
"""Helper: extract up to `count` non-empty lines starting at `index` and walking
|
||||||
|
in `direction` (1 = forward, -1 = backward). Used to build the start/end anchors
|
||||||
|
for fuzzy re-resolution."""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_slice(cls, text: str, start_line: int, end_line: int) -> dict:
|
def create_slice(cls, text: str, start_line: int, end_line: int) -> dict:
|
||||||
"""Returns slice_data with content_hash, anchor_lines, and positions."""
|
"""Returns slice_data with start_line, end_line, content_hash, start_context,
|
||||||
|
and end_context fields. start_line/end_line are 1-based; the hash is MD5
|
||||||
|
of the region's text."""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def resolve_slice(cls, text: str, slice_data: dict) -> Optional[Tuple[int, int]]:
|
def resolve_slice(cls, text: str, slice_data: dict) -> Optional[Tuple[int, int]]:
|
||||||
"""Resolves slice position in modified text, returns (start, end) or None."""
|
"""Resolves slice position in modified text. Returns (start, end) on success
|
||||||
|
or None if the slice can no longer be located. Strategy: (1) try exact
|
||||||
|
match by content hash at the original line range; (2) fall back to fuzzy
|
||||||
|
match by walking the start_context and end_context anchors."""
|
||||||
```
|
```
|
||||||
|
|
||||||
### Slice Data Structure
|
### Slice Data Structure
|
||||||
|
|||||||
Reference in New Issue
Block a user