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
a3a79772
Commit
a3a79772
authored
14 years ago
by
ilor
Browse files
Options
Downloads
Patches
Plain Diff
add -V option to wcclparser to dump variable status after query processing
parent
e34bd768
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libwccl/values/value.h
+6
-1
6 additions, 1 deletion
libwccl/values/value.h
wcclparser/main.cpp
+19
-4
19 additions, 4 deletions
wcclparser/main.cpp
with
25 additions
and
5 deletions
libwccl/values/value.h
+
6
−
1
View file @
a3a79772
...
@@ -6,7 +6,10 @@
...
@@ -6,7 +6,10 @@
#define WCCL_VALUE_PREAMBLE \
#define WCCL_VALUE_PREAMBLE \
static const char* type_name; \
static const char* type_name; \
const char* get_type_name() const { return type_name; } \
const char* get_type_name() const { return type_name; } \
static std::string var_repr(const std::string &var_name);
static std::string var_repr(const std::string &var_name); \
std::string make_var_repr(const std::string &var_name) const { \
return var_repr(var_name); \
}
namespace
Wccl
{
namespace
Wccl
{
...
@@ -35,6 +38,8 @@ public:
...
@@ -35,6 +38,8 @@ public:
virtual
~
Value
()
{}
virtual
~
Value
()
{}
virtual
std
::
string
make_var_repr
(
const
std
::
string
&
)
const
=
0
;
/**
/**
* String representation function, in general, a tagset is required,
* String representation function, in general, a tagset is required,
* but some classes might not need that, so by default just forward
* but some classes might not need that, so by default just forward
...
...
This diff is collapsed.
Click to expand it.
wcclparser/main.cpp
+
19
−
4
View file @
a3a79772
...
@@ -90,8 +90,17 @@ void libedit_read_loop(boost::function<bool (const std::string&)>& line_cb)
...
@@ -90,8 +90,17 @@ void libedit_read_loop(boost::function<bool (const std::string&)>& line_cb)
}
}
#endif
#endif
void
dumpvariables
(
const
Wccl
::
Variables
&
vars
,
const
Corpus2
::
Tagset
&
tagset
)
{
typedef
std
::
pair
<
std
::
string
,
boost
::
shared_ptr
<
Wccl
::
Value
>
>
v_t
;
foreach
(
const
v_t
&
v
,
vars
.
get_all
<
Wccl
::
Value
>
())
{
std
::
cerr
<<
v
.
second
->
make_var_repr
(
v
.
first
)
<<
"="
<<
v
.
second
->
to_string
(
tagset
)
<<
"
\n
"
;
}
}
bool
process_line
(
const
std
::
string
&
line
,
Wccl
::
Parser
&
parser
,
bool
process_line
(
const
std
::
string
&
line
,
Wccl
::
Parser
&
parser
,
Wccl
::
SentenceContext
&
sc
,
bool
all_positions
)
Wccl
::
SentenceContext
&
sc
,
bool
all_positions
,
bool
dump_variables
)
{
{
if
(
line
.
empty
()
||
line
==
"exit"
||
line
==
"quit"
)
{
if
(
line
.
empty
()
||
line
==
"exit"
||
line
==
"quit"
)
{
return
true
;
return
true
;
...
@@ -123,6 +132,9 @@ bool process_line(const std::string& line, Wccl::Parser& parser,
...
@@ -123,6 +132,9 @@ bool process_line(const std::string& line, Wccl::Parser& parser,
<<
"Parsed expression: "
<<
"Parsed expression: "
<<
retVal
->
to_string
(
parser
.
tagset
())
<<
retVal
->
to_string
(
parser
.
tagset
())
<<
std
::
endl
;
<<
std
::
endl
;
if
(
dump_variables
)
{
dumpvariables
(
*
cx
.
variables
(),
parser
.
tagset
());
}
}
else
{
}
else
{
std
::
cerr
<<
"Problem while parsing -- "
std
::
cerr
<<
"Problem while parsing -- "
<<
"retVal is NULL!"
<<
std
::
endl
;
<<
"retVal is NULL!"
<<
std
::
endl
;
...
@@ -156,6 +168,7 @@ int main(int argc, char** argv)
...
@@ -156,6 +168,7 @@ int main(int argc, char** argv)
std
::
string
query_load
=
""
;
std
::
string
query_load
=
""
;
std
::
string
position
=
"0"
;
std
::
string
position
=
"0"
;
bool
quiet
=
false
;
bool
quiet
=
false
;
bool
dump_variables
=
false
;
using
boost
::
program_options
::
value
;
using
boost
::
program_options
::
value
;
boost
::
program_options
::
options_description
desc
(
"Allowed options"
);
boost
::
program_options
::
options_description
desc
(
"Allowed options"
);
...
@@ -172,6 +185,8 @@ int main(int argc, char** argv)
...
@@ -172,6 +185,8 @@ int main(int argc, char** argv)
"Query to run (disables interactive mode)
\n
"
)
"Query to run (disables interactive mode)
\n
"
)
(
"quiet,q"
,
value
(
&
quiet
)
->
zero_tokens
(),
(
"quiet,q"
,
value
(
&
quiet
)
->
zero_tokens
(),
"Suppress messages
\n
"
)
"Suppress messages
\n
"
)
(
"variables,V"
,
value
(
&
dump_variables
)
->
zero_tokens
(),
"Dump variables after running each query
\n
"
)
(
"help,h"
,
"Show help"
)
(
"help,h"
,
"Show help"
)
;
;
boost
::
program_options
::
variables_map
vm
;
boost
::
program_options
::
variables_map
vm
;
...
@@ -214,14 +229,14 @@ int main(int argc, char** argv)
...
@@ -214,14 +229,14 @@ int main(int argc, char** argv)
sc
.
set_position
(
pos
);
sc
.
set_position
(
pos
);
Wccl
::
Parser
parser
(
tagset
);
Wccl
::
Parser
parser
(
tagset
);
if
(
!
query
.
empty
())
{
if
(
!
query
.
empty
())
{
process_line
(
query
,
parser
,
sc
,
position
==
"all"
);
process_line
(
query
,
parser
,
sc
,
position
==
"all"
,
dump_variables
);
return
0
;
return
0
;
}
else
if
(
!
query_load
.
empty
())
{
}
else
if
(
!
query_load
.
empty
())
{
std
::
ifstream
qf
(
query_load
.
c_str
());
std
::
ifstream
qf
(
query_load
.
c_str
());
if
(
qf
.
good
())
{
if
(
qf
.
good
())
{
std
::
stringstream
ss
;
std
::
stringstream
ss
;
ss
<<
qf
.
rdbuf
();
ss
<<
qf
.
rdbuf
();
process_line
(
ss
.
str
(),
parser
,
sc
,
position
==
"all"
);
process_line
(
ss
.
str
(),
parser
,
sc
,
position
==
"all"
,
dump_variables
);
return
0
;
return
0
;
}
else
{
}
else
{
throw
Wccl
::
FileNotFound
(
sentence_load
,
""
,
"Query file"
);
throw
Wccl
::
FileNotFound
(
sentence_load
,
""
,
"Query file"
);
...
@@ -229,7 +244,7 @@ int main(int argc, char** argv)
...
@@ -229,7 +244,7 @@ int main(int argc, char** argv)
}
}
boost
::
function
<
bool
(
const
std
::
string
&
)
>
f
;
boost
::
function
<
bool
(
const
std
::
string
&
)
>
f
;
f
=
boost
::
bind
(
&
process_line
,
_1
,
boost
::
ref
(
parser
),
boost
::
ref
(
sc
),
f
=
boost
::
bind
(
&
process_line
,
_1
,
boost
::
ref
(
parser
),
boost
::
ref
(
sc
),
position
==
"all"
);
position
==
"all"
,
dump_variables
);
#ifdef HAVE_LIBEDIT
#ifdef HAVE_LIBEDIT
libedit_read_loop
(
f
);
libedit_read_loop
(
f
);
#else
#else
...
...
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