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

concise phrase transform #811

Merged
merged 10 commits into from
Oct 15, 2024
Merged

Conversation

eschultink
Copy link
Member

@eschultink eschultink commented Sep 25, 2024

Features

  • transform more suited to the calendar event title use-case

Change implications

  • dependencies added/changed? no
  • something important to note in future release notes? not yet

@eschultink eschultink changed the title S184 : concise phrase transform concise phrase transform Sep 27, 2024
@@ -186,6 +186,27 @@ void redactRegexMatches(String source) {
}


@SneakyThrows
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test by copilot?? typo PHASE instead of PHRASE everywhere :)

Base automatically changed from rc-v0.4.61 to main October 3, 2024 20:41
@eschultink eschultink changed the base branch from main to rc-v0.5.0 October 3, 2024 21:24
@eschultink eschultink marked this pull request as ready for review October 4, 2024 00:29
"Prep Customer Meeting,Prep ",
"Prep: Customer,Prep: ",
"Out of the Office: Vacation,Out of the Office",
"Focus Time,'Focus Time,Focus'",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, this is reality of this; bc transform products ALL matches, not just first. In effect, it's more like categorization than redaction.

behavior is needed if you want "Team weekly" to match both "team" and "weekly" cases. that will end up as team,weekly.

Copy link
Member

@jlorper jlorper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a minor typo

return patterns.stream()
.map(p -> p.matcher((String) s))
.filter(Matcher::matches)
.map(m -> m.group(1)) //group 1, bc we created caputuring group in regex above
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map(m -> m.group(1)) //group 1, bc we created caputuring group in regex above
.map(m -> m.group(1)) //group 1, bc we created capturing group in regex above

"Focus Time Block,'Focus Time,Focus'",
"Focus: Secret Project,Focus",
"No Meeting Wednesday,No Meeting",
" No Meetings,'No Meetings,No Meetings'", // q: why????
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because matches with No Meeting and No Meetings

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 it shouldn't though ... No Meeting token string shouldn't match No Meetings, bc I'm transforming it into a pattern with \b tokens on either side to only match "word boundaries. So it shouldn't match prefixes.


List<Pattern> patterns = transform.getAllowedPhrases().stream()
.map(p -> "\\Q" + p + "\\E") // quote it
.map(p -> "\\b" + p + "[\\\\s:]*\\b") //boundary match, with optional whitespace or colon at end
Copy link
Member Author

@eschultink eschultink Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jlorper this is where should be limiting to word boundaries.

maybe bug is that "[\\\\s:]*" is wrong, so it's matching character 's' specifically, instead of \s for whitespace as I intended ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it was that - fixed now and works as expected.

@eschultink eschultink merged commit 8d3c34c into rc-v0.5.0 Oct 15, 2024
67 checks passed
@eschultink eschultink deleted the s184-concise-phrase-transform branch October 15, 2024 20:58
eschultink added a commit that referenced this pull request Dec 4, 2024
* wip of concise phrase transform

* fix import

* cleanup, fix tests

* cleaner rules and examples

* fix tests

* fix tests

* drop case-insensitive multi-pattern stuff

* fix pattern to allow spaces rather than s char; and tighten capture pattern

* fix tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants