Skip to content

Commit

Permalink
(FIX) toward fixing the substring problem
Browse files Browse the repository at this point in the history
  • Loading branch information
rciric committed Aug 29, 2023
1 parent f7876a3 commit 6568cc4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
recursive-include src/gramform/_resources *
recursive-include src/gramform/_results *
graft src/gramform/_resources
include src/gramform/_results/.empty
10 changes: 7 additions & 3 deletions src/gramform/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,18 @@ def _scan_content_and_embed_child(
child_id: str,
) -> IndexedNestedString:
content = self.content
new_loc = []
for start, end in loc:
content = content.substitute(
new_content = content.substitute(
content=ChildToken(child_id, length=end - start),
start=start,
end=end,
loc_type='index',
)
return content
if content != new_content:
new_loc.append((start, end))
content = new_content
return content, new_loc

def _scan_content_and_embed_token(
self,
Expand Down Expand Up @@ -357,7 +361,7 @@ def create_child(

contentstr = self.materialise(recursive=recursive)
loc = [m.span() for m in re.finditer(re.escape(query), contentstr)]
content = self._scan_content_and_embed_child(loc, child_id)
content, loc = self._scan_content_and_embed_child(loc, child_id)

if nest:
child = self._child_carry_nested_content(
Expand Down

0 comments on commit 6568cc4

Please sign in to comment.