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
249b0dd1
Commit
249b0dd1
authored
Nov 12, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added serialization support to constituent and parse_tree_element.
parent
47d118c1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
0 deletions
+98
-0
find_max_parse_cky.h
dlib/optimization/find_max_parse_cky.h
+58
-0
find_max_parse_cky_abstract.h
dlib/optimization/find_max_parse_cky_abstract.h
+40
-0
No files found.
dlib/optimization/find_max_parse_cky.h
View file @
249b0dd1
...
...
@@ -7,6 +7,7 @@
#include <vector>
#include <string>
#include <sstream>
#include "../serialize.h"
#include "../array2d.h"
namespace
dlib
...
...
@@ -22,8 +23,38 @@ namespace dlib
T
right_tag
;
};
template
<
typename
T
>
void
serialize
(
const
constituent
<
T
>&
item
,
std
::
ostream
&
out
)
{
serialize
(
item
.
begin
,
out
);
serialize
(
item
.
end
,
out
);
serialize
(
item
.
k
,
out
);
serialize
(
item
.
left_tag
,
out
);
serialize
(
item
.
right_tag
,
out
);
}
template
<
typename
T
>
void
deserialize
(
constituent
<
T
>&
item
,
std
::
istream
&
in
)
{
deserialize
(
item
.
begin
,
in
);
deserialize
(
item
.
end
,
in
);
deserialize
(
item
.
k
,
in
);
deserialize
(
item
.
left_tag
,
in
);
deserialize
(
item
.
right_tag
,
in
);
}
// -----------------------------------------------------------------------------------------
const
unsigned
long
END_OF_TREE
=
0xFFFFFFFF
;
// -----------------------------------------------------------------------------------------
template
<
typename
T
>
struct
parse_tree_element
{
...
...
@@ -35,6 +66,33 @@ namespace dlib
double
score
;
};
template
<
typename
T
>
void
serialize
(
const
parse_tree_element
<
T
>&
item
,
std
::
ostream
&
out
)
{
serialize
(
item
.
c
,
out
);
serialize
(
item
.
tag
,
out
);
serialize
(
item
.
left
,
out
);
serialize
(
item
.
right
,
out
);
serialize
(
item
.
score
,
out
);
}
template
<
typename
T
>
void
deserialize
(
parse_tree_element
<
T
>&
item
,
std
::
istream
&
in
)
{
deserialize
(
item
.
c
,
in
);
deserialize
(
item
.
tag
,
in
);
deserialize
(
item
.
left
,
in
);
deserialize
(
item
.
right
,
in
);
deserialize
(
item
.
score
,
in
);
}
// -----------------------------------------------------------------------------------------
namespace
impl
{
...
...
dlib/optimization/find_max_parse_cky_abstract.h
View file @
249b0dd1
...
...
@@ -24,11 +24,33 @@ namespace dlib
T
right_tag
;
};
template
<
typename
T
>
void
serialize
(
const
constituent
<
T
>&
item
,
std
::
ostream
&
out
);
/*!
provides serialization support
!*/
template
<
typename
T
>
void
deserialize
(
constituent
<
T
>&
item
,
std
::
istream
&
in
);
/*!
provides deserialization support
!*/
// -----------------------------------------------------------------------------------------
/*!A END_OF_TREE is used to indicate that parse_tree_element::left or
parse_tree_element::right doesn't point to another subtree.
!*/
const
unsigned
long
END_OF_TREE
=
0xFFFFFFFF
;
// -----------------------------------------------------------------------------------------
template
<
typename
T
>
struct
parse_tree_element
{
...
...
@@ -46,6 +68,24 @@ namespace dlib
double
score
;
// score for this tree
};
template
<
typename
T
>
void
serialize
(
const
parse_tree_element
<
T
>&
item
,
std
::
ostream
&
out
);
/*!
provides serialization support
!*/
template
<
typename
T
>
void
deserialize
(
parse_tree_element
<
T
>&
item
,
std
::
istream
&
in
);
/*!
provides deserialization support
!*/
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
...
...
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