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

bug: matching with math questions?? #94

Closed
3 of 5 tasks
maddox05 opened this issue Jan 24, 2025 · 9 comments
Closed
3 of 5 tasks

bug: matching with math questions?? #94

maddox05 opened this issue Jan 24, 2025 · 9 comments
Labels
bug Something isn't working

Comments

@maddox05
Copy link

Expected behavior

Consider the surface: $$3x^2 - 12x + 5y^3 + z + 6 = 0$$. Find the points on the surface at which the tangent plane is parallel to the xy-plane.

const matcher = new RegExpMatcher({
...englishDataset.build(),
...englishRecommendedTransformers,
});
Bad word found between: 22 - 25
what is it matching??

Actual behavior

i expected it to not match

Minimal reproducible example

const matcher = new RegExpMatcher({
  ...englishDataset.build(),
  ...englishRecommendedTransformers,
});

const matchedWord = matcher.getAllMatches("Consider the surface: $$3x^2 - 12x + 5y^3 + z + 6 = 0$$. Find the points on the surface at which the tangent plane is parallel to the xy-plane.");

Steps to reproduce

its simple

Additional context

No response

Node.js version

v16.7.0

Obscenity version

0.4.2

Priority

  • Low
  • Medium
  • High

Terms

  • I agree to follow the project's Code of Conduct.
  • I have searched existing issues for similar reports.
@maddox05 maddox05 added the bug Something isn't working label Jan 24, 2025
@jo3-l
Copy link
Owner

jo3-l commented Jan 24, 2025

Looks like the leetspeak transformer is rewriting $$3x^2 to ssex^2. We can certainly whitelist this case (switching $ to s is an intended outcome of this transformer, so we should not change that), though I am not sure how much it will help.

In general, the leetspeak transformer is fairly aggressive, so if you are seeing many false positives in your application, I would just disable it.

@maddox05
Copy link
Author

maddox05 commented Jan 24, 2025

thats super funny. what other recommendations you got, or can I remove that case, for example the leet transformer could I disable it, or do I have to disabled obscenity?

@jo3-l
Copy link
Owner

jo3-l commented Jan 24, 2025

Yes, you can disable just the leetspeak transformer or just disable the $ to s transformation. See the blacklistMatcherTransformers option on RegExpMatcher: (docs and an example here: https://github.com/jo3-l/obscenity/blob/main/docs/reference/classes/RegExpMatcher.md#constructor).

@maddox05
Copy link
Author

thank you! great work you do.

@maddox05
Copy link
Author

@jo3-l im making quackprep.com if u have any feedback I rlly need it especially first UX

@maddox05
Copy link
Author

const matcher = new RegExpMatcher({
...englishDataset.build(),
...englishRecommendedTransformers,
blacklistMatcherTransformers: [
resolveLeetSpeakTransformer(), // '$' => 's'
],
});

still has the same issue at the same location

@maddox05 maddox05 reopened this Jan 24, 2025
@jo3-l
Copy link
Owner

jo3-l commented Jan 24, 2025

blacklistMatcherTransformers means "use these specific transformers when matching blacklisted terms", not "disable these transformers". See https://github.com/jo3-l/obscenity/blob/main/docs/reference/interfaces/RegExpMatcherOptions.md#blacklistmatchertransformers. Sorry if my original message was unclear. What you should do instead is copy the list of transformers in englishRecommendedTransformers and remove resolveLeetSpeakTransformer().

@maddox05
Copy link
Author

maddox05 commented Jan 24, 2025

ah i see, I though blacklist meant remove. ill try that thank you!

@maddox05
Copy link
Author

worked! sorry for my confusion. thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants