Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WCCL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Analysers
WCCL
Commits
fabf3493
Commit
fabf3493
authored
Dec 9, 2010
by
Adam Wardynski
Browse files
Options
Downloads
Patches
Plain Diff
categories_count(tagset) method for TSet.
parent
47a70582
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
libwccl/values/tset.cpp
+13
-1
13 additions, 1 deletion
libwccl/values/tset.cpp
libwccl/values/tset.h
+8
-2
8 additions, 2 deletions
libwccl/values/tset.h
tests/values.cpp
+8
-0
8 additions, 0 deletions
tests/values.cpp
with
29 additions
and
3 deletions
libwccl/values/tset.cpp
+
13
−
1
View file @
fabf3493
#include
<libwccl/values/tset.h>
#include
<libwccl/values/tset.h>
#include
<libpwrutils/foreach.h>
#include
<sstream>
#include
<sstream>
namespace
Wccl
{
namespace
Wccl
{
...
@@ -17,11 +18,22 @@ std::string TSet::to_string(const Corpus2::Tagset& tagset) const
...
@@ -17,11 +18,22 @@ std::string TSet::to_string(const Corpus2::Tagset& tagset) const
std
::
string
TSet
::
var_repr
(
const
std
::
string
&
var_name
)
std
::
string
TSet
::
var_repr
(
const
std
::
string
&
var_name
)
{
{
std
::
stringstream
ss
;
std
::
o
stringstream
ss
;
ss
<<
"$t:"
<<
var_name
;
ss
<<
"$t:"
<<
var_name
;
return
ss
.
str
();
return
ss
.
str
();
}
}
int
TSet
::
categories_count
(
const
Corpus2
::
Tagset
&
tagset
)
const
{
int
cats
=
(
tag_
.
get_pos
().
any
())
?
1
:
0
;
foreach
(
const
Corpus2
::
mask_t
&
mask
,
tagset
.
all_attribute_masks
())
{
if
(
tag_
.
get_values_for
(
mask
).
any
())
{
++
cats
;
}
}
return
cats
;
}
void
TSet
::
insert_symbol
(
const
Corpus2
::
Tagset
&
tagset
,
const
std
::
string
&
s
)
void
TSet
::
insert_symbol
(
const
Corpus2
::
Tagset
&
tagset
,
const
std
::
string
&
s
)
{
{
tag_
.
combine_with
(
tagset
.
parse_symbol
(
s
));
tag_
.
combine_with
(
tagset
.
parse_symbol
(
s
));
...
...
This diff is collapsed.
Click to expand it.
libwccl/values/tset.h
+
8
−
2
View file @
fabf3493
...
@@ -52,7 +52,7 @@ public:
...
@@ -52,7 +52,7 @@ public:
}
}
/**
/**
* Convenience function to add a symbol from a tags
t
e by name.
* Convenience function to add a symbol from a tagse
t
by name.
*
*
* Note: slow. Avoid in code that gets repeatedly executed.
* Note: slow. Avoid in code that gets repeatedly executed.
*/
*/
...
@@ -82,6 +82,13 @@ public:
...
@@ -82,6 +82,13 @@ public:
return
tag_
==
other
.
tag_
;
return
tag_
==
other
.
tag_
;
}
}
/**
* @return Number of categories present in this symbol set according
* to supplied tagset.
* @note A category is word class or an attribute.
*/
int
categories_count
(
const
Corpus2
::
Tagset
&
tagset
)
const
;
void
combine_with
(
const
Corpus2
::
Tag
&
other
)
{
void
combine_with
(
const
Corpus2
::
Tag
&
other
)
{
tag_
.
combine_with
(
other
);
tag_
.
combine_with
(
other
);
}
}
...
@@ -90,7 +97,6 @@ public:
...
@@ -90,7 +97,6 @@ public:
tag_
.
combine_with
(
other
.
get_value
());
tag_
.
combine_with
(
other
.
get_value
());
}
}
std
::
string
to_string
(
const
Corpus2
::
Tagset
&
)
const
;
std
::
string
to_string
(
const
Corpus2
::
Tagset
&
)
const
;
std
::
string
to_raw_string
()
const
;
std
::
string
to_raw_string
()
const
;
...
...
This diff is collapsed.
Click to expand it.
tests/values.cpp
+
8
−
0
View file @
fabf3493
...
@@ -72,17 +72,21 @@ BOOST_AUTO_TEST_CASE(tset_ops)
...
@@ -72,17 +72,21 @@ BOOST_AUTO_TEST_CASE(tset_ops)
BOOST_CHECK
(
s1
.
is_subset_of
(
s2
));
BOOST_CHECK
(
s1
.
is_subset_of
(
s2
));
BOOST_CHECK
(
s2
.
is_subset_of
(
s1
));
BOOST_CHECK
(
s2
.
is_subset_of
(
s1
));
BOOST_CHECK
(
!
s1
.
intersects
(
s2
));
BOOST_CHECK
(
!
s1
.
intersects
(
s2
));
BOOST_CHECK_EQUAL
(
0
,
s1
.
categories_count
(
tagset
));
s1
.
insert_symbol
(
tagset
,
"subst"
);
s1
.
insert_symbol
(
tagset
,
"subst"
);
BOOST_CHECK_EQUAL
(
1
,
s1
.
categories_count
(
tagset
));
BOOST_CHECK
(
!
s1
.
equals
(
s2
));
BOOST_CHECK
(
!
s1
.
equals
(
s2
));
BOOST_CHECK
(
!
s1
.
is_subset_of
(
s2
));
BOOST_CHECK
(
!
s1
.
is_subset_of
(
s2
));
BOOST_CHECK
(
s2
.
is_subset_of
(
s1
));
BOOST_CHECK
(
s2
.
is_subset_of
(
s1
));
BOOST_CHECK
(
!
s1
.
intersects
(
s2
));
BOOST_CHECK
(
!
s1
.
intersects
(
s2
));
s2
.
insert_symbol
(
tagset
,
"pl"
);
s2
.
insert_symbol
(
tagset
,
"pl"
);
BOOST_CHECK_EQUAL
(
1
,
s2
.
categories_count
(
tagset
));
BOOST_CHECK
(
!
s1
.
equals
(
s2
));
BOOST_CHECK
(
!
s1
.
equals
(
s2
));
BOOST_CHECK
(
!
s1
.
is_subset_of
(
s2
));
BOOST_CHECK
(
!
s1
.
is_subset_of
(
s2
));
BOOST_CHECK
(
!
s2
.
is_subset_of
(
s1
));
BOOST_CHECK
(
!
s2
.
is_subset_of
(
s1
));
BOOST_CHECK
(
!
s1
.
intersects
(
s2
));
BOOST_CHECK
(
!
s1
.
intersects
(
s2
));
s2
.
insert_symbol
(
tagset
,
"subst"
);
s2
.
insert_symbol
(
tagset
,
"subst"
);
BOOST_CHECK_EQUAL
(
2
,
s2
.
categories_count
(
tagset
));
BOOST_CHECK
(
!
s1
.
equals
(
s2
));
BOOST_CHECK
(
!
s1
.
equals
(
s2
));
BOOST_CHECK
(
s1
.
is_subset_of
(
s2
));
BOOST_CHECK
(
s1
.
is_subset_of
(
s2
));
BOOST_CHECK
(
!
s2
.
is_subset_of
(
s1
));
BOOST_CHECK
(
!
s2
.
is_subset_of
(
s1
));
...
@@ -92,6 +96,10 @@ BOOST_AUTO_TEST_CASE(tset_ops)
...
@@ -92,6 +96,10 @@ BOOST_AUTO_TEST_CASE(tset_ops)
BOOST_CHECK
(
s1
.
is_subset_of
(
s2
));
BOOST_CHECK
(
s1
.
is_subset_of
(
s2
));
BOOST_CHECK
(
s2
.
is_subset_of
(
s1
));
BOOST_CHECK
(
s2
.
is_subset_of
(
s1
));
BOOST_CHECK
(
s1
.
intersects
(
s2
));
BOOST_CHECK
(
s1
.
intersects
(
s2
));
s1
.
insert_symbol
(
tagset
,
"sg"
);
BOOST_CHECK_EQUAL
(
2
,
s1
.
categories_count
(
tagset
));
s1
.
insert_symbol
(
tagset
,
"f"
);
BOOST_CHECK_EQUAL
(
3
,
s1
.
categories_count
(
tagset
));
}
}
BOOST_AUTO_TEST_CASE
(
position_ops
)
BOOST_AUTO_TEST_CASE
(
position_ops
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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