-
Notifications
You must be signed in to change notification settings - Fork 0
Add decorator places providers that select or transform places returned from inner providers #7
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,16 @@ | |
|
|
||
| import org.deckfour.xes.model.XLog; | ||
| import org.processmining.placebasedlpmdiscovery.model.Place; | ||
| import org.processmining.placebasedlpmdiscovery.placechooser.placepredicates.NonSelfLoopPlacePredicate; | ||
| import org.processmining.placebasedlpmdiscovery.placechooser.placerankconverters.RankedPlace; | ||
| import org.processmining.placebasedlpmdiscovery.placechooser.placerankconverters.RankedPlaceComparator; | ||
| import org.processmining.placebasedlpmdiscovery.placechooser.placerankconverters.TransitionCountPlaceRankConverter; | ||
| import org.processmining.placebasedlpmdiscovery.placechooser.placetransformers.IncludedActivitiesPlaceTransformer; | ||
| import org.processmining.placebasedlpmdiscovery.placechooser.placetransformers.PassageUsagePlaceTransformer; | ||
| import org.processmining.placebasedlpmdiscovery.utils.LogUtils; | ||
|
|
||
| import java.util.Set; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| /** | ||
| * A provider of places for LPM discovery. Implementations can provide places from various sources, | ||
|
|
@@ -38,6 +46,47 @@ static PlacesProvider fromLog(XLog log) { | |
| return FromLogPlacesProvider.recommended(log); | ||
| } | ||
|
|
||
| /** | ||
| * Creates a PlacesProvider that provides the top K ranked places from the base provider. | ||
| * @param baseProvider the base PlacesProvider to get places from | ||
| * @param k the number of top ranked places to provide | ||
| * @return a PlacesProvider that provides the top K ranked places | ||
| */ | ||
| static PlacesProvider topK(PlacesProvider baseProvider, int k) { | ||
| return () -> baseProvider.provide().stream() | ||
| .map(p -> new RankedPlace(p, | ||
| new TransitionCountPlaceRankConverter().convert(p) | ||
| /*, new TotalPassageCoveragePlaceRankConverter(lefr).convert(p) */)) | ||
| .sorted(new RankedPlaceComparator()) | ||
| .map(RankedPlace::getPlace) | ||
| .limit(k) | ||
| .collect(Collectors.toSet()); | ||
| } | ||
|
|
||
| static PlacesProvider noSelfLoopPlaces(PlacesProvider baseProvider) { | ||
| return () -> baseProvider.provide().stream() | ||
| .filter(new NonSelfLoopPlacePredicate()) | ||
| .collect(Collectors.toSet()); | ||
| } | ||
|
|
||
| static PlacesProvider noEmptyIOPlaces(PlacesProvider baseProvider) { | ||
| return () -> baseProvider.provide().stream() | ||
| .filter(new NonSelfLoopPlacePredicate()) | ||
| .collect(Collectors.toSet()); | ||
| } | ||
|
|
||
| static PlacesProvider onlyForActivities(PlacesProvider baseProvider, Set<String> activities) { | ||
| return () -> baseProvider.provide().stream() | ||
| .map(new IncludedActivitiesPlaceTransformer(activities)) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this filter out transitions from places that are not in the list? |
||
| .collect(Collectors.toSet()); | ||
| } | ||
|
|
||
| static PlacesProvider onlyOccurringInProximity(PlacesProvider baseProvider, int proximity, XLog log) { | ||
| return () -> baseProvider.provide().stream() | ||
| .map(new PassageUsagePlaceTransformer(LogUtils.getFollowRelations(log, proximity))) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't understand this. Maybe it would be nice if you document what these decorators actually are supposed to do. |
||
| .collect(Collectors.toSet()); | ||
| } | ||
|
|
||
| /** | ||
| * Provides a set of places. | ||
| * @return a set of places | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be the wrong predicate.