-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Model Repository Parser for UML Diagrams (#144)
* Model Repository Parser for UML Diagrams
- Loading branch information
Showing
3 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import re | ||
import os | ||
|
||
from fedot_ind.api.utils.path_lib import DEFAULT_PATH_MODELS | ||
|
||
with open(DEFAULT_PATH_MODELS, 'r') as file: | ||
file_content = [string for string in file.read().split("\n") if not string.startswith("from")] | ||
file_content = file_content[:next((i for i, line in enumerate(file_content) if line.startswith("def")), None)] | ||
file_content = file_content[next((i for i, line in enumerate(file_content) if line == '}'), None) + 1:] | ||
|
||
pattern = re.compile(r'\b[A-Z_]+\b') | ||
|
||
substrings = [] | ||
for s in file_content: | ||
matches = pattern.findall(s) | ||
substrings.extend(matches) | ||
substrings = list(set(substrings)) | ||
|
||
res = ["@startuml", "'https://plantuml.com/sequence-diagram", "", "class AtomizedModel {", " Enum", "}", ""] | ||
for ind in substrings: | ||
res += ["abstract " + ind] | ||
res += ["", ""] | ||
|
||
res += ["INDUSTRIAL_CLF_PREPROC_MODEL --> AtomizedModel", | ||
"AtomizedModel <-- SKLEARN_CLF_MODELS", | ||
"FEDOT_PREPROC_MODEL --> AtomizedModel", | ||
"AtomizedModel <- INDUSTRIAL_PREPROC_MODEL", | ||
"SKLEARN_REG_MODELS --> AtomizedModel", | ||
"AtomizedModel <-- FORECASTING_MODELS", | ||
"FORECASTING_PREPROC -> AtomizedModel", | ||
"NEURAL_MODEL -> AtomizedModel", ""] | ||
|
||
for ind in substrings: | ||
start_index = next((i for i, line in enumerate(file_content) if line.endswith(ind + " = {")), None) | ||
end_index = next((i for i, line in enumerate(file_content[start_index:]) if line.endswith("}")), | ||
None) + 1 + start_index | ||
list_of_strings = file_content[start_index:end_index] | ||
pattern = re.compile(r"': ([^']*)") | ||
formatted_strings = [pattern.search(string).group(1) if pattern.search(string) else "" | ||
for string in list_of_strings] | ||
res = res + ["abstract " + ind + " {"] + [string for string in formatted_strings if | ||
string.strip() and string.strip() != "{"] + ["}", ""] | ||
|
||
with open('your_file.puml', 'w') as f: | ||
for line in res + ["@enduml"]: | ||
f.write(f"{line}\n") | ||
|
||
os.system('python -m plantuml your_file.puml') |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
@startuml | ||
'https://plantuml.com/sequence-diagram | ||
|
||
class AtomizedModel { | ||
Enum | ||
} | ||
|
||
abstract FEDOT_PREPROC_MODEL | ||
abstract NEURAL_MODEL | ||
abstract INDUSTRIAL_PREPROC_MODEL | ||
abstract SKLEARN_CLF_MODELS | ||
abstract INDUSTRIAL_CLF_PREPROC_MODEL | ||
abstract SKLEARN_REG_MODELS | ||
abstract FORECASTING_PREPROC | ||
abstract FORECASTING_MODELS | ||
|
||
|
||
INDUSTRIAL_CLF_PREPROC_MODEL --> AtomizedModel | ||
AtomizedModel <-- SKLEARN_CLF_MODELS | ||
FEDOT_PREPROC_MODEL --> AtomizedModel | ||
AtomizedModel <- INDUSTRIAL_PREPROC_MODEL | ||
SKLEARN_REG_MODELS --> AtomizedModel | ||
AtomizedModel <-- FORECASTING_MODELS | ||
FORECASTING_PREPROC -> AtomizedModel | ||
NEURAL_MODEL -> AtomizedModel | ||
|
||
abstract FEDOT_PREPROC_MODEL { | ||
ScalingImplementation, | ||
NormalizationImplementation, | ||
ImputationImplementation, | ||
KernelPCAImplementation, | ||
TopologicalFeaturesImplementation | ||
} | ||
|
||
abstract NEURAL_MODEL { | ||
InceptionTimeModel, | ||
OmniScaleModel, | ||
ResNetModel, | ||
NBeatsModel, | ||
TSTModel, | ||
XCModel, | ||
DummyOverComplicatedNeuralNetwork, | ||
LoraModel | ||
} | ||
|
||
abstract INDUSTRIAL_PREPROC_MODEL { | ||
ChannelCentroidFilter, | ||
EigenBasisImplementation, | ||
WaveletBasisImplementation, | ||
FourierBasisImplementation, | ||
RecurrenceExtractor, | ||
QuantileExtractor, | ||
RiemannExtractor, | ||
TopologicalFeaturesImplementation, | ||
MiniRocketExtractor, | ||
ChronosExtractor, | ||
IsolationForestClassImplementation, | ||
IsolationForestRegImplementation, | ||
} | ||
|
||
abstract SKLEARN_CLF_MODELS { | ||
GradientBoostingClassifier, | ||
SklearnLogReg, | ||
DecisionTreeClassifier, | ||
RandomForestClassifier, | ||
MLPClassifier, | ||
LGBMClassifier | ||
} | ||
|
||
abstract INDUSTRIAL_CLF_PREPROC_MODEL { | ||
DecomposerClassImplementation, | ||
ResampleImplementation, | ||
} | ||
|
||
abstract SKLEARN_REG_MODELS { | ||
XGBRegressor, | ||
SklearnSGD, | ||
ExtraTreesRegressor, | ||
SklearnRidgeReg, | ||
SklearnLassoReg, | ||
DecisionTreeRegressor, | ||
LGBMRegressor, | ||
} | ||
|
||
abstract FORECASTING_PREPROC { | ||
LaggedTransformationImplementation, | ||
SparseLaggedTransformationImplementation, | ||
TsSmoothingImplementation, | ||
GaussianFilterImplementation, | ||
ExogDataTransformationImplementation, | ||
} | ||
|
||
abstract FORECASTING_MODELS { | ||
AutoRegImplementation, | ||
STLForecastARIMAImplementation, | ||
ExpSmoothingImplementation, | ||
CGRUImplementation, | ||
GLMIndustrial | ||
} | ||
|
||
@enduml |