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
1e850797
Commit
1e850797
authored
13 years ago
by
Adam Radziszewski
Browse files
Options
Downloads
Patches
Plain Diff
disambiguation functions
parent
f7917760
Branches
Branches containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
libcorpus2/tagging.cpp
+34
-0
34 additions, 0 deletions
libcorpus2/tagging.cpp
libcorpus2/tagging.h
+18
-0
18 additions, 0 deletions
libcorpus2/tagging.h
swig/tagging.i
+4
-0
4 additions, 0 deletions
swig/tagging.i
with
56 additions
and
0 deletions
libcorpus2/tagging.cpp
+
34
−
0
View file @
1e850797
...
...
@@ -91,4 +91,38 @@ void select_singular_tags(const Tagset& tagset, Token* token)
}
}
bool
disambiguate_equal
(
Token
*
token
,
const
Tag
&
mask_where
,
const
Tag
&
mask_wanted
)
{
std
::
vector
<
Lexeme
>
wanted
;
foreach
(
const
Lexeme
&
lex
,
token
->
lexemes
())
{
Tag
mask_theirs
=
lex
.
tag
().
get_masked
(
mask_where
);
if
(
mask_theirs
==
mask_wanted
)
{
wanted
.
push_back
(
lex
);
}
}
if
(
wanted
.
empty
())
{
return
false
;
}
token
->
replace_lexemes
(
wanted
);
return
true
;
}
bool
disambiguate_subset
(
Token
*
token
,
const
Tag
&
mask_where
,
const
Tag
&
mask_wanted
)
{
std
::
vector
<
Lexeme
>
wanted
;
foreach
(
const
Lexeme
&
lex
,
token
->
lexemes
())
{
Tag
mask_theirs
=
lex
.
tag
().
get_masked
(
mask_where
);
if
(
mask_theirs
.
get_masked
(
mask_wanted
)
==
mask_theirs
)
{
wanted
.
push_back
(
lex
);
}
}
if
(
wanted
.
empty
())
{
return
false
;
}
token
->
replace_lexemes
(
wanted
);
return
true
;
}
}
/* end ns Corpus2 */
This diff is collapsed.
Click to expand it.
libcorpus2/tagging.h
+
18
−
0
View file @
1e850797
...
...
@@ -61,6 +61,24 @@ void expand_unspec_attrs(const Tagset& tagset, Token* token);
*/
void
select_singular_tags
(
const
Tagset
&
tagset
,
Token
*
token
);
/** Tries to select only those lexemes whose tags projected onto mask_where
* have exactly the value as given in mask_wanted. E.g. pass whole attribute
* as mask_where and a particular desired value as mask_wanted. If no lexeme
* satisfies the constraint, will leave the token intact.
* @return if succeeded
*/
bool
disambiguate_equal
(
Token
*
token
,
const
Tag
&
mask_where
,
const
Tag
&
mask_wanted
);
/** Tries to select only those lexemes whose tags projected onto mask_where
* have a subset of the value as given in mask_wanted. E.g. pass noun + gerund
* mask and have both left. NOTE: this may be inconvenient for dealing with
* optional attributes. If no lexeme satisfies the constraint, will leave the
* token intact.
* @return if succeeded
*/
bool
disambiguate_subset
(
Token
*
token
,
const
Tag
&
mask_where
,
const
Tag
&
mask_wanted
);
}
/* end ns Corpus2 */
...
...
This diff is collapsed.
Click to expand it.
swig/tagging.i
+
4
−
0
View file @
1e850797
...
...
@@ -27,6 +27,10 @@ void expand_unspec_attrs(const Tagset& tagset, Token* token);
void select_singular_tags(const Tagset& tagset, Token* token);
bool disambiguate_equal(Token* token, const Tag& mask_where, const Tag& mask_wanted);
bool disambiguate_subset(Token* token, const Tag& mask_where, const Tag& mask_wanted);
}
using
namespace
std
;
...
...
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