Skip to content

Commit

Permalink
FeatureHasher, raise an error when the delimiter length is > 1 (#1036)
Browse files Browse the repository at this point in the history
* FeatureHasher, raise an error when the delimiter length is > 1

Signed-off-by: Xavier Dupre <[email protected]>

* fix error message

Signed-off-by: Xavier Dupre <[email protected]>

---------

Signed-off-by: Xavier Dupre <[email protected]>
  • Loading branch information
xadupre authored Oct 20, 2023
1 parent 84046e4 commit 8e612bb
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions skl2onnx/operator_converters/feature_hasher.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,18 @@ def convert_sklearn_feature_hasher(
out_indices = scope.get_unique_variable_name(f"out_indices{i}")
out_text = scope.get_unique_variable_name(f"out_text{i}")
out_shape = scope.get_unique_variable_name(f"out_shape{i}")
container.add_node(
"StringSplit",
[reshaped, delimiter, skip_empty],
[out_indices, out_text, out_shape],
op_domain="ai.onnx.contrib",
op_version=1,
)
if len(separator) <= 1:
container.add_node(
"StringSplit",
[reshaped, delimiter, skip_empty],
[out_indices, out_text, out_shape],
op_domain="ai.onnx.contrib",
op_version=1,
)
else:
raise RuntimeError(
f"Only one character separator are supported but delimiter is {separator!r}."
)
shape = scope.get_unique_variable_name(f"shape{i}")
container.add_node("Shape", [col_to_split.full_name], [shape])

Expand Down

0 comments on commit 8e612bb

Please sign in to comment.