jsonformer icon indicating copy to clipboard operation
jsonformer copied to clipboard

Return empty values

Open zacharyblank opened this issue 2 years ago • 1 comments

First off, great package! Thanks for the contribution.

I've been using this package to basically transform unstructured text to JSON. It works very well with one exception. If a value does not exist in the text, one is made up.

Instead, for a number, for example, I'd be better for it to return null or for a string to return an empty string.

I'd issue a PR but I am not sure how to accomplish this.

Thanks again!

zacharyblank avatar Jun 02 '23 23:06 zacharyblank

This is also extremely important for my use case. After looking at the code, I think the best way to implement this would be to create a null type and enable union types. e.g: {"type": ["number", "null"]}. Null types can only be one value so they would always just generate null. Union types would be more complex, but I think it's possible. Objects always start with {, arrays with [, numbers with a digit, strings with ", booleans with true or false and of course null is always null. You could check which of the above start tokens has the highest probability according to the model. Then choose the corresponding type and generate it as normal.

posionus avatar Jun 08 '23 18:06 posionus