-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#5] Refactoring to extract anything from ontology header
- Loading branch information
Showing
14 changed files
with
107 additions
and
69 deletions.
There are no files selected for viewing
This file contains 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 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,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains 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,3 +1 @@ | ||
rootProject.name = 'ontology-version-extractor' | ||
enableFeaturePreview("VERSION_CATALOGS") | ||
|
||
rootProject.name = 'ontology-version-extractor' |
This file contains 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,39 @@ | ||
package cz.sio2.obo; | ||
|
||
import cz.sio2.obo.extractor.OntologyHeaderExtractor; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import static cz.sio2.obo.Constants.NS_OBO_HTTP; | ||
|
||
public class Extractor { | ||
|
||
private String get(final Pattern pattern, final String singleLine) { | ||
Matcher m = pattern.matcher(singleLine); | ||
if (m.matches()) { | ||
return m.group(1); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
private String sanitize(final String input) { | ||
if (input == null) { | ||
return null; | ||
} | ||
return input.replace("&obo;", NS_OBO_HTTP); | ||
} | ||
|
||
public OntologyHeader extract(final String s, final OntologyHeaderExtractor extractor) { | ||
final OntologyHeader ontologyHeader = new OntologyHeader(); | ||
final String singleLine = s.replace('\n', ' '); | ||
if (!extractor.getFormatMatcher().matcher(singleLine).matches()) { | ||
return null; | ||
} | ||
ontologyHeader.setOwlOntologyIri(sanitize(get(extractor.getIriMatcher(), singleLine))); | ||
ontologyHeader.setOwlVersionIri(sanitize(get(extractor.getVersionIriMatcher(), singleLine))); | ||
ontologyHeader.setOwlVersionInfo(get(extractor.getVersionInfoMatcher(), singleLine)); | ||
return ontologyHeader; | ||
} | ||
} |
This file contains 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 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 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 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 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 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 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 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.