flitsr.advanced.Config¶
- class flitsr.advanced.Config(ranker: RankerType | None = None, cluster: ClusterType | None = None, refiner: RefinerType | None = None, args: Dict[str, Dict[str, Any]] | None = None)¶
Bases:
objectThe advanced type configuration for a particular run of SBFL methods.
Optionally contains a single Refiner, Cluster, and/or Ranker, as well as any arguments related to these advanced types. Multiple of these Config objects can be created in the same execution.
Changed in version 2.3.0: Replaced the
ranker,cluster, andrefinerattributes with functions constructing them- __init__(ranker: RankerType | None = None, cluster: ClusterType | None = None, refiner: RefinerType | None = None, args: Dict[str, Dict[str, Any]] | None = None)¶
Construct a
Configobject with the given ranker, cluster, and/or refiner (all optional).- Parameters:
ranker – The (optional)
RankerTypeto include in this configcluster – The (optional)
ClusterTypeto include in this configrefiner – The (optional)
RefinerTypeto include in this configargs – If given, the dictionary containing additional arguments for each of the advanced types. The dictionary is indexed by the name of the advanced type, with the value being another dictionary with argument names and values. For example: {‘MULTI’: {‘cutoff’: 5}} will set the
cutoffparameter of theMULTIRankerType.
Changed in version 2.4.0: Added the args optional argument
Methods
__init__([ranker, cluster, refiner, args])Construct a
Configobject with the given ranker, cluster, and/or refiner (all optional).build_adv_type(...)Constructs the advanced type given by adv_type using the parameters in both the given args and this
Config's arguments.cluster(args)Build and return this
Config'sClusterType, if available.get_concrete(adv_type)Returns a string name of this
Config's concrete advanced type for the given category (Refiner, Cluster or Ranker), if it is available.get_file_name([params])Synonym for
Config.get_str(filename=True, ...).get_str([filename, params])Returns a string description of the advanced types of this config object that can be used either in the name of the output file (filename=True), or for other script use (filename=False).
ranker(args)Build and return this
Config'sRankerType, if available.refiner(args)Build and return this
Config'sRefinerType, if available.set_arg(adv_type, arg_name, arg_value)Set the argument given by arg_name with arg_value for the given advanced type.
- build_adv_type(adv_type: RankerType, args: Args) Ranker¶
- build_adv_type(adv_type: ClusterType, args: Args) Cluster
- build_adv_type(adv_type: RefinerType, args: Args) Refiner
- build_adv_type(adv_type: None, args: Args) None
Constructs the advanced type given by adv_type using the parameters in both the given args and this
Config’s arguments.- Parameters:
adv_type – The advanced type to construct, which is one of
RefinerType,ClusterType, orRankerType.args – The global flitsr arguments to use when constructing the given advanced type.
- Returns:
The constructed advanced type object, which corresponds to the given adv_type argument.
Added in version 2.4.0.
- cluster(args: Args) Cluster | None¶
Build and return this
Config’sClusterType, if available.- Parameters:
args – The global flitsr arguments to use when constructing this
Config’sClusterType.- Returns:
This
Config’s constructedClusterobject, or None if noClusterTypehas been set.
Added in version 2.4.0.
- get_concrete(adv_type: Type[RefinerType] | Type[ClusterType] | Type[RankerType]) str | None¶
Returns a string name of this
Config’s concrete advanced type for the given category (Refiner, Cluster or Ranker), if it is available. For example, if RankerType was given, and this Config contained the SBFL RankerType, then “SBFL” would be returned. If there is no concrete advanced type for the given category, None is returned.- Parameters:
adv_type – The advanced type category to retrieve.
- Returns:
The name of the concrete implementation for the given advanced type in this
Configobject, or None if no concrete implementation is available.
Added in version 2.4.0.
- get_file_name(params: str | None = None)¶
Synonym for
Config.get_str(filename=True, ...).Returns a string description of the advanced types of this config object that can be used in the name of the output file.
- Parameters:
params – (Default value = None) Whether to include advanced type parameters in the file name. See the
get_strmethod for a description of the format.- Returns:
A string description of this
Configfor filename use.
Changed in version 2.4.0: Added the params optional argument
- get_str(filename=False, params: str | None = None)¶
Returns a string description of the advanced types of this config object that can be used either in the name of the output file (filename=True), or for other script use (filename=False).
- Parameters:
params – (Default value = None) If and how to include advanced type parameters in the output string. If None, parameters will not be included in the output string. If the empty string (“”) is given, parameters will be included in the format “{k}-{v}” (for filenames) or “{k}={v}” (for non-filenames), where “{k}” is the parameter name, and “{v}” the value. Alternatively, a different format can be specified by giving a string using the same “{k}”, “{v}” format.
- Returns:
A string description of this
Config.
Added in version 2.4.0.
- ranker(args: Args) Ranker | None¶
Build and return this
Config’sRankerType, if available.- Parameters:
args – The global flitsr arguments to use when constructing this
Config’sRankerType.- Returns:
This
Config’s constructedRankerobject, or None if noRankerTypehas been set.
Added in version 2.4.0.
- refiner(args: Args) Refiner | None¶
Build and return this
Config’sRefinerType, if available.- Parameters:
args – The global flitsr arguments to use when constructing this
Config’sRefinerType.- Returns:
This
Config’s constructedRefinerobject, or None if noRefinerTypehas been set.
Added in version 2.4.0.
- set_arg(adv_type: RefinerType | ClusterType | RankerType, arg_name: str, arg_value: Any)¶
Set the argument given by arg_name with arg_value for the given advanced type.
- Parameters:
adv_type – The advanced type to set the argument for.
arg_name – str: The name of the argument to set
arg_value –
Any: The value of the argument to set
Added in version 2.4.0.