-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added InferDictionariesFromRecords flag to JSON TP #1430
Conversation
JSON TP always projects json record fields into the properties of generated types. Sometimes it is not desirable. The added flag will allow to infer dictionaries from the records if the names of all the fields of similar records in the provider's training data are inferred to the same non-string primitive type (by type inference rules). The flag is not set by default for backwards compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took a look, I think this is a great feature to add. Code looks reasonable.
I'd like to spend a little time mulling it over, though. @dsyme would like to get your take as well.
- removed extra pipe ! added missing newline at end of the files + code reusing
Suggest |
I left a couple of suggestions, but otherwise marked as approved, the code looks great |
- dropped overused lambda expressions * renamed the InferDictionariesFromRecords flag into PreferDictionaries
done |
Thanks! |
JSON TP always projects json record fields into the properties
of generated types. Sometimes it is not desirable. The added
flag will allow to infer dictionaries from the records if the names
of all the fields of similar records in the provider's training data
are inferred to the same non-string primitive type (by type inference
rules). The flag is not set by default for backwards compatibility.
The current implementation makes it meaningless to process such data in the JSON Provider:
With this PR, for example, it is easy to find out from the above data how many sales were in February:
In addition to the
Items: (InferedKey * InferedValue) seq
property specified in the code above, the generated dictionary-like type contains theCount
,IsEmpty
,Keys
,Values
properties, theItem
indexed property, and theContainsKey
,TryFind
methods, similar to the members ofFSharp.Collections.Map