Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
corpus2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Analysers
corpus2
Commits
98676555
Commit
98676555
authored
Oct 21, 2010
by
ilor
Browse files
Options
Downloads
Patches
Plain Diff
modernize tagset-tool, add internals output mode
parent
2724bad2
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tagset-tool/main.cpp
+31
-14
31 additions, 14 deletions
tagset-tool/main.cpp
with
31 additions
and
14 deletions
tagset-tool/main.cpp
+
31
−
14
View file @
98676555
...
...
@@ -90,32 +90,39 @@ void tagset_info(const Corpus2::Tagset& tagset)
std
::
cerr
<<
"
\n
"
;
}
void
tagset_query_cb
(
const
Corpus2
::
Tagset
&
tagset
,
const
std
::
string
&
s
)
void
tagset_query_cb
(
const
Corpus2
::
Tagset
&
tagset
,
const
std
::
string
&
s
,
bool
internals
)
{
Corpus2
::
idx_t
pos
=
tagset
.
pos_dictionary
().
get_id
(
s
);
Corpus2
::
idx_t
atr
=
tagset
.
attribute_dictionary
().
get_id
(
s
);
Corpus2
::
mask_t
val
=
tagset
.
get_value_mask
(
s
);
if
(
tagset
.
pos_dictionary
().
is_id_valid
(
pos
))
{
if
(
pos
>=
0
)
{
if
(
internals
)
{
std
::
cout
<<
tagset
.
get_pos_mask
(
pos
)
<<
" ("
<<
(
int
)
pos
<<
")
\n
"
;
}
std
::
cout
<<
s
<<
" -> POS ->"
;
foreach
(
Corpus2
::
idx_t
a
,
tagset
.
get_pos_attributes
(
pos
))
{
std
::
string
astr
=
tagset
.
attribute_dictionary
().
get_string
(
a
);
if
(
tagset
.
get_
pos_require
d
_attribute
s
(
pos
)[
a
]
)
{
if
(
tagset
.
pos_require
s
_attribute
(
pos
,
a
)
)
{
std
::
cout
<<
" "
<<
astr
;
}
else
{
std
::
cout
<<
" ["
<<
astr
<<
"]"
;
}
}
std
::
cout
<<
"
\n
"
;
}
else
if
(
tagset
.
attribute_dictionary
().
is_id_valid
(
atr
))
{
}
else
if
(
atr
>
0
)
{
if
(
internals
)
{
std
::
cout
<<
tagset
.
get_attribute_mask
(
atr
)
<<
" ("
<<
(
int
)
atr
<<
")
\n
"
;
}
std
::
cout
<<
s
<<
" -> attribute ->"
;
foreach
(
Corpus2
::
mask_t
v
,
tagset
.
get_attribute_values
(
atr
))
{
std
::
cout
<<
" "
<<
tagset
.
get_value_name
(
v
);
}
std
::
cout
<<
"
\n
In POSes:"
;
for
(
Corpus2
::
idx_t
p
=
0
;
p
<
tagset
.
pos_
dictionary
().
size
();
++
p
)
{
if
(
tagset
.
get_po
s_attribute
s_flag
(
p
)[
atr
]
)
{
for
(
Corpus2
::
idx_t
p
=
0
;
p
<
tagset
.
pos_
count
();
++
p
)
{
if
(
tagset
.
pos_ha
s_attribute
(
p
,
atr
)
)
{
std
::
cout
<<
" "
<<
tagset
.
pos_dictionary
().
get_string
(
p
);
if
(
!
tagset
.
get_
pos_require
d
_attribute
s
(
p
)[
atr
]
)
{
if
(
!
tagset
.
pos_require
s
_attribute
(
p
,
atr
)
)
{
std
::
cout
<<
"?"
;
}
}
...
...
@@ -123,6 +130,10 @@ void tagset_query_cb(const Corpus2::Tagset& tagset, const std::string& s)
std
::
cout
<<
"
\n
"
;
}
else
if
(
val
.
any
())
{
Corpus2
::
idx_t
a
=
tagset
.
get_value_attribute_index
(
val
);
if
(
internals
)
{
std
::
cout
<<
val
<<
" ("
<<
PwrNlp
::
lowest_bit
(
val
)
<<
")
\n
"
;
std
::
cout
<<
tagset
.
get_attribute_mask
(
a
)
<<
" ("
<<
(
int
)
a
<<
")
\n
"
;
}
std
::
cout
<<
s
<<
" -> value -> attribute "
;
std
::
cout
<<
tagset
.
attribute_dictionary
().
get_string
(
a
);
std
::
cout
<<
" ."
;
...
...
@@ -130,10 +141,10 @@ void tagset_query_cb(const Corpus2::Tagset& tagset, const std::string& s)
std
::
cout
<<
" "
<<
tagset
.
get_value_name
(
v
);
}
std
::
cout
<<
"
\n
In POSes:"
;
for
(
Corpus2
::
idx_t
p
=
0
;
p
<
tagset
.
pos_
dictionary
().
size
();
++
p
)
{
if
(
tagset
.
get_po
s_attribute
s_flag
(
p
)[
a
]
)
{
for
(
Corpus2
::
idx_t
p
=
0
;
p
<
tagset
.
pos_
count
();
++
p
)
{
if
(
tagset
.
pos_ha
s_attribute
(
p
,
a
)
)
{
std
::
cout
<<
" "
<<
tagset
.
pos_dictionary
().
get_string
(
p
);
if
(
!
tagset
.
get_
pos_require
d
_attribute
s
(
p
)[
a
]
)
{
if
(
!
tagset
.
pos_require
s
_attribute
(
p
,
a
)
)
{
std
::
cout
<<
"?"
;
}
}
...
...
@@ -144,7 +155,8 @@ void tagset_query_cb(const Corpus2::Tagset& tagset, const std::string& s)
}
}
void
tag_parse_cb
(
const
Corpus2
::
Tagset
&
tagset
,
bool
validate
,
bool
sort
,
const
std
::
string
&
s
)
void
tag_parse_cb
(
const
Corpus2
::
Tagset
&
tagset
,
bool
validate
,
bool
sort
,
const
std
::
string
&
s
,
bool
internals
)
{
try
{
Corpus2
::
Token
t
;
...
...
@@ -156,6 +168,9 @@ void tag_parse_cb(const Corpus2::Tagset& tagset, bool validate, bool sort, const
if
(
validate
)
{
tagset
.
validate_tag
(
lex
.
tag
(),
false
,
&
ss
);
}
if
(
internals
)
{
ss
<<
"
\n
"
<<
lex
.
tag
().
raw_dump
()
<<
""
;
}
out
.
push_back
(
ss
.
str
());
}
if
(
sort
)
{
...
...
@@ -171,7 +186,7 @@ void tag_parse_cb(const Corpus2::Tagset& tagset, bool validate, bool sort, const
int
main
(
int
argc
,
char
**
argv
)
{
std
::
string
tagset_load
,
tagset_save
;
bool
quiet
=
false
;
bool
quiet
=
false
,
internals
=
false
;
bool
parse
=
false
,
validate
=
false
,
sort
=
false
;
using
boost
::
program_options
::
value
;
...
...
@@ -185,6 +200,8 @@ int main(int argc, char** argv)
"Suppress startup info
\n
"
)
(
"parse,p"
,
value
(
&
parse
)
->
zero_tokens
(),
"Parse complex tag strings mode"
)
(
"internals,i"
,
value
(
&
internals
)
->
zero_tokens
(),
"Output internal representations"
)
(
"validate,v"
,
value
(
&
validate
)
->
zero_tokens
(),
"Validate parsed tags"
)
(
"sort,s"
,
value
(
&
sort
)
->
zero_tokens
(),
...
...
@@ -236,13 +253,13 @@ int main(int argc, char** argv)
std
::
cerr
<<
"(Tag parse mode)
\n
"
;
}
_prompt
=
"tag-parse> "
;
f
=
boost
::
bind
(
&
tag_parse_cb
,
boost
::
ref
(
tagset
),
validate
,
sort
,
_1
);
f
=
boost
::
bind
(
&
tag_parse_cb
,
boost
::
ref
(
tagset
),
validate
,
sort
,
_1
,
internals
);
}
else
{
if
(
!
quiet
)
{
std
::
cerr
<<
"(Tagset query mode)
\n
"
;
}
_prompt
=
"tagset-query> "
;
f
=
boost
::
bind
(
&
tagset_query_cb
,
boost
::
ref
(
tagset
),
_1
);
f
=
boost
::
bind
(
&
tagset_query_cb
,
boost
::
ref
(
tagset
),
_1
,
internals
);
}
#ifdef HAVE_LIBEDIT
libedit_read_loop
(
f
);
...
...
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