-
Notifications
You must be signed in to change notification settings - Fork 3
Updates to support conversion from metadata downloaded from KG #43
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4827fab
work in progress
ehennestad 694048d
Create instanceFromIRI.m
ehennestad 82f7964
Minor fixes
ehennestad 78359ef
Merge branch 'support-kg-to-openminds-conversion' of https://github.c…
ehennestad 9ec1a8a
Minor fixes
ehennestad c38f74f
Update code issues and tests badges
2db19df
Update ControlledTerm.m
ehennestad 29fa0ce
Merge branch 'support-kg-to-openminds-conversion' of https://github.c…
ehennestad 9c3ca2b
Create version.m
ehennestad 420e6ec
Create basicNeuroscienceDataset.mlx
ehennestad f01ca68
Update code issues and tests badges
79ed5f8
Update basicNeuroscienceDataset.mlx
ehennestad 2730951
Add md and html for the basic neuroscience dataset tutorial
ehennestad 9cbe0ee
Merge branch 'support-kg-to-openminds-conversion' into z/merged/suppo…
ehennestad b34428d
Update code issues and tests badges
698738e
Build triggered by update to pipeline (#44)
ehennestad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| function instance = fromIdentifier(atId) | ||
| [type, name] = openminds.utility.parseAtID(atId); | ||
| enumType = openminds.enum.Types(type); | ||
| instance = feval(enumType.ClassName, name); | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| function instance = fromTypeName( typeNameURI, identifier ) | ||
| arguments | ||
| typeNameURI | ||
| identifier = '' | ||
| end | ||
| enumType = openminds.enum.Types.fromAtType(typeNameURI); | ||
| instance = feval(enumType.ClassName, 'id', identifier); | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,35 @@ | ||
| function versionNum = getModelVersion(outputType) | ||
|
|
||
| % Todo: save version number in prefs/singleton? | ||
|
|
||
| arguments | ||
| % outputType - char or VersionNumber. char is default to keep | ||
| % backwards compatibility. Todo: Deprecate char option | ||
| outputType (1,1) string ... | ||
| {mustBeMember(outputType, ["char", "VersionNumber"])} = "char" | ||
| end | ||
|
|
||
| typeFolder = fullfile(openminds.internal.rootpath, 'types/'); | ||
| pathSplit = strsplit(path, pathsep); | ||
|
|
||
| matchedIdx = find(contains(pathSplit, typeFolder)); | ||
| persistent lastTic cachedVersionNumber | ||
| if isempty(lastTic); lastTic = uint64(0); end | ||
|
|
||
| if numel(matchedIdx) > 1 | ||
| warning('Multiple openMINDS model versions are present on the search path.'); | ||
| if toc(lastTic) > 1 | ||
| typeFolder = fullfile(openminds.internal.rootpath, 'types/'); | ||
| pathSplit = strsplit(path, pathsep); | ||
|
|
||
| matchedIdx = find(contains(pathSplit, typeFolder)); | ||
|
|
||
| if numel(matchedIdx) > 1 | ||
| warning('Multiple openMINDS model versions are present on the search path.'); | ||
| end | ||
|
|
||
| versionName = strrep(pathSplit{matchedIdx(1)}, typeFolder, ''); | ||
| cachedVersionNumber = openminds.internal.utility.VersionNumber(versionName); | ||
| cachedVersionNumber.Format = "vX.Y"; | ||
| lastTic = tic(); | ||
| end | ||
| versionNum = cachedVersionNumber; | ||
|
|
||
| versionNum = strrep(pathSplit{matchedIdx(1)}, typeFolder, ''); | ||
|
|
||
| if outputType == "VersionNumber" | ||
| versionNum = openminds.internal.utility.VersionNumber(versionNum); | ||
| versionNum.Format = "vX.Y"; | ||
| if outputType == "char" | ||
| versionNum = char(versionNum); | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| function instance = instanceFromIRI(iri) | ||
| [type, ~] = openminds.utility.parseAtID(iri); | ||
| typeEnum = openminds.enum.Types(type); | ||
| instance = feval(typeEnum.ClassName, iri); | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| function versionStr = version(version) | ||
| arguments | ||
| version (1,1) openminds.internal.utility.VersionNumber ... | ||
| {openminds.mustBeValidVersion(version)} = missing | ||
| end | ||
| if ismissing(version) | ||
| versionStr = string(openminds.getModelVersion()); | ||
| else | ||
| openminds.selectOpenMindsVersion(version) | ||
| versionStr = string(version); | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 7 additions & 4 deletions
11
code/internal/+openminds/+internal/+utility/+string/type2class.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,12 @@ | ||
| function className = type2class(openmindsType) | ||
|
|
||
| typeSplit = strsplit(openmindsType, '/'); | ||
|
|
||
| modelName = lower( typeSplit{end-1} ); | ||
| schemaName = typeSplit{end}; | ||
|
|
||
| className = sprintf('openminds.%s.%s', modelName, schemaName); | ||
|
|
||
| if startsWith(openmindsType, "https://openminds.om-i.org/types") | ||
| className = openminds.enum.Types(schemaName).ClassName; | ||
| else | ||
| modelName = lower( typeSplit{end-1} ); | ||
| className = sprintf('openminds.%s.%s', modelName, schemaName); | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| function isValid = isIRI(value) | ||
| % isIRI Validates an Internationalized Resource Identifier (IRI) | ||
| % isValid = isIRI(value) returns true if the input string 'value' | ||
| % has the basic structure of an IRI as defined in RFC 3987 section 2.1, | ||
| % and false otherwise. | ||
| % | ||
| % This function uses a regular expression to check for: | ||
| % - A scheme, which must start with a letter and can include letters, | ||
| % digits, plus (+), hyphen (-), and period (.) | ||
| % - An optional authority preceded by "//" (which should not include | ||
| % the delimiters ?, or #) | ||
| % - A path (which is any sequence of characters except '?' and '#') | ||
| % - An optional query (preceded by '?') | ||
| % - An optional fragment (preceded by '#') | ||
| % | ||
| % Note: This validator provides a basic check and does not fully enforce | ||
| % all details of RFC 3987 (for example, the precise allowed Unicode | ||
| % ranges in each component). | ||
| % | ||
| % Example: | ||
| % validIRI = 'http://例え.テスト/path?query#fragment'; | ||
| % isValid = openminds.utility.isIRI(validIRI); | ||
| % | ||
| % Author: ChatGPT o3-mini-high | ||
|
|
||
| % Regular expression pattern for a simplified IRI structure: | ||
| % - (?<scheme>[A-Za-z][A-Za-z0-9+\-.]*): --> scheme followed by ':' | ||
| % - (?://(?<authority>[^/?#]*))? --> optional "//" and authority | ||
| % - (?<path>[^?#]*) --> path (no '?' or '#') | ||
| % - (?:\?(?<query>[^#]*))? --> optional query starting with '?' | ||
| % - (?:#(?<fragment>.*))? --> optional fragment starting with '#' | ||
| % | ||
| % Note: Double backslashes (\\) are used in MATLAB string literals. | ||
| pattern = ['^(?<scheme>[A-Za-z][A-Za-z0-9+\\-.]*):', ... | ||
| '(?://(?<authority>[^/?#]*))?', ... | ||
| '(?<path>[^?#]*)', ... | ||
| '(?:\\?(?<query>[^#]*))?', ... | ||
| '(?:#(?<fragment>.*))?$', ... | ||
| ]; | ||
|
|
||
| % Use regexp with the 'names' option to capture components | ||
| tokens = regexp(value, pattern, 'names'); | ||
|
|
||
| % The IRI is considered valid if the regex returns non-empty tokens. | ||
| isValid = ~isempty(tokens); | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / Code Analyzer
Value assigned to variable might be unused. Warning