Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
898ad4df
Commit
898ad4df
authored
Nov 21, 2012
by
Davis King
Browse files
Made parse_trees_to_string() and parse_trees_to_string_tagged() a little more
user friendly.
parent
658a8182
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
17 deletions
+17
-17
dlib/optimization/find_max_parse_cky.h
dlib/optimization/find_max_parse_cky.h
+6
-6
dlib/optimization/find_max_parse_cky_abstract.h
dlib/optimization/find_max_parse_cky_abstract.h
+7
-7
dlib/test/parse.cpp
dlib/test/parse.cpp
+4
-4
No files found.
dlib/optimization/find_max_parse_cky.h
View file @
898ad4df
...
...
@@ -340,14 +340,14 @@ namespace dlib
std
::
string
parse_trees_to_string
(
const
std
::
vector
<
parse_tree_element
<
T
>
>&
tree
,
const
std
::
vector
<
U
>&
words
,
const
unsigned
long
root_idx
=
0
const
T
&
tag_to_skip
)
{
if
(
root_idx
>=
tree
.
size
())
if
(
tree
.
size
()
==
0
)
return
""
;
std
::
ostringstream
sout
;
impl
::
print_parse_tree_helper
<
false
,
true
>
(
tree
,
words
,
root_idx
,
tree
[
root_idx
].
tag
,
sout
);
impl
::
print_parse_tree_helper
<
false
,
true
>
(
tree
,
words
,
0
,
tag_to_skip
,
sout
);
return
sout
.
str
();
}
...
...
@@ -357,14 +357,14 @@ namespace dlib
std
::
string
parse_trees_to_string_tagged
(
const
std
::
vector
<
parse_tree_element
<
T
>
>&
tree
,
const
std
::
vector
<
U
>&
words
,
const
unsigned
long
root_idx
=
0
const
T
&
tag_to_skip
)
{
if
(
root_idx
>=
tree
.
size
())
if
(
tree
.
size
()
==
0
)
return
""
;
std
::
ostringstream
sout
;
impl
::
print_parse_tree_helper
<
true
,
true
>
(
tree
,
words
,
root_idx
,
tree
[
root_idx
].
tag
,
sout
);
impl
::
print_parse_tree_helper
<
true
,
true
>
(
tree
,
words
,
0
,
tag_to_skip
,
sout
);
return
sout
.
str
();
}
...
...
dlib/optimization/find_max_parse_cky_abstract.h
View file @
898ad4df
...
...
@@ -298,7 +298,7 @@ namespace dlib
std
::
string
parse_trees_to_string
(
const
std
::
vector
<
parse_tree_element
<
T
>
>&
tree
,
const
std
::
vector
<
U
>&
words
,
const
unsigned
long
root_idx
=
0
const
T
&
tag_to_skip
);
/*!
requires
...
...
@@ -307,9 +307,9 @@ namespace dlib
ensures
- This function behaves just like parse_tree_to_string() except that it will
not print the brackets (i.e. []) for the top most parts of the tree which
have tags equal to t
ree[root_idx].tag
. It will however print all the words.
have tags equal to t
ag_to_skip
. It will however print all the words.
Therefore, this function only includes brackets on the subtrees which begin
with a tag other than t
ree[root_idx].tag
.
with a tag other than t
ag_to_skip
.
throws
- parse_tree_to_string_error
This exception is thrown if an invalid tree is detected. This might happen
...
...
@@ -326,7 +326,7 @@ namespace dlib
std
::
string
parse_trees_to_string_tagged
(
const
std
::
vector
<
parse_tree_element
<
T
>
>&
tree
,
const
std
::
vector
<
U
>&
words
,
const
unsigned
long
root_idx
=
0
const
T
&
tag_to_skip
);
/*!
requires
...
...
@@ -336,9 +336,9 @@ namespace dlib
ensures
- This function behaves just like parse_tree_to_string_tagged() except that it
will not print the brackets (i.e. []) for the top most parts of the tree
which have tags equal to t
ree[root_idx].tag
. It will however print all the
words.
Therefore, this function only includes brackets on the subtrees which
begin
with a tag other than t
ree[root_idx].tag
.
which have tags equal to t
ag_to_skip
. It will however print all the
words.
Therefore, this function only includes brackets on the subtrees which
begin
with a tag other than t
ag_to_skip
.
throws
- parse_tree_to_string_error
This exception is thrown if an invalid tree is detected. This might happen
...
...
dlib/test/parse.cpp
View file @
898ad4df
...
...
@@ -131,10 +131,10 @@ namespace
const
std
::
string
str3
=
"[[The flight] [includes [a meal]]] [[The flight] [includes [a meal]]]"
;
const
std
::
string
str4
=
"[5 [3 The flight] [4 includes [3 a meal]]] [5 [3 The flight] [4 includes [3 a meal]]]"
;
dlog
<<
LINFO
<<
parse_trees_to_string
(
parse_tree
,
words
);
DLIB_TEST
(
parse_trees_to_string
(
parse_tree
,
words
)
==
str3
);
dlog
<<
LINFO
<<
parse_trees_to_string_tagged
(
parse_tree
,
words
);
DLIB_TEST
(
parse_trees_to_string_tagged
(
parse_tree
,
words
)
==
str4
);
dlog
<<
LINFO
<<
parse_trees_to_string
(
parse_tree
,
words
,
G
);
DLIB_TEST
(
parse_trees_to_string
(
parse_tree
,
words
,
G
)
==
str3
);
dlog
<<
LINFO
<<
parse_trees_to_string_tagged
(
parse_tree
,
words
,
G
);
DLIB_TEST
(
parse_trees_to_string_tagged
(
parse_tree
,
words
,
G
)
==
str4
);
sequence
.
clear
();
find_max_parse_cky
(
sequence
,
user_defined_ruleset
<
true
>
,
parse_tree
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment