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
51d291a8
"...text-generation-inference.git" did not exist on "57b34958235ee64b7c310a4b5410bcc491a0ef28"
Commit
51d291a8
authored
Jun 04, 2013
by
Davis King
Browse files
clarified example program
parent
e2a9071b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
examples/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).
I
n the code below we create some very simple
sequence/segmentation training
people).
Therefore, i
n 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
string
s and our task will be to learn to identify
person
be sentences represented as
arrays of
word
s 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