sampling-mining-workflows-dsl 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sampling_mining_workflows_dsl/ __init__.py +0 -0
- sampling_mining_workflows_dsl/CompleteWorkflow.py +23 -0
- sampling_mining_workflows_dsl/Workflow.py +242 -0
- sampling_mining_workflows_dsl/WorkflowBuilder.py +11 -0
- sampling_mining_workflows_dsl/analysis/ChiSquareAnalysis.py +37 -0
- sampling_mining_workflows_dsl/analysis/CochranTest.py +44 -0
- sampling_mining_workflows_dsl/analysis/CochranWorkflowAnalysis.py +37 -0
- sampling_mining_workflows_dsl/analysis/CoverageTest.py +60 -0
- sampling_mining_workflows_dsl/analysis/DistributionWorkflowAnalysis.py +57 -0
- sampling_mining_workflows_dsl/analysis/HistAnalysis.py +201 -0
- sampling_mining_workflows_dsl/analysis/HistWorkflowAnalysis.py +72 -0
- sampling_mining_workflows_dsl/analysis/KSWorkflowAnalysis.py +217 -0
- sampling_mining_workflows_dsl/analysis/WorkflowAnalysis.py +7 -0
- sampling_mining_workflows_dsl/analysis/YamaneTest.py +16 -0
- sampling_mining_workflows_dsl/analysis/YamaneWorkflowAnalysis.py +27 -0
- sampling_mining_workflows_dsl/analysis/kolmogorov_smirnov.py +31 -0
- sampling_mining_workflows_dsl/constraint/BoolComparator.py +23 -0
- sampling_mining_workflows_dsl/constraint/BoolConstraint.py +50 -0
- sampling_mining_workflows_dsl/constraint/BoolConstraintString.py +66 -0
- sampling_mining_workflows_dsl/constraint/Comparator.py +16 -0
- sampling_mining_workflows_dsl/constraint/Constraint.py +23 -0
- sampling_mining_workflows_dsl/constraint/NaturalComparator.py +17 -0
- sampling_mining_workflows_dsl/element/Element.py +45 -0
- sampling_mining_workflows_dsl/element/Loader.py +17 -0
- sampling_mining_workflows_dsl/element/Repository.py +28 -0
- sampling_mining_workflows_dsl/element/Set.py +210 -0
- sampling_mining_workflows_dsl/element/Writer.py +9 -0
- sampling_mining_workflows_dsl/element/loader/CsvLoader.py +67 -0
- sampling_mining_workflows_dsl/element/loader/JsonLoader.py +84 -0
- sampling_mining_workflows_dsl/element/loader/LoaderFactory.py +14 -0
- sampling_mining_workflows_dsl/element/writer/CsvWriter.py +46 -0
- sampling_mining_workflows_dsl/element/writer/JsonWriter.py +58 -0
- sampling_mining_workflows_dsl/element/writer/WriterFactory.py +7 -0
- sampling_mining_workflows_dsl/exec_visualizer/WorkflowVisualizer.py +189 -0
- sampling_mining_workflows_dsl/github_seart/loader.py +17 -0
- sampling_mining_workflows_dsl/github_seart/metadata.py +106 -0
- sampling_mining_workflows_dsl/metadata/Metadata.py +117 -0
- sampling_mining_workflows_dsl/metadata/MetadataBoolean.py +14 -0
- sampling_mining_workflows_dsl/metadata/MetadataDate.py +75 -0
- sampling_mining_workflows_dsl/metadata/MetadataDict.py +33 -0
- sampling_mining_workflows_dsl/metadata/MetadataList.py +32 -0
- sampling_mining_workflows_dsl/metadata/MetadataNumber.py +29 -0
- sampling_mining_workflows_dsl/metadata/MetadataString.py +13 -0
- sampling_mining_workflows_dsl/metadata/MetadataValue.py +24 -0
- sampling_mining_workflows_dsl/operator/Operator.py +165 -0
- sampling_mining_workflows_dsl/operator/OperatorBuilder.py +191 -0
- sampling_mining_workflows_dsl/operator/OperatorFactory.py +76 -0
- sampling_mining_workflows_dsl/operator/clustering/GroupingOperator.py +36 -0
- sampling_mining_workflows_dsl/operator/clustering/SubWorkflowOperatorBuilder.py +76 -0
- sampling_mining_workflows_dsl/operator/selection/SelectionOperator.py +5 -0
- sampling_mining_workflows_dsl/operator/selection/filter/FilterOperator.py +30 -0
- sampling_mining_workflows_dsl/operator/selection/sampling/SamplingOperator.py +11 -0
- sampling_mining_workflows_dsl/operator/selection/sampling/automatic/AutomaticSamplingOperator.py +9 -0
- sampling_mining_workflows_dsl/operator/selection/sampling/automatic/RandomSelectionOperator.py +24 -0
- sampling_mining_workflows_dsl/operator/selection/sampling/automatic/RandomSelectionPartitionOperator.py +62 -0
- sampling_mining_workflows_dsl/operator/selection/sampling/automatic/SystematicRandomSelectionOperator.py +14 -0
- sampling_mining_workflows_dsl/operator/selection/sampling/automatic/SystematicSelectionOperator.py +31 -0
- sampling_mining_workflows_dsl/operator/selection/sampling/manual/InteractiveManualSamplingOperator.py +40 -0
- sampling_mining_workflows_dsl/operator/selection/sampling/manual/ManualSamplingOperator.py +28 -0
- sampling_mining_workflows_dsl/operator/set_algebra/ExternalSetOperator.py +33 -0
- sampling_mining_workflows_dsl/operator/set_algebra/InternalSetOperator.py +47 -0
- sampling_mining_workflows_dsl/operator/set_algebra/SetOperator.py +30 -0
- sampling_mining_workflows_dsl/operator/set_algebra/external_set_operator/DifferenceOperator.py +17 -0
- sampling_mining_workflows_dsl/operator/set_algebra/external_set_operator/IntersectionOperator.py +19 -0
- sampling_mining_workflows_dsl/operator/set_algebra/external_set_operator/UnionOperator.py +17 -0
- sampling_mining_workflows_dsl/operator/set_algebra/internal_set_operator/DifferenceOperator.py +17 -0
- sampling_mining_workflows_dsl/operator/set_algebra/internal_set_operator/IntersectionOperator.py +18 -0
- sampling_mining_workflows_dsl/operator/set_algebra/internal_set_operator/UnionOperator.py +17 -0
- sampling_mining_workflows_dsl/operator/set_algebra/set_operator/DifferenceOperator.py +15 -0
- sampling_mining_workflows_dsl/operator/set_algebra/set_operator/IntersectionOperator.py +18 -0
- sampling_mining_workflows_dsl/operator/set_algebra/set_operator/UnionOperator.py +17 -0
- sampling_mining_workflows_dsl/test/ __init__.py +0 -0
- sampling_mining_workflows_dsl/test/Workflow_simple.py +38 -0
- sampling_mining_workflows_dsl/test/input.json +401 -0
- sampling_mining_workflows_dsl/toolbox.py +42 -0
- sampling_mining_workflows_dsl-0.0.1.dist-info/METADATA +236 -0
- sampling_mining_workflows_dsl-0.0.1.dist-info/RECORD +79 -0
- sampling_mining_workflows_dsl-0.0.1.dist-info/WHEEL +4 -0
- sampling_mining_workflows_dsl-0.0.1.dist-info/licenses/LICENSE.txt +674 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
|
|
2
|
+
from sampling_mining_workflows_dsl.element.Set import Set
|
|
3
|
+
from sampling_mining_workflows_dsl.operator.Operator import Operator
|
|
4
|
+
from sampling_mining_workflows_dsl.operator.selection.sampling.automatic.AutomaticSamplingOperator import (
|
|
5
|
+
AutomaticSamplingOperator,
|
|
6
|
+
)
|
|
7
|
+
from sampling_mining_workflows_dsl.Workflow import Workflow
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class RandomSelectionPartitionOperator(AutomaticSamplingOperator):
|
|
11
|
+
def __init__(self, workflow: Workflow, cardinality: int, seed: int = 0):
|
|
12
|
+
super().__init__(workflow, cardinality)
|
|
13
|
+
self.seed = seed
|
|
14
|
+
|
|
15
|
+
def execute(self) -> Operator:
|
|
16
|
+
from sampling_mining_workflows_dsl.operator.OperatorFactory import (
|
|
17
|
+
OperatorFactory,
|
|
18
|
+
) # Local import
|
|
19
|
+
|
|
20
|
+
random_selection_operator = OperatorFactory.random_selection_operator
|
|
21
|
+
|
|
22
|
+
self._output = Set()
|
|
23
|
+
is_set_of_set = all(isinstance(x, Set) for x in self._input.get_elements())
|
|
24
|
+
|
|
25
|
+
if is_set_of_set:
|
|
26
|
+
input_sets: list[Set] = [
|
|
27
|
+
x for x in self._input.get_elements() if isinstance(x, Set)
|
|
28
|
+
]
|
|
29
|
+
total_size = sum(len(s.get_elements()) for s in input_sets)
|
|
30
|
+
|
|
31
|
+
# Compute the number of elements per list
|
|
32
|
+
sample_sizes = [
|
|
33
|
+
round((len(sublist.get_elements()) / total_size) * self._cardinality)
|
|
34
|
+
for sublist in input_sets
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
# Correction to ensure the total sample size matches the cardinality
|
|
38
|
+
diff = self._cardinality - sum(sample_sizes)
|
|
39
|
+
i = 0
|
|
40
|
+
while diff != 0:
|
|
41
|
+
index = i % len(input_sets)
|
|
42
|
+
if diff > 0:
|
|
43
|
+
sample_sizes[index] += 1
|
|
44
|
+
diff -= 1
|
|
45
|
+
else:
|
|
46
|
+
sample_sizes[index] -= 1
|
|
47
|
+
diff += 1
|
|
48
|
+
i += 1
|
|
49
|
+
|
|
50
|
+
# Generate sampled sets
|
|
51
|
+
for i, sublist in enumerate(input_sets):
|
|
52
|
+
cardinality = sample_sizes[i]
|
|
53
|
+
sampled_set = (
|
|
54
|
+
random_selection_operator(cardinality)
|
|
55
|
+
.input_set(sublist)
|
|
56
|
+
.execute()
|
|
57
|
+
.get_output()
|
|
58
|
+
)
|
|
59
|
+
self._output.add_element(sampled_set)
|
|
60
|
+
|
|
61
|
+
return self
|
|
62
|
+
raise RuntimeError("Input is not a set of sets")
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from sampling_mining_workflows_dsl.operator.Operator import Operator
|
|
2
|
+
from sampling_mining_workflows_dsl.operator.selection.sampling.automatic.AutomaticSamplingOperator import (
|
|
3
|
+
AutomaticSamplingOperator,
|
|
4
|
+
)
|
|
5
|
+
from sampling_mining_workflows_dsl.Workflow import Workflow
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SystematicRandomSelectionOperator(AutomaticSamplingOperator):
|
|
9
|
+
def __init__(self, workflow: Workflow, cardinality: int, pas: int):
|
|
10
|
+
super().__init__(workflow, cardinality)
|
|
11
|
+
self.pas = pas
|
|
12
|
+
|
|
13
|
+
def execute(self) -> Operator:
|
|
14
|
+
raise NotImplementedError("Unimplemented method 'execute'")
|
sampling_mining_workflows_dsl/operator/selection/sampling/automatic/SystematicSelectionOperator.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from sampling_mining_workflows_dsl.constraint import NaturalComparator
|
|
2
|
+
from sampling_mining_workflows_dsl.constraint.Comparator import Comparator
|
|
3
|
+
from sampling_mining_workflows_dsl.operator.Operator import Operator
|
|
4
|
+
from sampling_mining_workflows_dsl.operator.selection.sampling.automatic.AutomaticSamplingOperator import (
|
|
5
|
+
AutomaticSamplingOperator,
|
|
6
|
+
)
|
|
7
|
+
from sampling_mining_workflows_dsl.Workflow import Workflow
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class SystematicSelectionOperator(AutomaticSamplingOperator):
|
|
11
|
+
def __init__(
|
|
12
|
+
self,
|
|
13
|
+
workflow: Workflow,
|
|
14
|
+
cardinality: int,
|
|
15
|
+
metadata_name: str,
|
|
16
|
+
reverse=False,
|
|
17
|
+
step: int = 1,
|
|
18
|
+
order_constraint: Comparator = NaturalComparator,
|
|
19
|
+
):
|
|
20
|
+
super().__init__(workflow, cardinality)
|
|
21
|
+
|
|
22
|
+
self.metadata_name = metadata_name
|
|
23
|
+
self.step = step
|
|
24
|
+
self.order_constraint = order_constraint
|
|
25
|
+
|
|
26
|
+
def execute(self) -> Operator:
|
|
27
|
+
self._input.sort_by_metadata(
|
|
28
|
+
self.metadata_name, self.order_constraint, self.reverse
|
|
29
|
+
)
|
|
30
|
+
self._output = self._input.get_systematic_subset(self._cardinality, self.step)
|
|
31
|
+
return self
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from typing import TypeVar
|
|
2
|
+
|
|
3
|
+
from sampling_mining_workflows_dsl.element.Repository import Repository
|
|
4
|
+
from sampling_mining_workflows_dsl.element.Set import Set
|
|
5
|
+
from sampling_mining_workflows_dsl.operator.Operator import Operator
|
|
6
|
+
from sampling_mining_workflows_dsl.operator.selection.sampling.manual.ManualSamplingOperator import (
|
|
7
|
+
ManualSamplingOperator,
|
|
8
|
+
)
|
|
9
|
+
from sampling_mining_workflows_dsl.Workflow import Workflow
|
|
10
|
+
|
|
11
|
+
T = TypeVar("T")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class InteractiveManualSamplingOperator[T](ManualSamplingOperator):
|
|
15
|
+
def __init__(self, workflow: Workflow):
|
|
16
|
+
super().__init__(workflow)
|
|
17
|
+
|
|
18
|
+
def execute(self) -> Operator:
|
|
19
|
+
self._output = Set()
|
|
20
|
+
|
|
21
|
+
print(f"input : \n{self._input.to_string() if self._input else 'None'}")
|
|
22
|
+
for element in self._input.get_elements():
|
|
23
|
+
if isinstance(element, Repository):
|
|
24
|
+
user_input = (
|
|
25
|
+
input(
|
|
26
|
+
f"Do you want to keep the project with ID {element.get_id()}? (yes/no/stop): "
|
|
27
|
+
)
|
|
28
|
+
.strip()
|
|
29
|
+
.lower()
|
|
30
|
+
)
|
|
31
|
+
if user_input in {"yes", "y"}:
|
|
32
|
+
self._output.add_element(element)
|
|
33
|
+
elif user_input in {"stop"}:
|
|
34
|
+
return self
|
|
35
|
+
else:
|
|
36
|
+
raise RuntimeError(
|
|
37
|
+
"Interactive manual sampling not implemented for sets"
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
return self
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from typing import TypeVar
|
|
2
|
+
|
|
3
|
+
from sampling_mining_workflows_dsl.element.Repository import Repository
|
|
4
|
+
from sampling_mining_workflows_dsl.element.Set import Set
|
|
5
|
+
from sampling_mining_workflows_dsl.operator.Operator import Operator
|
|
6
|
+
from sampling_mining_workflows_dsl.operator.selection.sampling.SamplingOperator import (
|
|
7
|
+
SamplingOperator,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
T = TypeVar("T")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ManualSamplingOperator[T](SamplingOperator):
|
|
14
|
+
def __init__(self, workflow, *ids: T):
|
|
15
|
+
super().__init__(workflow, len(ids))
|
|
16
|
+
self.ids = ids
|
|
17
|
+
|
|
18
|
+
def execute(self) -> Operator:
|
|
19
|
+
self._output = Set()
|
|
20
|
+
|
|
21
|
+
for element in self._input.get_elements():
|
|
22
|
+
if isinstance(element, Repository):
|
|
23
|
+
if any(element.get_id() == id_ for id_ in self.ids):
|
|
24
|
+
self._output.add_element(element)
|
|
25
|
+
else:
|
|
26
|
+
raise RuntimeError("Manual sampling not implemented for sets")
|
|
27
|
+
super().execute()
|
|
28
|
+
return self
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from typing import TypeVar
|
|
2
|
+
|
|
3
|
+
from sampling_mining_workflows_dsl.element.Loader import Loader
|
|
4
|
+
from sampling_mining_workflows_dsl.element.Repository import Repository
|
|
5
|
+
from sampling_mining_workflows_dsl.element.Set import Set
|
|
6
|
+
from sampling_mining_workflows_dsl.operator.Operator import Operator
|
|
7
|
+
from sampling_mining_workflows_dsl.operator.selection.sampling.SamplingOperator import (
|
|
8
|
+
SamplingOperator,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
T = TypeVar("T")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ExternalSetOperator(Operator):
|
|
15
|
+
set_function = None
|
|
16
|
+
def __init__(self, workflow,loader:Loader):
|
|
17
|
+
self.loader = loader
|
|
18
|
+
super().__init__(workflow)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def execute(self) -> Operator:
|
|
22
|
+
if not self._output.size()==0:
|
|
23
|
+
print("Warning: output set is not empty, clearing it")
|
|
24
|
+
self.output_set.remove_all_elements()
|
|
25
|
+
set= self.loader.load()
|
|
26
|
+
self.output_set.add(self.input_set)
|
|
27
|
+
self.set_function(self.output_set,set)
|
|
28
|
+
super().execute()
|
|
29
|
+
return self
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from typing import TypeVar
|
|
2
|
+
|
|
3
|
+
from sampling_mining_workflows_dsl.element.Repository import Repository
|
|
4
|
+
from sampling_mining_workflows_dsl.element.Set import Set
|
|
5
|
+
from sampling_mining_workflows_dsl.operator.Operator import Operator
|
|
6
|
+
from sampling_mining_workflows_dsl.operator.selection.sampling.SamplingOperator import (
|
|
7
|
+
SamplingOperator,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
T = TypeVar("T")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class InternalSetOperator(Operator):
|
|
14
|
+
set_function = None
|
|
15
|
+
def __init__(self, workflow,indexes=[-1]):
|
|
16
|
+
self.indexes=indexes
|
|
17
|
+
super().__init__(workflow)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def execute(self) -> Operator:
|
|
21
|
+
|
|
22
|
+
if self._input.get_depth() < 2:
|
|
23
|
+
raise ValueError(f" Internal set Operator need a set of depth >= 2")
|
|
24
|
+
if not self._output:
|
|
25
|
+
self._output = Set()
|
|
26
|
+
if not self._output.size()==0:
|
|
27
|
+
print("Warning: output set is not empty, clearing it")
|
|
28
|
+
self._output.remove_all_elements()
|
|
29
|
+
|
|
30
|
+
if self.indexes == [-1]:
|
|
31
|
+
self.indexes = list(range(self._input.size()))
|
|
32
|
+
|
|
33
|
+
#get the first set and delete it from the list
|
|
34
|
+
set_res = self._input.get_element_by_index(self.indexes.pop(0)).clone()
|
|
35
|
+
|
|
36
|
+
for i in self.indexes:
|
|
37
|
+
set = self._input.get_element_by_index(i)
|
|
38
|
+
if not isinstance(set, Set):
|
|
39
|
+
raise ValueError("Internal set Operator need need a set of depth >= 2")
|
|
40
|
+
self.set_function(set_res,set)
|
|
41
|
+
for element in set_res.elements.values():
|
|
42
|
+
self._output.add_element(element)
|
|
43
|
+
super().execute()
|
|
44
|
+
return self
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from typing import TypeVar
|
|
2
|
+
|
|
3
|
+
from sampling_mining_workflows_dsl.element.Repository import Repository
|
|
4
|
+
from sampling_mining_workflows_dsl.element.Set import Set
|
|
5
|
+
from sampling_mining_workflows_dsl.operator.Operator import Operator
|
|
6
|
+
from sampling_mining_workflows_dsl.operator.selection.sampling.SamplingOperator import (
|
|
7
|
+
SamplingOperator,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
T = TypeVar("T")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class SetOperator(Operator):
|
|
14
|
+
set_function = None
|
|
15
|
+
def __init__(self, workflow,other:Set):
|
|
16
|
+
self.other = other
|
|
17
|
+
super().__init__(workflow)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def execute(self) -> Operator:
|
|
21
|
+
if not self._output.size()==0:
|
|
22
|
+
print("Warning: output set is not empty, clearing it")
|
|
23
|
+
self.output_set.remove_all_elements()
|
|
24
|
+
|
|
25
|
+
self.output_set.add(self.input_set)
|
|
26
|
+
self.set_function(self.output_set,set)
|
|
27
|
+
super().execute()
|
|
28
|
+
return self
|
|
29
|
+
|
|
30
|
+
|
sampling_mining_workflows_dsl/operator/set_algebra/external_set_operator/DifferenceOperator.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from typing import TypeVar
|
|
2
|
+
|
|
3
|
+
from sampling_mining_workflows_dsl.element.Repository import Repository
|
|
4
|
+
from sampling_mining_workflows_dsl.element.Set import Set
|
|
5
|
+
from sampling_mining_workflows_dsl.operator.Operator import Operator
|
|
6
|
+
from sampling_mining_workflows_dsl.operator.selection.sampling.SamplingOperator import (
|
|
7
|
+
SamplingOperator,
|
|
8
|
+
)
|
|
9
|
+
from sampling_mining_workflows_dsl.operator.set_algebra import ExternalSetOperator
|
|
10
|
+
|
|
11
|
+
T = TypeVar("T")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class DifferenceOperator(ExternalSetOperator):
|
|
15
|
+
def __init__(self, workflow,indexes=[-1]):
|
|
16
|
+
super().__init__(workflow)
|
|
17
|
+
self.set_function = Set.difference
|
sampling_mining_workflows_dsl/operator/set_algebra/external_set_operator/IntersectionOperator.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from typing import TypeVar
|
|
2
|
+
|
|
3
|
+
from sampling_mining_workflows_dsl.element.Repository import Repository
|
|
4
|
+
from sampling_mining_workflows_dsl.element.Set import Set
|
|
5
|
+
from sampling_mining_workflows_dsl.operator.Operator import Operator
|
|
6
|
+
from sampling_mining_workflows_dsl.operator.selection.sampling.SamplingOperator import (
|
|
7
|
+
SamplingOperator,
|
|
8
|
+
)
|
|
9
|
+
from sampling_mining_workflows_dsl.operator.set_algebra import ExternalSetOperator
|
|
10
|
+
from sampling_mining_workflows_dsl.operator.set_algebra.InternalSetOperator import InternalSetOperator
|
|
11
|
+
|
|
12
|
+
T = TypeVar("T")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class IntersectionOperator(ExternalSetOperator):
|
|
16
|
+
def __init__(self, workflow,indexes=[-1]):
|
|
17
|
+
super().__init__(workflow)
|
|
18
|
+
self.set_function = Set.intersection
|
|
19
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from typing import TypeVar
|
|
2
|
+
|
|
3
|
+
from sampling_mining_workflows_dsl.element.Repository import Repository
|
|
4
|
+
from sampling_mining_workflows_dsl.element.Set import Set
|
|
5
|
+
from sampling_mining_workflows_dsl.operator.Operator import Operator
|
|
6
|
+
from sampling_mining_workflows_dsl.operator.selection.sampling.SamplingOperator import (
|
|
7
|
+
SamplingOperator,
|
|
8
|
+
)
|
|
9
|
+
from sampling_mining_workflows_dsl.operator.set_algebra import ExternalSetOperator
|
|
10
|
+
|
|
11
|
+
T = TypeVar("T")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class UnionOperator(ExternalSetOperator):
|
|
15
|
+
def __init__(self, workflow, indexes=[-1]):
|
|
16
|
+
super().__init__(workflow)
|
|
17
|
+
self.set_function = Set.union
|
sampling_mining_workflows_dsl/operator/set_algebra/internal_set_operator/DifferenceOperator.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from typing import TypeVar
|
|
2
|
+
|
|
3
|
+
from sampling_mining_workflows_dsl.element.Repository import Repository
|
|
4
|
+
from sampling_mining_workflows_dsl.element.Set import Set
|
|
5
|
+
from sampling_mining_workflows_dsl.operator.Operator import Operator
|
|
6
|
+
from sampling_mining_workflows_dsl.operator.selection.sampling.SamplingOperator import (
|
|
7
|
+
SamplingOperator,
|
|
8
|
+
)
|
|
9
|
+
from sampling_mining_workflows_dsl.operator.set_algebra.InternalSetOperator import InternalSetOperator
|
|
10
|
+
|
|
11
|
+
T = TypeVar("T")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class DifferenceOperator(InternalSetOperator):
|
|
15
|
+
def __init__(self, workflow,indexes=[-1]):
|
|
16
|
+
super().__init__(workflow)
|
|
17
|
+
self.set_function = Set.difference
|
sampling_mining_workflows_dsl/operator/set_algebra/internal_set_operator/IntersectionOperator.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from typing import TypeVar
|
|
2
|
+
|
|
3
|
+
from sampling_mining_workflows_dsl.element.Repository import Repository
|
|
4
|
+
from sampling_mining_workflows_dsl.element.Set import Set
|
|
5
|
+
from sampling_mining_workflows_dsl.operator.Operator import Operator
|
|
6
|
+
from sampling_mining_workflows_dsl.operator.selection.sampling.SamplingOperator import (
|
|
7
|
+
SamplingOperator,
|
|
8
|
+
)
|
|
9
|
+
from sampling_mining_workflows_dsl.operator.set_algebra.InternalSetOperator import InternalSetOperator
|
|
10
|
+
|
|
11
|
+
T = TypeVar("T")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class IntersectionOperator(InternalSetOperator):
|
|
15
|
+
def __init__(self, workflow,indexes=[-1]):
|
|
16
|
+
super().__init__(workflow)
|
|
17
|
+
self.set_function = Set.intersection
|
|
18
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from typing import TypeVar
|
|
2
|
+
|
|
3
|
+
from sampling_mining_workflows_dsl.element.Repository import Repository
|
|
4
|
+
from sampling_mining_workflows_dsl.element.Set import Set
|
|
5
|
+
from sampling_mining_workflows_dsl.operator.Operator import Operator
|
|
6
|
+
from sampling_mining_workflows_dsl.operator.selection.sampling.SamplingOperator import (
|
|
7
|
+
SamplingOperator,
|
|
8
|
+
)
|
|
9
|
+
from sampling_mining_workflows_dsl.operator.set_algebra.InternalSetOperator import InternalSetOperator
|
|
10
|
+
|
|
11
|
+
T = TypeVar("T")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class UnionOperator(InternalSetOperator):
|
|
15
|
+
def __init__(self, workflow, indexes=[-1]):
|
|
16
|
+
super().__init__(workflow)
|
|
17
|
+
self.set_function = Set.union
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from typing import TypeVar
|
|
2
|
+
|
|
3
|
+
from sampling_mining_workflows_dsl.element.Repository import Repository
|
|
4
|
+
from sampling_mining_workflows_dsl.element.Set import Set
|
|
5
|
+
from sampling_mining_workflows_dsl.operator.Operator import Operator
|
|
6
|
+
|
|
7
|
+
from sampling_mining_workflows_dsl.operator.set_algebra.SetOperator import SetOperator
|
|
8
|
+
|
|
9
|
+
T = TypeVar("T")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class DifferenceOperator(SetOperator):
|
|
13
|
+
def __init__(self, workflow,indexes=[-1]):
|
|
14
|
+
super().__init__(workflow)
|
|
15
|
+
self.set_function = Set.difference
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from typing import TypeVar
|
|
2
|
+
|
|
3
|
+
from sampling_mining_workflows_dsl.element.Repository import Repository
|
|
4
|
+
from sampling_mining_workflows_dsl.element.Set import Set
|
|
5
|
+
from sampling_mining_workflows_dsl.operator.Operator import Operator
|
|
6
|
+
from sampling_mining_workflows_dsl.operator.selection.sampling.SamplingOperator import (
|
|
7
|
+
SamplingOperator,
|
|
8
|
+
)
|
|
9
|
+
from sampling_mining_workflows_dsl.operator.set_algebra.SetOperator import SetOperator
|
|
10
|
+
|
|
11
|
+
T = TypeVar("T")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class IntersectionOperator(SetOperator):
|
|
15
|
+
def __init__(self, workflow,indexes=[-1]):
|
|
16
|
+
super().__init__(workflow)
|
|
17
|
+
self.set_function = Set.intersection
|
|
18
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from typing import TypeVar
|
|
2
|
+
|
|
3
|
+
from sampling_mining_workflows_dsl.element.Repository import Repository
|
|
4
|
+
from sampling_mining_workflows_dsl.element.Set import Set
|
|
5
|
+
from sampling_mining_workflows_dsl.operator.Operator import Operator
|
|
6
|
+
from sampling_mining_workflows_dsl.operator.selection.sampling.SamplingOperator import (
|
|
7
|
+
SamplingOperator,
|
|
8
|
+
)
|
|
9
|
+
from sampling_mining_workflows_dsl.operator.set_algebra.SetOperator import SetOperator
|
|
10
|
+
|
|
11
|
+
T = TypeVar("T")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class UnionOperator(SetOperator):
|
|
15
|
+
def __init__(self, workflow, indexes=[-1]):
|
|
16
|
+
super().__init__(workflow)
|
|
17
|
+
self.set_function = Set.union
|
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from sampling_mining_workflows_dsl.element.loader.LoaderFactory import LoaderFactory
|
|
2
|
+
from sampling_mining_workflows_dsl.element.writer.WriterFactory import WritterFactory
|
|
3
|
+
from sampling_mining_workflows_dsl.exec_visualizer.WorkflowVisualizer import WorkflowVisualizer
|
|
4
|
+
from sampling_mining_workflows_dsl.metadata.Metadata import Metadata
|
|
5
|
+
from sampling_mining_workflows_dsl.operator.clustering.SubWorkflowOperatorBuilder import (
|
|
6
|
+
SubWorkflowOperatorBuilder,
|
|
7
|
+
)
|
|
8
|
+
from sampling_mining_workflows_dsl.WorkflowBuilder import WorkflowBuilder
|
|
9
|
+
|
|
10
|
+
json_loader = LoaderFactory.json_loader
|
|
11
|
+
json_writer = WritterFactory.json_writer
|
|
12
|
+
filter_operator = SubWorkflowOperatorBuilder.filter_operator
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def main():
|
|
16
|
+
import os
|
|
17
|
+
|
|
18
|
+
input_path = os.path.join(os.path.dirname(__file__), "input.json")
|
|
19
|
+
|
|
20
|
+
language = Metadata.of_string("language")
|
|
21
|
+
id_ = Metadata.of_string("id")
|
|
22
|
+
commit_nb = Metadata.of_integer("commitNb")
|
|
23
|
+
|
|
24
|
+
w = (
|
|
25
|
+
WorkflowBuilder()
|
|
26
|
+
.input(json_loader(input_path, id_, commit_nb, language))
|
|
27
|
+
.filter_operator("commitNb > 2000 and commitNb < 7000")
|
|
28
|
+
.random_selection_operator(40)
|
|
29
|
+
.output(json_writer("out.json"))
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
w.execute_workflow()
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
if __name__ == "__main__":
|
|
37
|
+
main()
|
|
38
|
+
|