Skip to content
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

Make generator extensible for other Schema definitions #25

Closed
agemmell opened this issue Sep 11, 2017 · 20 comments
Closed

Make generator extensible for other Schema definitions #25

agemmell opened this issue Sep 11, 2017 · 20 comments

Comments

@agemmell
Copy link

Not so much an issue, just a question.

I'd love to use this package but without the health-lifesci.schema.org extension I might need to roll my own. Is there a way for me to add schema extensions so I can benefit from using the MedicalOrganization type "Physician"?

Is it possible to somehow run your generator against that health-lifesci schema extension and generate a library of files in my project to augment your core files?

@sebastiandedeyne
Copy link
Member

Hmm right now not without forking this... Is there an RDFa file available though? That's what's used to generate the classes here, not sure if there are files like that available for extensions. If there is, I'd be willing to look into making the generator a bit more open for extension if it isn't too much overhead.

@greatislander
Copy link

There's this: https://github.com/schemaorg/schemaorg/blob/master/data/releases/3.3/ext-health-lifesci.rdf

Related, we would be really interested in looking into a way to include the bib.schema.org extensions:

https://github.com/schemaorg/schemaorg/blob/master/data/releases/3.3/ext-bib.rdf

If extension support is a broader feature you'd consider, I'd be delighted to help with testing if needed.

@sebastiandedeyne
Copy link
Member

I'll look into making this extensible for other rdf files, but it won't be before the end of this month.

@sebastiandedeyne sebastiandedeyne changed the title Adding Physician Make generator extensible for other Schema definitions Sep 13, 2017
@greatislander
Copy link

greatislander commented Jan 12, 2018

@sebastiandedeyne I've been looking into this and I'd like to submit a PR to allow generating classes for Schema extensions. However I want to make sure my approach works for you before I do so.

Notes

  • The RDFa files for Schema.org extension use schema:<class> in the subClassOf property instead of just <class> (e.g. schema:CreativeWork instead of CreativeWorksee here).
  • While the generate command can take a different source URL as input, running the command multiple times with multiple inputs overwrites the src folder contents and populates src/Schema.php with only the most recent set of classes.

Proposed Approach

  • This line should be modified to trim schema: from the beginning of the $type->parent property instead of ignoring types that begin with schema:.
  • The generate command should be modified to accept multiple, comma-separated sources and should parse them into a single $types object which can then be used to populate the filesystem and src/Schema.php factory.

So, to generate core types + bibliographic extension, one would run:

php generate.php generate https://raw.githubusercontent.com/schemaorg/schemaorg/sdo-callisto/data/schema.rdfa,https://raw.githubusercontent.com/schemaorg/schemaorg/sdo-callisto/data/ext/bib/bsdo-1.0.rdfa

Let me know what you think.

Edit: The generate command could also be updated to generate core types plus all extensions by default. See here.

Something like:

-     const SOURCE = 'https://raw.githubusercontent.com/schemaorg/schemaorg/sdo-callisto/data/schema.rdfa';
+     const SOURCES = [
+          'https://raw.githubusercontent.com/schemaorg/schemaorg/sdo-callisto/data/schema.rdfa',
+          'https://raw.githubusercontent.com/schemaorg/schemaorg/sdo-callisto/data/ext/auto/auto.rdfa',
+          'https://raw.githubusercontent.com/schemaorg/schemaorg/sdo-callisto/data/ext/bib/bsdo-1.0.rdfa',
+          'https://raw.githubusercontent.com/schemaorg/schemaorg/sdo-callisto/data/ext/health-lifesci/med-health-core.rdfa',
+          'https://raw.githubusercontent.com/schemaorg/schemaorg/sdo-callisto/data/ext/health-lifesci/physical-activity-and-exercise.rdfa'
+     ];

@sebastiandedeyne
Copy link
Member

I'd rather only have the core types generated in this package. I don't mind maintaining a generate command that has the option of generating more types though, I'd accept a PR that adds this.

I'm currently rewriting part of the generator to give it a huge speed boost though, so if the changes are significant you might want to wait, or do it before I've made substantial progress 😄

@greatislander
Copy link

Changes aren’t that significant; I’ll try to submit a PR today.

@greatislander
Copy link

Sorry, won't get a chance to do this today. I'll wait on your upstream changes and then submit, unless you can accept the PR later this week.

@sebastiandedeyne
Copy link
Member

No hurry, not sure when I'll be getting to my changes yet either :)

@sebastiandedeyne
Copy link
Member

Pretty far in the refactor. If you hate debugging with the long build times, you might want to wait on this, generating the code has gone down to 8 seconds from 150+ 😅

@Gummibeer
Copy link
Collaborator

@greatislander will you find time? Or is this now, like labeled, help wanted and the community can/should solve this.

@greatislander
Copy link

I still plan on doing this at some point.

@nolros
Copy link

nolros commented Jun 1, 2018

@greatislander I'm interested why support for RDF vs JSON-ld. Google has been very pro-active in promoting JSON-LD-schema.org these past couple or three years. I see very little support for inline or any other vocabulary approach. Is it some further vocabulary extension like b2b or commerce of something else that is required by RDFa?

@Gummibeer
Copy link
Collaborator

@nolros they contain the same data just different file-formats. And the generated code is json-ld.

@greatislander
Copy link

Finally getting back to looking at this.

@Gummibeer
Copy link
Collaborator

relates to #133

@mallardduck
Copy link
Contributor

@agemmell I think this issue is essentially resolved by the recent changes in #140. The Physician class is now being generated which seemed to be the specific concern mentioned. So give things a look and potentially this issue could be marked as resolved.

If there are any Schema types you think are missing still it's possible they were still Pending in the 8.0 release for schema. In that case then you may need to check back once the repo is updated to use the Schema 9.0 release. Which shouldn't be too hard to create. From what I saw in testing on that, it added a LOT more medical related Schema types.

@Gummibeer
Copy link
Collaborator

I'm working right now on v9 release - it will contain everything including all pending and extension types.
I think that it will be released late today or tomorrow and as soon as it's released I will close this issue. 😊

@mallardduck
Copy link
Contributor

Nice! In my testing it was a lot more similar to v8 but had a handful of changes it needed. Mainly it seems that they're adding some internationalization of some sort. For instance I found some strings are now wrapped in an object identifying their locale.

@Gummibeer
Copy link
Collaborator

https://github.com/spatie/schema-org/releases/tag/3.0.0

@agemmell
Copy link
Author

@mallardduck I'm afraid I cannot test this as I am no longer involved in this space. However, I appreciate the hard work OSS contributors like yourself put in to make improvements like this! So thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants