Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
corpus2
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Analysers
corpus2
Commits
19e77ee0
Commit
19e77ee0
authored
14 years ago
by
ilor
Browse files
Options
Downloads
Patches
Plain Diff
convenience functions for token disamb lexemes
parent
b244ceb1
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libcorpus2/token.cpp
+21
-1
21 additions, 1 deletion
libcorpus2/token.cpp
libcorpus2/token.h
+25
-0
25 additions, 0 deletions
libcorpus2/token.h
with
46 additions
and
1 deletion
libcorpus2/token.cpp
+
21
−
1
View file @
19e77ee0
...
...
@@ -15,9 +15,10 @@ or FITNESS FOR A PARTICULAR PURPOSE.
*/
#include
<libcorpus2/token.h>
#include
<sstream>
#include
<libpwrutils/foreach.h>
#include
<libcorpus2/tokenmetadata.h>
#include
<sstream>
#include
<boost/bind.hpp>
namespace
Corpus2
{
...
...
@@ -79,6 +80,25 @@ size_t Token::get_preferred_lexeme_index(const Tagset& tagset) const
return
std
::
distance
(
lexemes_
.
begin
(),
pref
);
}
bool
Token
::
has_disamb_lexeme
()
const
{
return
std
::
find_if
(
lexemes
().
begin
(),
lexemes
().
end
(),
boost
::
bind
(
&
Lexeme
::
is_disamb
,
_1
))
!=
lexemes
().
end
();
}
int
Token
::
count_disamb_lexemes
()
const
{
return
std
::
count_if
(
lexemes
().
begin
(),
lexemes
().
end
(),
boost
::
bind
(
&
Lexeme
::
is_disamb
,
_1
));
}
std
::
pair
<
Token
::
lexeme_filter_iterator
,
Token
::
lexeme_filter_iterator
>
Token
::
disamb_lexemes
()
const
{
lexeme_filter_iterator
f1
(
boost
::
bind
(
&
Lexeme
::
is_disamb
,
_1
),
lexemes
().
begin
(),
lexemes
().
end
());
lexeme_filter_iterator
f2
(
boost
::
bind
(
&
Lexeme
::
is_disamb
,
_1
),
lexemes
().
end
(),
lexemes
().
end
());
return
std
::
make_pair
(
f1
,
f2
);
}
void
Token
::
make_ign
(
const
Tagset
&
tagset
)
{
lexemes_
.
clear
();
...
...
This diff is collapsed.
Click to expand it.
libcorpus2/token.h
+
25
−
0
View file @
19e77ee0
...
...
@@ -23,6 +23,9 @@ or FITNESS FOR A PARTICULAR PURPOSE.
#include
<libpwrutils/util.h>
#include
<libpwrutils/whitespace.h>
#include
<boost/iterator/filter_iterator.hpp>
#include
<boost/function.hpp>
#include
<unicode/unistr.h>
#include
<memory>
#include
<string>
...
...
@@ -128,6 +131,28 @@ public:
*/
bool
remove_duplicate_lexemes
();
/**
* Return true if there is at least one disambed lexeme in this token.
*/
bool
has_disamb_lexeme
()
const
;
/**
* Return the count of disambed lexemes in this token.
*/
int
count_disamb_lexemes
()
const
;
/// Helper iterator typedef
typedef
boost
::
filter_iterator
<
boost
::
function
<
bool
(
const
Lexeme
&
)
>
,
std
::
vector
<
Lexeme
>::
const_iterator
>
lexeme_filter_iterator
;
/**
* Helper to iterate through disamb-marked lexemes only (lexemes with
* the disamb flag false are skipped).
*/
std
::
pair
<
lexeme_filter_iterator
,
lexeme_filter_iterator
>
disamb_lexemes
()
const
;
/**
* Check if all the lexemes of the token have the given POS, and and
* the token orth caselessly matches the given orth.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment