Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Imène Lajili
clowdflows
Commits
dd59a8eb
Commit
dd59a8eb
authored
Jan 12, 2016
by
Alain Shakour
Browse files
Add PRD & KDIC converters to cforange
parent
9aa68ae2
Changes
4
Hide whitespace changes
Inline
Side-by-side
workflows/cforange/library.py
View file @
dd59a8eb
...
...
@@ -523,6 +523,23 @@ def cforange_hierarchical_clustering_finished(postdata, input_dict, output_dict)
centroids
,
selected_table
,
unselected_table
=
None
,
None
,
None
return
{
'centroids'
:
centroids
,
'selected_examples'
:
selected_table
,
'unselected_examples'
:
unselected_table
}
def
cforange_odt_to_kdic
(
input_dict
):
from
odt_converters
import
toKDICstring
,
toKDICheader
output_dict
=
{}
f
=
toKDICheader
(
input_dict
[
'odt'
])
output_dict
[
'kdic'
]
=
f
.
getvalue
()
f2
=
toKDICstring
(
input_dict
[
'odt'
])
output_dict
[
'txt'
]
=
f2
.
getvalue
()
return
output_dict
def
cforange_odt_to_prd_fct
(
input_dict
):
from
odt_converters
import
toPRDstring
,
toFCTstring
output_dict
=
{}
f
=
toPRDstring
(
input_dict
[
'odt'
])
output_dict
[
'prd'
]
=
f
.
getvalue
()
f2
=
toFCTstring
(
input_dict
[
'odt'
])
output_dict
[
'fct'
]
=
f2
.
getvalue
()
return
output_dict
def
filter_table
(
input_dict
):
return
{
'altered_data'
:
None
}
...
...
workflows/cforange/odt_converters.py
0 → 100644
View file @
dd59a8eb
def
toKDICheader
(
table
,
try_numericize
=
0
):
import
cStringIO
,
string
t
=
table
f
=
cStringIO
.
StringIO
()
f
.
write
(
'
\n
Dictionary
\t
%s
\n
'
%
t
.
name
)
f
.
write
(
'{
\n
'
)
ats
=
[
i
for
i
in
t
.
domain
.
attributes
]
ats
.
append
(
t
.
domain
.
classVar
)
for
i
in
ats
:
real
=
True
if
i
.
varType
==
1
:
if
try_numericize
:
# try if all values numeric
for
j
in
i
.
values
:
try
:
x
=
string
.
atof
(
j
)
except
:
real
=
False
# failed
break
else
:
real
=
False
iname
=
str
(
i
.
name
)
if
string
.
find
(
iname
,
" "
)
!=
-
1
:
iname
=
"'%s'"
%
iname
if
real
:
f
.
write
(
'
\t
Numerical
\t
%s
\t\t
;
\n
'
%
iname
)
else
:
f
.
write
(
'
\t
Categorical
\t
%s
\t\t
;
\n
'
%
iname
)
f
.
write
(
'};
\n
'
)
return
f
def
toKDICstring
(
table
,
try_numericize
=
0
):
import
cStringIO
,
string
t
=
table
f
=
cStringIO
.
StringIO
()
ats
=
[
i
for
i
in
t
.
domain
.
attributes
]
ats
.
append
(
t
.
domain
.
classVar
)
for
i
in
ats
:
iname
=
str
(
i
.
name
)
f
.
write
(
'%s
\t
'
%
iname
)
f
.
write
(
'
\n
'
)
for
j
in
t
:
x
=
[]
for
i
in
range
(
len
(
ats
)):
s
=
str
(
j
[
i
])
if
string
.
find
(
s
,
" "
)
==
-
1
:
x
.
append
(
"%s"
%
s
)
else
:
x
.
append
(
"'%s'"
%
s
)
for
i
in
x
[:
-
1
]:
f
.
write
(
'%s
\t
'
%
i
)
f
.
write
(
'%s
\n
'
%
x
[
-
1
])
return
f
def
toPRDstring
(
table
,
try_numericize
=
0
):
import
cStringIO
,
string
t
=
table
f
=
cStringIO
.
StringIO
()
f
.
write
(
'--INDIVIDUAL
\n
'
)
f
.
write
(
'%s 1 %s cwa
\n
'
%
(
t
.
name
,
t
.
name
))
f
.
write
(
'--STRUCTURAL
\n
'
)
f
.
write
(
'--PROPERTIES
\n
'
)
f
.
write
(
'class 2 %s #class cwa
\n
'
%
t
.
name
)
ats
=
[
i
for
i
in
t
.
domain
.
attributes
]
ats
.
append
(
t
.
domain
.
classVar
)
for
i
in
ats
:
iname
=
str
(
i
.
name
)
if
string
.
find
(
iname
,
" "
)
!=
-
1
:
iname
=
"'%s'"
%
iname
f
.
write
(
'%s 2 %s #%s 1 cwa
\n
'
%
(
iname
,
t
.
name
,
iname
))
return
f
def
toFCTstring
(
table
,
try_numericize
=
0
):
import
cStringIO
,
string
t
=
table
f
=
cStringIO
.
StringIO
()
ats
=
[
i
for
i
in
t
.
domain
.
attributes
]
ats
.
append
(
t
.
domain
.
classVar
)
for
j
in
t
:
f
.
write
(
'!
\n
'
)
x
=
[]
for
i
in
range
(
len
(
ats
)):
s
=
str
(
j
[
i
])
if
ats
[
i
].
name
==
t
.
domain
.
classVar
.
name
:
x
.
insert
(
0
,
"%s(%s,%s)"
%
(
t
.
domain
.
classVar
.
name
,
j
.
id
,
s
))
elif
string
.
find
(
s
,
" "
)
==
-
1
:
x
.
append
(
"%s(%s,%s)"
%
(
ats
[
i
].
name
,
j
.
id
,
s
))
else
:
x
.
append
(
"'%s'"
%
s
)
for
i
in
x
:
f
.
write
(
'%s
\n
'
%
(
i
))
f
.
write
(
'
\n
'
)
return
f
workflows/cforange/package_data/widgets/70718b14-851b-40ed-9091-3e83a95bee5e.json
0 → 100644
View file @
dd59a8eb
[
{
"model"
:
"workflows.abstractwidget"
,
"fields"
:
{
"category"
:
"aa3ed779-1e0b-4c6b-883e-24d85b9a6009"
,
"treeview_image"
:
""
,
"uid"
:
"70718b14-851b-40ed-9091-3e83a95bee5e"
,
"windows_queue"
:
false
,
"package"
:
"cforange"
,
"interaction_view"
:
""
,
"has_progress_bar"
:
false
,
"image"
:
""
,
"description"
:
"It transforms a Orange Data Table into the Prd and Fct files used by Tertius, 1BC and 1BC2 widget. Its input is a Database context widget."
,
"static_image"
:
""
,
"action"
:
"cforange_odt_to_prd_fct"
,
"visualization_view"
:
""
,
"streaming_visualization_view"
:
""
,
"post_interact_action"
:
""
,
"wsdl_method"
:
""
,
"wsdl"
:
""
,
"interactive"
:
false
,
"is_streaming"
:
false
,
"order"
:
1
,
"name"
:
"Orange Data Table to Prd and Fct"
}
},
{
"model"
:
"workflows.abstractinput"
,
"fields"
:
{
"widget"
:
"70718b14-851b-40ed-9091-3e83a95bee5e"
,
"name"
:
"orange data table"
,
"short_name"
:
"odt"
,
"default"
:
""
,
"description"
:
""
,
"required"
:
false
,
"multi"
:
false
,
"parameter_type"
:
null
,
"variable"
:
"odt"
,
"parameter"
:
false
,
"order"
:
1
,
"uid"
:
"4845f9a5-1068-4669-9feb-54a0edf80e7d"
}
},
{
"model"
:
"workflows.abstractoutput"
,
"fields"
:
{
"widget"
:
"70718b14-851b-40ed-9091-3e83a95bee5e"
,
"name"
:
"fct file"
,
"short_name"
:
"fct"
,
"description"
:
"to Tertius, 1BC or 1BC2"
,
"variable"
:
"fct"
,
"order"
:
2
,
"uid"
:
"1f6c8d49-771c-4614-87fe-d8b973d02caf"
}
},
{
"model"
:
"workflows.abstractoutput"
,
"fields"
:
{
"widget"
:
"70718b14-851b-40ed-9091-3e83a95bee5e"
,
"name"
:
"prd file"
,
"short_name"
:
"prd"
,
"description"
:
"to Tertius, 1BC or 1BC2"
,
"variable"
:
"prd"
,
"order"
:
1
,
"uid"
:
"5b7b93f9-6596-4840-8461-b52718c0bce9"
}
}
]
\ No newline at end of file
workflows/cforange/package_data/widgets/777bee59-4e3f-4818-91f4-78d9c020d622.json
0 → 100644
View file @
dd59a8eb
[
{
"model"
:
"workflows.abstractwidget"
,
"fields"
:
{
"category"
:
"aa3ed779-1e0b-4c6b-883e-24d85b9a6009"
,
"treeview_image"
:
""
,
"uid"
:
"777bee59-4e3f-4818-91f4-78d9c020d622"
,
"windows_queue"
:
false
,
"package"
:
"cforange"
,
"interaction_view"
:
""
,
"has_progress_bar"
:
false
,
"image"
:
""
,
"description"
:
"It generates files for khiops."
,
"static_image"
:
""
,
"action"
:
"cforange_odt_to_kdic"
,
"visualization_view"
:
""
,
"streaming_visualization_view"
:
""
,
"post_interact_action"
:
""
,
"wsdl_method"
:
""
,
"wsdl"
:
""
,
"interactive"
:
false
,
"is_streaming"
:
false
,
"order"
:
1
,
"name"
:
"Orange Data Table to KDIC String"
}
},
{
"model"
:
"workflows.abstractinput"
,
"fields"
:
{
"widget"
:
"777bee59-4e3f-4818-91f4-78d9c020d622"
,
"name"
:
"orange data table"
,
"short_name"
:
"odt"
,
"default"
:
""
,
"description"
:
""
,
"required"
:
false
,
"multi"
:
false
,
"parameter_type"
:
null
,
"variable"
:
"odt"
,
"parameter"
:
false
,
"order"
:
1
,
"uid"
:
"06db825a-76da-4019-bc4d-aae67a8de245"
}
},
{
"model"
:
"workflows.abstractoutput"
,
"fields"
:
{
"widget"
:
"777bee59-4e3f-4818-91f4-78d9c020d622"
,
"name"
:
"KDIC"
,
"short_name"
:
"kdc"
,
"description"
:
"Header file"
,
"variable"
:
"kdic"
,
"order"
:
1
,
"uid"
:
"075d553f-5133-4023-8148-5a2edc520af3"
}
},
{
"model"
:
"workflows.abstractoutput"
,
"fields"
:
{
"widget"
:
"777bee59-4e3f-4818-91f4-78d9c020d622"
,
"name"
:
"TXT"
,
"short_name"
:
"txt"
,
"description"
:
"containing CSV data"
,
"variable"
:
"txt"
,
"order"
:
2
,
"uid"
:
"8d0df2c8-5969-4a82-b752-376534beea04"
}
}
]
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment