Package net.sf.okapi.common.filters
Class FilterUtil
- java.lang.Object
-
- net.sf.okapi.common.filters.FilterUtil
-
public class FilterUtil extends Object
-
-
Constructor Summary
Constructors Constructor Description FilterUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringaddCustomConfig(FilterConfigurationMapper fcMapper, URL customConfig)Adds to a givenFilterConfigurationMapperobject the custom configuration defined in the fprm file denoted by a given URL.static EventcreateDeepenSegmentationEvent()static IFiltercreateFilter(Class<? extends IFilter> filterClass, String configId)Creates an instance of the filter for a given configuration identifier and loads its corresponding parameters.static IFiltercreateFilter(String configId)Creates an instance of the filter for a given configuration identifier and loads its corresponding parameters.static IFiltercreateFilter(String configId, URL... customConfigs)Creates an instance of the filter for a given configuration identifier and loads its corresponding parameters.static IFiltercreateFilter(URL customConfig)Creates an instance of the filter for a given URL of a fprm file defining a custom configuration.static voidlogDebugEvent(Event e, String leader, org.slf4j.Logger logger)Logs an event at the debug level.static voidlogDebugEvents(Iterable<Event> events, org.slf4j.Logger logger)Logs events at the debug level.
-
-
-
Method Detail
-
createDeepenSegmentationEvent
public static Event createDeepenSegmentationEvent()
- Returns:
EventwithCustomresource andDeepenSegmentationAnnotaton.
-
createFilter
public static IFilter createFilter(String configId)
Creates an instance of the filter for a given configuration identifier and loads its corresponding parameters. Only Okapi default filter configurations are accepted.- Parameters:
configId- the filter configuration identifier. Can only be one of default filter configurations.- Returns:
- a new
IFilterobject (with its parameters loaded) for the given configuration identifier, or null if the object could not be created.
-
createFilter
public static IFilter createFilter(Class<? extends IFilter> filterClass, String configId)
Creates an instance of the filter for a given configuration identifier and loads its corresponding parameters.- Parameters:
filterClass- class of the filter.configId- the filter configuration identifier. Can be either one of Okapi default filter configurations or one of the built-in configurations defined in the filter class.- Returns:
- a new
IFilterobject (with its parameters loaded) for the given configuration identifier, or null if the object could not be created.
-
createFilter
public static IFilter createFilter(String configId, URL... customConfigs)
Creates an instance of the filter for a given configuration identifier and loads its corresponding parameters. This method accepts a list of the URLs of fprm files defining custom configurations, and can be used to create a filter and configure its sub-filters in one call.- Parameters:
configId- the filter configuration identifier. Can be either one of Okapi default filter configurations or one of the custom configurations defined in the fprm files.customConfigs- a list of the URLs of fprm files defining custom configurations. Every file name should follow the pattern of custom filter configurations, i.e. contain a filter name like "okf_xmlstream@custom_config.fprm". The file extension should be .fprm.- Returns:
- a new
IFilterobject (with its parameters loaded) for the given configuration identifier, or null if the object could not be created.
-
addCustomConfig
public static String addCustomConfig(FilterConfigurationMapper fcMapper, URL customConfig)
Adds to a givenFilterConfigurationMapperobject the custom configuration defined in the fprm file denoted by a given URL.- Parameters:
fcMapper- the givenFilterConfigurationMapper.customConfig- the URL of a fprm file defining the custom configuration the filter should be loaded from. The file extension should be .fprm. The file name should follow the pattern of custom filter configurations, i.e. contain a filter name like "okf_xmlstream@custom_config.fprm".- Returns:
- the configuration identifier or null if the configuration was not added.
-
createFilter
public static IFilter createFilter(URL customConfig)
Creates an instance of the filter for a given URL of a fprm file defining a custom configuration.- Parameters:
customConfig- the URL of a fprm file defining the custom configuration the filter should be loaded from. The file extension should be .fprm. The file name should follow the pattern of custom filter configurations, i.e. contain a filter name like "okf_xmlstream@custom_config.fprm".- Returns:
- a new
IFilterobject (with its parameters loaded) for the given configuration identifier, or null if the object could not be created.
-
logDebugEvents
public static void logDebugEvents(Iterable<Event> events, org.slf4j.Logger logger)
Logs events at the debug level.- Parameters:
events- The events to loglogger- The logger
-
-