Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WCCL
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Analysers
WCCL
Commits
011ca5d1
Commit
011ca5d1
authored
13 years ago
by
ilor
Browse files
Options
Downloads
Patches
Plain Diff
add raw operator string support in wcclrun
parent
5014ffab
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wcclrun/main.cpp
+42
-13
42 additions, 13 deletions
wcclrun/main.cpp
with
42 additions
and
13 deletions
wcclrun/main.cpp
+
42
−
13
View file @
011ca5d1
...
@@ -48,6 +48,9 @@ public:
...
@@ -48,6 +48,9 @@ public:
}
}
bool
load_more_operators
(
const
std
::
string
&
filename
);
bool
load_more_operators
(
const
std
::
string
&
filename
);
bool
load_operator_string
(
const
std
::
string
&
op_string
);
const
std
::
vector
<
boost
::
shared_ptr
<
Wccl
::
FunctionalOperator
>
>&
operators
()
const
{
const
std
::
vector
<
boost
::
shared_ptr
<
Wccl
::
FunctionalOperator
>
>&
operators
()
const
{
return
ops_
;
return
ops_
;
}
}
...
@@ -102,6 +105,27 @@ bool Runner::load_more_operators(const std::string& filename)
...
@@ -102,6 +105,27 @@ bool Runner::load_more_operators(const std::string& filename)
return
false
;
return
false
;
}
}
bool
Runner
::
load_operator_string
(
const
std
::
string
&
op_string
)
{
boost
::
shared_ptr
<
Wccl
::
FunctionalOperator
>
retOp
;
try
{
retOp
=
parser_
.
parseAnyOperator
(
op_string
);
if
(
retOp
)
{
op_names_
.
push_back
(
op_string
);
ops_
.
push_back
(
retOp
);
return
true
;
}
else
{
std
::
cerr
<<
"Problem while parsing -- "
<<
"parser returned NULL!"
<<
std
::
endl
;
}
}
catch
(
PwrNlp
::
PwrNlpError
&
e
)
{
std
::
cerr
<<
e
.
scope
()
<<
" error: "
<<
e
.
info
()
<<
std
::
endl
;
}
catch
(
antlr
::
ANTLRException
&
e
)
{
std
::
cerr
<<
"Antlr error "
<<
e
.
getMessage
()
<<
std
::
endl
;
}
return
false
;
}
void
Runner
::
do_sentence
(
const
boost
::
shared_ptr
<
Corpus2
::
Sentence
>&
sentence
)
void
Runner
::
do_sentence
(
const
boost
::
shared_ptr
<
Corpus2
::
Sentence
>&
sentence
)
{
{
Wccl
::
SentenceContext
sc
(
sentence
);
Wccl
::
SentenceContext
sc
(
sentence
);
...
@@ -197,7 +221,7 @@ int main(int argc, char** argv)
...
@@ -197,7 +221,7 @@ int main(int argc, char** argv)
{
{
std
::
string
tagset_load
=
"kipi"
;
std
::
string
tagset_load
=
"kipi"
;
bool
first
=
false
;
bool
first
=
false
;
std
::
vector
<
std
::
string
>
corpora_files
,
ccl_
files
,
file
s
;
std
::
vector
<
std
::
string
>
corpora_files
,
files
,
operator_string
s
;
bool
corpus_stdin
=
false
;
bool
corpus_stdin
=
false
;
using
boost
::
program_options
::
value
;
using
boost
::
program_options
::
value
;
...
@@ -207,8 +231,8 @@ int main(int argc, char** argv)
...
@@ -207,8 +231,8 @@ int main(int argc, char** argv)
"Tagset to use"
)
"Tagset to use"
)
(
"corpus,c"
,
value
(
&
corpora_files
),
(
"corpus,c"
,
value
(
&
corpora_files
),
"Corpus file to load (XCES)"
)
"Corpus file to load (XCES)"
)
(
"ccl-
file
,C"
,
value
(
&
ccl_file
s
),
(
"ccl-
operator
,C"
,
value
(
&
operator_string
s
),
"CCL
query file
"
)
"CCL
operator file or string
"
)
(
"files,f"
,
value
(
&
files
),
(
"files,f"
,
value
(
&
files
),
"Files to load, looking at the extension to determine type"
)
"Files to load, looking at the extension to determine type"
)
(
"corpus-from-stdin,I"
,
value
(
&
corpus_stdin
)
->
zero_tokens
(),
(
"corpus-from-stdin,I"
,
value
(
&
corpus_stdin
)
->
zero_tokens
(),
...
@@ -248,7 +272,8 @@ int main(int argc, char** argv)
...
@@ -248,7 +272,8 @@ int main(int argc, char** argv)
if
(
vm
.
count
(
"help"
))
{
if
(
vm
.
count
(
"help"
))
{
std
::
cerr
<<
"Usage "
<<
argv
[
0
]
<<
" [OPTIONS] FILES
\n
"
std
::
cerr
<<
"Usage "
<<
argv
[
0
]
<<
" [OPTIONS] FILES
\n
"
<<
"Files ending with .xml are treated as corpora, otherwise
\n
"
<<
"Files ending with .xml are treated as corpora, otherwise
\n
"
<<
"as CCL files. Use - to read corpus from stdin (as with -I)
\n
"
;
<<
"as CCL files. Use - to read corpus from stdin (as with -I)
\n
"
<<
"Files not ending with an extension are treated as raw operator strings
\n
"
;
std
::
cout
<<
desc
<<
"
\n
"
;
std
::
cout
<<
desc
<<
"
\n
"
;
return
1
;
return
1
;
}
}
...
@@ -259,23 +284,27 @@ int main(int argc, char** argv)
...
@@ -259,23 +284,27 @@ int main(int argc, char** argv)
}
else
if
(
boost
::
algorithm
::
ends_with
(
f
,
".xml"
))
{
}
else
if
(
boost
::
algorithm
::
ends_with
(
f
,
".xml"
))
{
corpora_files
.
push_back
(
f
);
corpora_files
.
push_back
(
f
);
}
else
{
}
else
{
ccl_file
s
.
push_back
(
f
);
operator_string
s
.
push_back
(
f
);
}
}
}
}
if
(
corpora_files
.
empty
()
||
(
ccl_file
s
.
empty
()
&&
!
output_orths
))
{
if
(
corpora_files
.
empty
()
||
(
operator_string
s
.
empty
()
&&
!
output_orths
))
{
std
::
cerr
<<
"Nothing to do, try "
<<
argv
[
0
]
<<
" -h
\n
"
;
std
::
cerr
<<
"Nothing to do, try "
<<
argv
[
0
]
<<
" -h
\n
"
;
return
2
;
return
2
;
}
}
try
{
try
{
const
Corpus2
::
Tagset
&
tagset
=
Corpus2
::
get_named_tagset
(
tagset_load
);
const
Corpus2
::
Tagset
&
tagset
=
Corpus2
::
get_named_tagset
(
tagset_load
);
Runner
runner
(
tagset
);
Runner
runner
(
tagset
);
foreach
(
const
std
::
string
&
f
,
ccl_files
)
{
foreach
(
const
std
::
string
&
f
,
operator_strings
)
{
size_t
sz
=
runner
.
operators
().
size
();
if
(
boost
::
algorithm
::
ends_with
(
f
,
".ccl"
))
{
if
(
!
runner
.
load_more_operators
(
f
))
{
size_t
sz
=
runner
.
operators
().
size
();
std
::
cerr
<<
"Warning: error while parsing "
<<
f
<<
"
\n
"
;
if
(
!
runner
.
load_more_operators
(
f
))
{
}
std
::
cerr
<<
"Warning: error while parsing "
<<
f
<<
"
\n
"
;
if
(
runner
.
operators
().
size
()
==
sz
)
{
}
std
::
cerr
<<
"Warning: no operators loaded from "
<<
f
<<
"
\n
"
;
if
(
runner
.
operators
().
size
()
==
sz
)
{
std
::
cerr
<<
"Warning: no operators loaded from "
<<
f
<<
"
\n
"
;
}
}
else
{
runner
.
load_operator_string
(
f
);
}
}
}
}
if
(
!
runner
.
operators
().
empty
())
{
if
(
!
runner
.
operators
().
empty
())
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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