forked from CLARIAH/wp23-PICCL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entitylinker.nf
executable file
·72 lines (59 loc) · 2.31 KB
/
entitylinker.nf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env nextflow
/*
vim: syntax=groovy
-*- mode: groovy;-*-
*/
log.info "-----------------------------"
log.info "FoLiA Entity Linker Pipeline"
log.info "-----------------------------"
def env = System.getenv()
params.virtualenv = env.containsKey('VIRTUAL_ENV') ? env['VIRTUAL_ENV'] : ""
params.extension = "folia.xml"
params.outputdir = "dbnl_output"
params.entitylinking = "slh"; //Methods correspond to FoliaEntity.exe -m option
params.entitylinkerurioptions = ""; //Extra options for entity linker, will be passed as -u to FoLiAEntity"
if (params.containsKey('help') || !params.containsKey('inputdir')) {
log.info "Usage:"
log.info " entitylinker.nf [OPTIONS]"
log.info ""
log.info "Mandatory parameters:"
log.info " --inputdir DIRECTORY Input directory (FoLiA documents)"
log.info""
log.info "Optional parameters:"
log.info " --virtualenv PATH Path to Virtual Environment to load (usually path to LaMachine)"
log.info " --entitylinking METHODS Do entity linking according to specified methods (see -m option of FoliaEntity)"
log.info " --entitylinkerurioptions X Extra options to pass to entity linker -u"
log.info " --outputdir DIRECTORY Output directory (FoLiA documents)"
exit 2
}
foliadocuments = Channel.fromPath(params.inputdir+"/*." + params.extension)
process entitylinker {
publishDir params.outputdir, mode: 'copy', overwrite: true
input:
file document from foliadocuments
val virtualenv from params.virtualenv
val methods from params.entitylinking
val extraoptions from params.entitylinkerurioptions
output:
file "${document.simpleName}.linked.folia.xml" into entitylinker_output
script:
"""
set +u
if [ ! -z "${virtualenv}" ]; then
source ${virtualenv}/bin/activate
rootpath=${virtualenv}
else
rootpath=/opt
fi
set -u
mkdir out
if [ ! -z "${extraoptions}" ]; then
extraoptions="-u ${extraoptions}"
else
extraoptions=""
fi
\$rootpath/foliaentity/FoliaEntity.exe -w -a "foliaentity" -m ${methods} \$extraoptions -i "${document}" -o out/
zcat out/\$(basename "${document}").gz > "${document.simpleName}.linked.folia.xml"
"""
}
entitylinker_output.subscribe { println "Output document written to " + params.outputdir + "/" + it.name }