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

API to Create an English Vocabulary File for a Model #644

Closed
Tracked by #21
dselman opened this issue May 10, 2023 · 22 comments
Closed
Tracked by #21

API to Create an English Vocabulary File for a Model #644

dselman opened this issue May 10, 2023 · 22 comments
Assignees
Milestone

Comments

@dselman
Copy link
Contributor

dselman commented May 10, 2023

Feature Request 🛍️

To bootstrap the creation of a vocabulary for a model it would be useful to add an API that uses the default English missing term generator to bootstrap a vocabulary file for all concepts and properties in a model.

Use Case

Users that would like to start using a vocabulary file need an easy path to get started.

Possible Solution

Context

Detailed Description

@sanketshevkar
Copy link
Member

sanketshevkar commented May 12, 2023

Hi @dselman,
Just wanted to clarify if this is what the requirement is?
For the following CTO file,

namespace test@1.0.0

abstract concept Person
{
    o String firstName
    o String lastName
}

concept Driver extends Person {
  o String favoriteColor
}

concept Car identified by vin
{
    o String vin
    o Person owner
}

If we do concerto vocab --model test@1.0.0.cto should hit the new API in concerto-vocabulary to generate a bootstrap teamplate that uses englishMissingTermGenerator?
Example output YAML file:

locale: en
namespace: test@1.0.0
declarations:
  - Person: # Add your definition
    properties:
      - lastName: lastName of the Person
      - firstName: firstName of the Person
  - Driver: # Add your defination
    properties:
      - favoriteColor: favoriteColor of the Driver
  - Car: # Add your definition
    properties:
     - vin: vin of the Car
     - owner: owner of the Car

@dselman
Copy link
Contributor Author

dselman commented May 12, 2023

Close! What I was thinking was a new code generator, so we could run it using:

concerto compile --model test@1.0.0.cto --target vocabulary

That saves creating a new CLI command etc.

The visitor for the code generator would create a voc file for each model file in the model manager.

The English Missing Term Generator will allow us to populate those # Add your definition with a machine generated term that people can then customise.

Would you like to work on this one?

@sanketshevkar
Copy link
Member

Yes sure.

The English Missing Term Generator will allow us to populate those # Add your definition with a machine generated term that people can then customise.

Just saw the method and edited the YAML file.

@dselman
Copy link
Contributor Author

dselman commented May 12, 2023

Great, it's all yours!

@dselman
Copy link
Contributor Author

dselman commented May 12, 2023

BTW - the English Missing Term Generator can also be applied to concept names (property name is optional).

@dselman
Copy link
Contributor Author

dselman commented May 12, 2023

@sanketshevkar
Copy link
Member

Yes, sure will keep in mind. Thank you Dan. :)

@dselman
Copy link
Contributor Author

dselman commented May 12, 2023

This may be helpful: https://concerto.accordproject.org/docs/reference/codegen/codegen-create-new
(note that the links in this page are incorrect, as the codgen package was recently moved) cc @jonathan-casey

@sanketshevkar
Copy link
Member

Hi @dselman,

I was testing the vocab file generated by the code generator I've written. While testing it on this repl https://replit.com/join/xeqmqanuuo-sanketshevkar
I'm not able able to add a command set to the model manager when any scalar value is present in the .cto file. In other cases it's working fine.
I am getting the following error.

TypeError: decl.getProperties is not a function
    at /home/runner/AccordProjectConcerto-Vocabulary/node_modules/@accordproject/concerto-vocabulary/lib/vocabularymanager.js:254:22
    at Array.forEach (<anonymous>)
    at /home/runner/AccordProjectConcerto-Vocabulary/node_modules/@accordproject/concerto-vocabulary/lib/vocabularymanager.js:230:40
    at Array.forEach (<anonymous>)
    at VocabularyManager.generateDecoratorCommands (/home/runner/AccordProjectConcerto-Vocabulary/node_modules/@accordproject/concerto-vocabulary/lib/vocabularymanager.js:229:38)
    at Object.<anonymous> (/home/runner/AccordProjectConcerto-Vocabulary/index.js:126:33)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
Hint: hit control+c anytime to enter REPL.

@sanketshevkar
Copy link
Member

Another question, how should I output vocab for Scalar type declarations?

@dselman
Copy link
Contributor Author

dselman commented May 15, 2023

We must have broken vocabulary management when we added scalars. Do you want me to fix that?

We can handle scalars in the vocabulary similar to concepts, just without properties.

@sanketshevkar
Copy link
Member

If that's how the output should be. I can try to patch it up in the same PR?
I don't think it'll be a blocker for this particular PR. I'll investigate and let you know. If it feels like a small patch I can do it myself.

@dselman
Copy link
Contributor Author

dselman commented May 15, 2023

Ok, thanks - I will leave it to you.

@dselman
Copy link
Contributor Author

dselman commented May 23, 2023

Any progress on this or an ETA? I have a need for this.

@sanketshevkar
Copy link
Member

sanketshevkar commented May 23, 2023

  1. Need handle case for relation and scalars.
  2. Write test cases.
    By when do you require this? Should be a few hours work at max. Sorry, kept it on hold, because I have an interview scheduled this week.
    If it's urgent for you I can prioritize it from my side.

@dselman
Copy link
Contributor Author

dselman commented May 23, 2023

If you create a draft PR with what you have then I can work on it as well.

@sanketshevkar
Copy link
Member

  1. Created a new issue in concerto-codegen
  2. Relationship and Scalar are now handled
  3. Need to write tests for field: (fields, enum values, relationships)

I'm trying to raise a PR on concerto-codegen but getting an error, regarding permission

remote: Permission to accordproject/concerto-codegen.git denied to sanketshevkar.
fatal: unable to access 'https://github.com/accordproject/concerto-codegen.git/': The requested URL returned error: 403

@dselman
Copy link
Contributor Author

dselman commented May 23, 2023

Strange. I see other PRs have been created: https://github.com/accordproject/concerto-codegen/branches
You need to fork the repo and then create your PR to merge from your fork back to the main branch.

@sanketshevkar
Copy link
Member

Ahh 😅
Hadn't forked the repo.
Here's the PR to be reviewed accordproject/concerto-codegen#22
Thanks @dselman

@sanketshevkar
Copy link
Member

I have completed the tests, can you review the PR? @dselman

@sanketshevkar
Copy link
Member

Documentation for vocabulary code generation
accordproject/concerto-docs#16

@dselman
Copy link
Contributor Author

dselman commented Aug 11, 2023

This has been implemented.

@dselman dselman closed this as completed Aug 11, 2023
@mttrbrts mttrbrts added this to the v3.x milestone Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

3 participants