-
Notifications
You must be signed in to change notification settings - Fork 1
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
Code generation #32
Code generation #32
Conversation
|
||
/// Returns true if a string contains special characters or starts with a number. | ||
let checkForSpecialCharacters str = | ||
let spChs = System.Text.RegularExpressions.Regex("(^\d|[^a-zA-Z0-9_])") |
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.
seems like there is a possible escape sequence here, better prefix the string with an '@'
open OBO.NET | ||
open OBO.NET.CodeGeneration | ||
open FSharpAux | ||
open ARCTokenization.StructuralOntology |
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.
i would not use these ontologies but static files in this repo as references for tests
testList "toSourceCode" [ | ||
testCase "returns correct source code" <| fun _ -> | ||
let expected = | ||
$"namespace ARCTokenization.StructuralOntology{NewLine}{NewLine} open ControlledVocabulary{NewLine}{NewLine} module Investigation ={NewLine}{NewLine} let Investigation_Metadata = CvTerm.create(\"INVMSO:00000001\", \"Investigation Metadata\", \"INVMSO\"){NewLine}{NewLine} let ONTOLOGY_SOURCE_REFERENCE = CvTerm.create(\"INVMSO:00000002\", \"ONTOLOGY SOURCE REFERENCE\", \"INVMSO\"){NewLine}{NewLine} let Term_Source_Name = CvTerm.create(\"INVMSO:00000003\", \"Term Source Name\", \"INVMSO\")" |
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.
here, i would also just parse a fully correct fsharp source file as reference, and check wether the full output is correct.
@kMutagene I added the requested changes. Ready for re-review. 😃 |
@@ -0,0 +1,11 @@ | |||
namespace ARCTokenization.StructuralOntology |
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.
Why are you not testing the whole ontology? this is just 3 terms, while your reference obo file contains a lot more.
@kMutagene I updated according to your requested changes. Ready for re-review. 😊 |
testCase "returns correct source code" <| fun _ -> | ||
let expected = String.replace "\r" "" refSF | ||
let actual = | ||
CodeGeneration.toSourceCode "Investigation" refObo |
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.
There is a ReplaceLineEndings
method on strings, this seems like a convoluted way of doing just that.
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.
Oh lol, didn't know about that! 👍🏻😄
@kMutagene Re-review-ready. 👍🏻 |
testList "toSourceCode" [ | ||
testCase "returns correct source code" <| fun _ -> | ||
let expected = refSF.ReplaceLineEndings() | ||
let actual = (CodeGeneration.toSourceCode "Investigation" refObo).ReplaceLineEndings() |
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.
nitpick, but i think the top-level module should be called INVMSO, just as the ontology itself. Once #33 is implemented, this can even be extracted from the header tags i guess. However, no need to change this
🥳 |
@omaus do not forget to release the package 🚀 |
This PR