Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
898ad4df
Commit
898ad4df
authored
Nov 21, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made parse_trees_to_string() and parse_trees_to_string_tagged() a little more
user friendly.
parent
658a8182
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
17 deletions
+17
-17
find_max_parse_cky.h
dlib/optimization/find_max_parse_cky.h
+6
-6
find_max_parse_cky_abstract.h
dlib/optimization/find_max_parse_cky_abstract.h
+7
-7
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 tree[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 tag_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