Skip to content
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

Rule collection order of rules: add internal rule priority to rule collections #82

Open
SafeTex opened this issue Jun 30, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@SafeTex
Copy link

SafeTex commented Jun 30, 2023

Hello Tommi

I'm normally confused why something doesn't work as I expect but this time I'm confused why it does work !!!

I have two rules in pre-edit, one is to convert all uppercase words to lowercase,

image

and the other one is to try to protect acronyms like "TSEK" from being converted to "tsek".

image

And this seems to work but I don't understand why.

If "TSEK" is converted to "tsek" then my rule to preserve "TSEK" should not work as it is not set up to deal with "tsek"

And if "TSEK" is initially preserved as "TSEK", then the conversion rule should subsequently apply and I would expect to see "tsek" at the end.

But the rules work well together (ABCD = control test)

image

Why is this please?

Thanks

@TommiNieminen
Copy link
Collaborator

Hi,

I think this is because only one rule per collection can be applied to any given span of text. So the TSEK rule takes precedence in the collection, so it is applied to the TSEK sentence, but in the ABCD sentence the TSEK rule does not match, so the other rule can be applied.

Rules are not applied consequentially, only rule collections are (i.e. the order of the rules in the rule collection is not significant). So if you want to modify the output of rule application with another rule, you need to create another rule collection, and place it after the first rule collection in the rule collection list.

@SafeTex
Copy link
Author

SafeTex commented Jul 3, 2023

Hello Tommi

I got lucky then but please not that neither the collections, nor the rules in them can be moved up or down as far as I can see.

As always, I know I'm "pedantic", but these problems do come up and where rules are in the wrong order, how to we manage without moving them?

@TommiNieminen
Copy link
Collaborator

You can change the order of the collections by using the Move up and Move down buttons in the Edit rules tab:

kuva

@SafeTex
Copy link
Author

SafeTex commented Jul 3, 2023

Hello Tommi

But the two rules were in the same global collection and there are no arrows there

image

What happens in this case?

Regards

@TommiNieminen
Copy link
Collaborator

Hi,

I don't recall exactly what the mechanism was for deciding which rule takes precedence (from a quick look at the code, the longest match should always take precedence, but that's not happening here). At the moment I think it's always safest to have rules that affect the whole sentence in a separate collection, and more specific rules that apply to smaller parts of the sentence in separate collections.

@TommiNieminen TommiNieminen added the enhancement New feature or request label Apr 30, 2024
@TommiNieminen TommiNieminen changed the title Rule collection order of rules Rule collection order of rules: add internal rule priority to rule collections Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants