Skip to content
Advertisement

How to correctly pass a split function to TextVectorization layer

I’m defining a custom split callable for TextVectorization like this:

JavaScript

resulting in:

JavaScript

as seen above the split function is working correctly outside of the TextVectorization layer but failes when passed as a callable

Advertisement

Answer

Your split_slash function does not seem to properly tokenize the phrases.

JavaScript

It is probably because your TextVectorization layer strips your phrases of all punctuation including / by default before your split_slash function is called. Setting standardize=None in your TextVectorization layer will do the trick for you.

Alternatively, you could also try the following snippet.

JavaScript

Note that your phrases are split on whitespace by default after removing your slashes.

JavaScript

For more information, check out the documentation.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement