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
d35e12c3
Commit
d35e12c3
authored
13 years ago
by
Bartosz Broda
Browse files
Options
Downloads
Patches
Plain Diff
add searching for head of an mwe
parent
c2317fdd
Branches
Branches containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
libmwereader/mwe.cpp
+20
-3
20 additions, 3 deletions
libmwereader/mwe.cpp
libmwereader/mwe.h
+1
-1
1 addition, 1 deletion
libmwereader/mwe.h
libmwereader/mwereader.cpp
+2
-1
2 additions, 1 deletion
libmwereader/mwereader.cpp
libmwereader/test_mwe.xml
+1
-1
1 addition, 1 deletion
libmwereader/test_mwe.xml
with
24 additions
and
6 deletions
libmwereader/mwe.cpp
+
20
−
3
View file @
d35e12c3
...
...
@@ -24,7 +24,7 @@ LexicalUnit::LexicalUnit(const std::string &base,
}
bool
LexicalUnit
::
IsHere
(
const
Wccl
::
SentenceContext
&
sc
,
std
::
set
<
size_t
>
&
out_position
)
const
std
::
set
<
size_t
>
&
out_position
,
int
&
head_pos
)
const
{
// set variables
for
(
variables_map
::
const_iterator
ivars
=
variables_
.
begin
();
...
...
@@ -37,6 +37,10 @@ bool LexicalUnit::IsHere(const Wccl::SentenceContext &sc,
if
(
pResult
->
get_value
()
==
false
)
return
false
;
bool
found_head
=
false
;
Wccl
::
SentenceContext
sc2
(
sc
.
get_sentence_ptr
());
// fill up positions
foreach
(
const
std
::
string
&
varname
,
condition_
->
valid_variable_names
()){
if
(
boost
::
algorithm
::
starts_with
(
varname
,
"Pos"
)){
...
...
@@ -46,11 +50,24 @@ bool LexicalUnit::IsHere(const Wccl::SentenceContext &sc,
errmsg
+=
" Offending unit: "
+
base_
;
throw
Wccl
::
WcclError
(
errmsg
);
}
out_position
.
insert
(
sc
.
get_abs_position
(
pos
)
);
int
abs_pos
=
sc
.
get_abs_position
(
pos
);
out_position
.
insert
(
abs_pos
);
if
(
!
found_head
){
sc2
.
set_position
(
abs_pos
);
if
(
head_cond_
->
apply
(
sc2
)
->
get_value
()){
head_pos
=
abs_pos
;
found_head
=
true
;
}
}
}
}
// TODO head position
if
(
!
found_head
){
std
::
string
errmsg
(
"MWE found, but no head for it."
);
errmsg
+=
" Offending unit: "
+
base_
;
throw
Wccl
::
WcclError
(
errmsg
);
}
return
true
;
}
...
...
This diff is collapsed.
Click to expand it.
libmwereader/mwe.h
+
1
−
1
View file @
d35e12c3
...
...
@@ -35,7 +35,7 @@ public:
* \returns true if this lexical unit was found here
*/
virtual
bool
IsHere
(
const
Wccl
::
SentenceContext
&
sc
,
std
::
set
<
size_t
>
&
out_positions
)
const
;
std
::
set
<
size_t
>
&
out_positions
,
int
&
head_pos
)
const
;
const
std
::
string
&
get_base
()
const
{
return
base_
;}
const
variables_map
&
get_variables
()
const
{
return
variables_
;}
...
...
This diff is collapsed.
Click to expand it.
libmwereader/mwereader.cpp
+
2
−
1
View file @
d35e12c3
...
...
@@ -46,7 +46,8 @@ bool MWEReader::registered = TokenReader::register_path_reader<MWEReader>(
std
::
cout
<<
"# "
;
foreach
(
LexicalUnit
::
Ptr
pLU
,
potential
){
std
::
set
<
size_t
>
positions
;
bool
is_here
=
pLU
->
IsHere
(
sc
,
positions
);
int
head
;
bool
is_here
=
pLU
->
IsHere
(
sc
,
positions
,
head
);
if
(
is_here
)
std
::
cout
<<
"** "
<<
pLU
->
get_base
()
<<
"** "
;
}
...
...
This diff is collapsed.
Click to expand it.
libmwereader/test_mwe.xml
+
1
−
1
View file @
d35e12c3
...
...
@@ -17,7 +17,7 @@
<MWE
base=
"Jan Paweł"
>
<var
name=
"Subst1"
>
jan
</var>
<var
name=
"Subst2"
>
paweł
</var>
<head>
inter(
c
as[0],
{nom}
)
</head>
<head>
inter(
b
as
e
[0],
"jan"
)
</head>
</MWE>
<MWE
base=
"waga netto"
>
<var
name=
"Subst1"
>
waga
</var>
...
...
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