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
51d291a8
Commit
51d291a8
authored
Jun 05, 2013
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clarified example program
parent
e2a9071b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
sequence_segmenter_ex.cpp
examples/sequence_segmenter_ex.cpp
+6
-7
No files found.
examples/sequence_segmenter_ex.cpp
View file @
51d291a8
...
@@ -4,11 +4,12 @@
...
@@ -4,11 +4,12 @@
This example shows how to use dlib to learn to perform sequence segmentation. In a
This example shows how to use dlib to learn to perform sequence segmentation. In a
sequence segmentation task we are given a sequence of objects (e.g. words in a
sequence segmentation task we are given a sequence of objects (e.g. words in a
sentence) and we are supposed to detect certain subsequences (e.g. the names of
sentence) and we are supposed to detect certain subsequences (e.g. the names of
people).
In the code below we create some very simple sequence/segmentation training
people).
Therefore, in the code below we create some very simple training sequences
examples and use them to learn a sequence segmentation model. In particular, our
and use them to learn a sequence segmentation model. In particular, our sequences will
sequences will be arrays of strings and our task will be to learn to identify person
be sentences represented as arrays of words and our task will be to learn to identify
names. Once we have our segmentation model we can use it to find names in new
person
names. Once we have our segmentation model we can use it to find names in new
sentences as we will show.
sentences as we will show.
*/
*/
...
@@ -85,9 +86,6 @@ public:
...
@@ -85,9 +86,6 @@ public:
// The model in this example program is very simple. Our features only look at the
// The model in this example program is very simple. Our features only look at the
// capitalization pattern of the words. So we have a single feature which checks
// capitalization pattern of the words. So we have a single feature which checks
// if the first letter is capitalized or not.
// if the first letter is capitalized or not.
// if the first character of the word sentence[position] is capitalized then
// we set our only feature 1, otherwise it remains set to 0.
if
(
isupper
(
sentence
[
position
][
0
]))
if
(
isupper
(
sentence
[
position
][
0
]))
set_feature
(
0
);
set_feature
(
0
);
}
}
...
@@ -207,6 +205,7 @@ int main()
...
@@ -207,6 +205,7 @@ int main()
}
}
// Now lets test it on a new sentence and see what it detects.
std
::
vector
<
std
::
string
>
sentence
(
split
(
"There once was a man from Nantucket whose name rhymed with Bob Bucket"
));
std
::
vector
<
std
::
string
>
sentence
(
split
(
"There once was a man from Nantucket whose name rhymed with Bob Bucket"
));
std
::
vector
<
std
::
pair
<
unsigned
long
,
unsigned
long
>
>
seg
=
segmenter
(
sentence
);
std
::
vector
<
std
::
pair
<
unsigned
long
,
unsigned
long
>
>
seg
=
segmenter
(
sentence
);
for
(
unsigned
long
j
=
0
;
j
<
seg
.
size
();
++
j
)
for
(
unsigned
long
j
=
0
;
j
<
seg
.
size
();
++
j
)
...
...
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