Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WCCL
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
WCCL
Commits
e70ded36
There was an error fetching the commit references. Please try again later.
Commit
e70ded36
authored
13 years ago
by
Bartosz Broda
Browse files
Options
Downloads
Patches
Plain Diff
small cleanup, small extensions
parent
cc8c48ad
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
libmwereader/mwe.cpp
+17
-4
17 additions, 4 deletions
libmwereader/mwe.cpp
libmwereader/mwe.h
+17
-11
17 additions, 11 deletions
libmwereader/mwe.h
libmwereader/mweparser.cpp
+6
-5
6 additions, 5 deletions
libmwereader/mweparser.cpp
with
40 additions
and
20 deletions
libmwereader/mwe.cpp
+
17
−
4
View file @
e70ded36
...
...
@@ -19,7 +19,7 @@ LexicalUnit::LexicalUnit(const std::string &base,
}
bool
LexicalUnit
::
IsHere
(
const
Wccl
::
SentenceContext
&
sc
,
std
::
set
<
size_t
>
&
out_position
)
std
::
set
<
size_t
>
&
out_position
)
const
{
boost
::
shared_ptr
<
const
Wccl
::
Bool
>
pResult
=
condition_
->
apply
(
sc
);
if
(
pResult
->
get_value
()
==
false
)
...
...
@@ -39,6 +39,8 @@ bool LexicalUnit::IsHere(const Wccl::SentenceContext &sc,
return
true
;
}
////////////////////////////////////////////////////////////////////
// TODO realy needed?
FixedLU
::
FixedLU
(
const
std
::
string
&
base
,
boost
::
shared_ptr
<
Wccl
::
Operator
<
Wccl
::
Bool
>
>
condition
,
...
...
@@ -56,12 +58,14 @@ FlexLU::FlexLU(const std::string &base,
{
}
MWEIndex
::
MWEIndex
()
{
////////////////////////////////////////////////////////////////////
MWEIndex
::
MWEIndex
()
:
index_
(),
empty_
()
{
// noop
}
void
MWEIndex
::
add_lexicalunit
(
LexicalUnitPtr
lu
)
void
MWEIndex
::
add_lexicalunit
(
LexicalUnit
::
Ptr
lu
)
{
foreach
(
const
std
::
string
&
base
,
lu
->
get_potential_bases
()){
value_type
::
iterator
find
=
index_
.
find
(
base
);
...
...
@@ -75,4 +79,13 @@ void MWEIndex::add_lexicalunit(LexicalUnitPtr lu)
}
}
const
MWEIndex
::
luvec
&
MWEIndex
::
get_potential_lu
(
const
std
::
string
&
base
){
value_type
::
iterator
find
=
index_
.
find
(
base
);
if
(
find
==
index_
.
end
()){
// not found -> return empty
return
empty_
;
}
return
(
find
->
second
);
}
}
//ns Corpus2
This diff is collapsed.
Click to expand it.
libmwereader/mwe.h
+
17
−
11
View file @
e70ded36
...
...
@@ -31,14 +31,14 @@ public:
* \returns true if this lexical unit was found here
*/
virtual
bool
IsHere
(
const
Wccl
::
SentenceContext
&
sc
,
std
::
set
<
size_t
>
&
out_positions
)
;
std
::
set
<
size_t
>
&
out_positions
)
const
;
const
std
::
string
&
get_base
()
const
{
return
base_
;}
const
strmap
&
get_variables
()
const
{
return
variables_
;}
const
strset
&
get_potential_bases
()
const
{
return
potential_bases_
;}
typedef
boost
::
shared_ptr
<
LexicalUnit
>
Ptr
;
protected
:
boost
::
shared_ptr
<
Wccl
::
Operator
<
Wccl
::
Bool
>
>
condition_
;
...
...
@@ -51,7 +51,7 @@ protected:
const
Wccl
::
Position
nowhere_
;
};
typedef
boost
::
shared_ptr
<
LexicalUnit
>
LexicalUnitPtr
;
// TODO: czy bedzie potrzebny podzial na fix/flex w kodzie?
...
...
@@ -59,9 +59,9 @@ class FixedLU : public LexicalUnit
{
public:
FixedLU
(
const
std
::
string
&
base
,
boost
::
shared_ptr
<
Wccl
::
Operator
<
Wccl
::
Bool
>
>
condition
,
boost
::
shared_ptr
<
Wccl
::
Operator
<
Wccl
::
Bool
>
>
head_cond
,
std
::
map
<
std
::
string
,
std
::
str
ing
>
variables
LexicalUnit
::
Bool
OpPtr
condition
,
LexicalUnit
::
Bool
OpPtr
head_cond
,
LexicalUnit
::
str
map
variables
);
};
...
...
@@ -69,9 +69,9 @@ class FlexLU : public LexicalUnit
{
public:
FlexLU
(
const
std
::
string
&
base
,
boost
::
shared_ptr
<
Wccl
::
Operator
<
Wccl
::
Bool
>
>
condition
,
boost
::
shared_ptr
<
Wccl
::
Operator
<
Wccl
::
Bool
>
>
head_cond
,
std
::
map
<
std
::
string
,
std
::
str
ing
>
variables
LexicalUnit
::
Bool
OpPtr
condition
,
LexicalUnit
::
Bool
OpPtr
head_cond
,
LexicalUnit
::
str
map
variables
);
};
...
...
@@ -79,16 +79,22 @@ public:
class
MWEIndex
// lub base -> vector<LexicalUnit>
{
public:
typedef
std
::
vector
<
LexicalUnit
::
Ptr
>
luvec
;
MWEIndex
();
void
add_lexicalunit
(
LexicalUnitPtr
lu
);
void
add_lexicalunit
(
LexicalUnit
::
Ptr
lu
);
const
luvec
&
get_potential_lu
(
const
std
::
string
&
base
);
protected:
typedef
std
::
vector
<
LexicalUnitPtr
>
luvec
;
typedef
boost
::
unordered_map
<
std
::
string
,
luvec
>
value_type
;
value_type
index_
;
const
luvec
empty_
;
};
}
// ns Corpus2
...
...
This diff is collapsed.
Click to expand it.
libmwereader/mweparser.cpp
+
6
−
5
View file @
e70ded36
...
...
@@ -60,17 +60,18 @@ namespace Corpus2 {
MWEBuilder
::
BoolOpPtr
head
=
mwe_builder_
->
get_head_condition
(
head_cond_
);
LexicalUnitPtr
lu
;
if
(
group_type_
==
"fix"
){
// group_name_ -> lower case
lu
=
LexicalUnitPtr
(
new
FixedLU
(
mwe_base_
,
main
,
head
,
variables_
));
mwe_index_
.
add_lexicalunit
(
LexicalUnit
::
Ptr
(
new
FixedLU
(
mwe_base_
,
main
,
head
,
variables_
))
)
;
}
else
if
(
group_type_
==
"flex"
){
lu
=
LexicalUnitPtr
(
new
FlexLU
(
mwe_base_
,
main
,
head
,
variables_
));
mwe_index_
.
add_lexicalunit
(
LexicalUnit
::
Ptr
(
new
FlexLU
(
mwe_base_
,
main
,
head
,
variables_
))
)
;
}
else
{
throw
Wccl
::
WcclError
(
"Unknown type of lexical unit:"
+
group_type_
);
}
}
std
::
string
MWEParser
::
get_attribute
(
const
AttributeList
&
attributes
,
...
...
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