Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
corpus-services
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lange, Dr. Herbert
corpus-services
Commits
93fcfca1
Commit
93fcfca1
authored
May 16, 2022
by
Lange, Dr. Herbert
Browse files
Options
Downloads
Patches
Plain Diff
add function to create list of file urls from comma-separated string and update parameters
parent
2048e73d
No related branches found
No related tags found
1 merge request
!6
add feature to load criteria file from resource and place all criteria files...
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/uni_hamburg/corpora/validation/quest/FileListChecker.java
+37
-6
37 additions, 6 deletions
...uni_hamburg/corpora/validation/quest/FileListChecker.java
with
37 additions
and
6 deletions
src/main/java/de/uni_hamburg/corpora/validation/quest/FileListChecker.java
+
37
−
6
View file @
93fcfca1
...
...
@@ -48,17 +48,39 @@ public class FileListChecker extends Checker implements CorpusFunction {
return
uris
;
}
/**
* Splits a file list on commas and converts to URIs
* @param fileList the comma-separated list
* @return the set of URIs
* @throws MalformedURLException if the file name cannot be converted into a URL
* @throws URISyntaxException if the URL cannot be converted into a URI
*/
private
static
Set
<
URI
>
splitFileList
(
String
fileList
)
throws
MalformedURLException
,
URISyntaxException
{
Set
<
URI
>
uris
=
new
HashSet
<>();
for
(
String
fname
:
fileList
.
split
(
","
))
{
uris
.
add
(
new
URL
(
fname
).
toURI
().
normalize
());
}
return
uris
;
}
Set
<
URI
>
expectedFiles
=
new
HashSet
<>();
Set
<
URI
>
presentFiles
=
new
HashSet
<>();
public
FileListChecker
(
Properties
properties
)
throws
FileNotFoundException
,
MalformedURLException
,
URISyntaxException
{
super
(
false
,
properties
);
if
(
properties
.
containsKey
(
"expected-files-list"
))
{
expectedFiles
=
readFileList
(
properties
.
getProperty
(
"expected-files-list"
));
if
(
properties
.
containsKey
(
"expected-files-file"
))
{
expectedFiles
=
readFileList
(
properties
.
getProperty
(
"expected-files-file"
));
}
else
if
(
properties
.
containsKey
(
"expected-files-list"
))
{
expectedFiles
=
splitFileList
(
properties
.
getProperty
(
"expected-files-list"
));
}
if
(
properties
.
containsKey
(
"present-files-
list
"
))
{
presentFiles
=
readFileList
(
properties
.
getProperty
(
"present-files-
list
"
));
if
(
properties
.
containsKey
(
"present-files-
file
"
))
{
presentFiles
=
readFileList
(
properties
.
getProperty
(
"present-files-
file
"
));
}
else
if
(
properties
.
containsKey
(
"present-files-list"
))
{
expectedFiles
=
splitFileList
(
properties
.
getProperty
(
"present-files-list"
));
}
}
/**
...
...
@@ -95,6 +117,11 @@ public class FileListChecker extends Checker implements CorpusFunction {
@Override
public
Report
function
(
Corpus
c
,
Boolean
fix
)
throws
NoSuchAlgorithmException
,
ClassNotFoundException
,
FSMException
,
URISyntaxException
,
SAXException
,
IOException
,
ParserConfigurationException
,
JexmaraldaException
,
TransformerException
,
XPathExpressionException
,
JDOMException
{
if
(
props
.
containsKey
(
"expected-files-linked"
))
{
LinkedFileChecker
lfc
=
new
LinkedFileChecker
(
props
);
lfc
.
function
(
c
,
fix
);
expectedFiles
.
addAll
(
lfc
.
getFileList
());
}
Report
report
=
new
Report
();
// Try to read corpus directory instead
if
(
presentFiles
.
isEmpty
()){
...
...
@@ -131,9 +158,13 @@ public class FileListChecker extends Checker implements CorpusFunction {
@Override
public
Map
<
String
,
String
>
getParameters
()
{
Map
<
String
,
String
>
params
=
super
.
getParameters
();
params
.
put
(
"expected-files-
list
"
,
"A file containing names of all expected file names, one name per line"
);
params
.
put
(
"present-files-
list
"
,
"A file containing names of all file names of files present, one name per "
+
params
.
put
(
"expected-files-
file
"
,
"A file containing names of all expected file names, one name per line"
);
params
.
put
(
"present-files-
file
"
,
"A file containing names of all file names of files present, one name per "
+
"line"
);
params
.
put
(
"expected-files-list"
,
"A list containing names of all expected file names, separated by commas"
);
params
.
put
(
"present-files-list"
,
"A list containing names of all file names of files present, separated by "
+
"commas"
);
params
.
put
(
"expected-files-linked"
,
"Flag to use a files linked in corpus files as expected files"
);
return
params
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment