-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace every occurrence of searched words #6
Comments
Removed the 'easy' tag because possibly it could have links with the way issue #9 of DuraLex is solved. This other issue is about how multiple articles are changed together, and this one is about how multiple occurences are managed in a single article, but I think the data model in AddDiffVisitor should be rewritten by taking into account both characteristics. A complete example is an amendment:
And the word "truc" appears multiple times in both locations specified in the articles. (According to the rules in the French assemblies, an amendment in the classical sense cannot change multiple articles, but here the “amendment” word is used as a synonym of “modifying text” and this type of amendment can be found in law projects/proposals or in in-force laws modifying other laws.) The DuraLex tree of such an amendment would be something like: {
"children": [
{
"children": [
{
"children": [
{
"children": [
{
"type": "quote",
"words": "truc"
}
],
"type": "word-reference"
}
],
"order": 1,
"type": "alinea-reference"
}
],
"id": "3",
"type": "article-reference"
},
{
"children": [
{
"children": [
{
"children": [
{
"type": "quote",
"words": "truc"
}
],
"type": "word-reference"
}
],
"order": 5,
"type": "alinea-reference"
}
],
"id": "5",
"type": "article-reference"
},
{
"children": [
{
"type": "quote",
"words": "machin"
}
],
"type": "word-definition"
}
],
"editType": "replace",
"type": "edit"
} |
This is a quite simple issue and could be a good first bug for a newcomer in SedLex codebase.
When diffs are generated by SedLex (in AddDiffVisitor), when DuraLex tree says to replace a word (well an expression possibly with multiple words) by another, only the first one is replaced. The perimeter is currently delimited by (self.begin, self.end), this should be changed into a list of perimeters and then do the edit operation in each perimeter. Some care should be taken because the text should not be reset between each sub-edit operation, particularly for exact diffs.
This can be tested on Durafront - it can be checked that the DuraLex tree is correct.
Amendment =
Text to be amended:
Currently only the first "truc" is changed to "machin".
When this will be implemented, the diff of the above example will look like:
and the exact diff will look like:
The text was updated successfully, but these errors were encountered: