-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Adding Helper/Utility Functionality (Merging, Clearing Empty, Value Type Promotion) #164
Comments
Do you have some example applications for some of these features?
I guess you'd probably also want to think about cloning too, although again I'm not sure about the use case. |
So I'm working on a service I've called BrandVantage which one of its core features is to convert any web page to a Schema.org WebPage as it is already an interoperable standard. I generate the objects by parsing details out of the page (eg. JSON-LD, Microdata) combined with other heuristics to get essentially a computer-readable page object.
As I convert data from a variety of sources into Schema.org objects, merging them together is imperative to avoid duplicate data - having two
Yep - basically perform a depth-first search of objects with default properties. Another useful thing for both minifying and merging.
That is very true though its really a case-by-case basis. If I have a Going one step further, if we had a This process (or the reverse, Value Type Demotion) are helpful for merging - having a My reasons for promotion/up-casting is to allow more consistency in the data. Having some images be just a
Yeah definitely. Expressing an Really each of these is just different ways to manipulate the objects. At the core, we'd need a good way to traverse the objects depth-first and a way to update a Regarding cloning, while it would likely be useful for the same types of reasons, I personally haven't had the need to clone objects yet. |
Describe the feature
There is a set of functionality that I'm working on that I think would be a good fit for the library as utilities for working with Schema objects in certain ways.
Merging
It would be useful to be able to merge appropriate objects and their properties together (where applicable) and use other known "ID" properties (eg.
URL
orIdentifier
properties, both path ofIThing
) to know whether they should merge.Because at its core, every property can have one or many values, merging them isn't too difficult. We would probably want a way to provide custom type comparers though as people do extend schema types etc let alone for other examples (eg. maybe URLs are considered equal even if their query string is different).
Clearing Empty
This fits somewhat closely with the Merging one - being able to remove Schema objects with no values specifically defined would be a useful feature. This can be as simple as check the count on each property.
Value Type Promotion
This one is useful, especially prior to running any Merge logic - in many cases, a value can be represented by multiple types for a single property. For example, an image might be a
Uri
or it might be aImageObject
.Value promotion would be a way to convert a
new Uri()
to annew ImageObject { Uri = theUri }
as these two are functionally equivalent. In a form like this, it can make dealing with external data (where you don't control the consistency of it) a lot easier to deal with.There may even be use for going the other way too (converting an
ImageObject
with only theUri
property set back to just aUri
type) - maybe for making the most size-efficient JSON - though personally I haven't needed to.These features are useful for working with the Schema objects in different ways though at the same time, might not actually need to belong to the main library. This might be a good utility library like
Schema.NET.Utilities
or something - I'll leave that up to you.Right now, I've got pretty "crappy" implementations of these in my current project (something that heavily relies on Schema.NET) and I don't know when I will be able to get better versions as a PR, this issue is to initially raise this as a point of discussion and get your thoughts on it and whether it would be worth having in the main library or in a utility library.
The text was updated successfully, but these errors were encountered: