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
1a999453
Commit
1a999453
authored
13 years ago
by
Adam Wardynski
Browse files
Options
Downloads
Patches
Plain Diff
Adding ability to mark head in mark for matches.
parent
b1b976c6
Branches
Branches containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
libwccl/ops/match/actions/markmatch.cpp
+9
-3
9 additions, 3 deletions
libwccl/ops/match/actions/markmatch.cpp
libwccl/ops/match/actions/markmatch.h
+20
-0
20 additions, 0 deletions
libwccl/ops/match/actions/markmatch.h
libwccl/parser/grammar.g
+18
-6
18 additions, 6 deletions
libwccl/parser/grammar.g
with
47 additions
and
9 deletions
libwccl/ops/match/actions/markmatch.cpp
+
9
−
3
View file @
1a999453
...
...
@@ -18,20 +18,26 @@ void MarkMatch::execute(const ActionExecContext& context) const
boost
::
shared_ptr
<
const
Match
>
match_from
=
match_from_
->
apply
(
context
);
boost
::
shared_ptr
<
const
Match
>
match_to
=
(
match_from_
.
get
()
==
match_to_
.
get
())
?
match_from
:
match_to_
->
apply
(
context
);
boost
::
shared_ptr
<
const
Match
>
head_match
=
(
match_from_
.
get
()
==
head_match_
.
get
())
?
match_from
:
head_match_
->
apply
(
context
);
int
abs_left
=
match_from
->
first_token
(
as
).
get_value
();
int
abs_right
=
match_to
->
last_token
(
as
).
get_value
();
if
(
abs_left
<
0
)
{
throw
WcclError
(
"Received starting match that points outside sentence."
);
}
int
abs_right
=
match_to
->
last_token
(
as
).
get_value
();
if
(
abs_right
>=
sc
.
size
())
{
throw
WcclError
(
"Received ending match that points outside sentence."
);
}
if
(
abs_left
>
abs_right
)
{
throw
WcclError
(
"Received starting match points after the received ending match."
);
}
// TODO: what about head in this mark from match actions? Mark from tag actions does have it.
int
abs_head
=
abs_left
;
int
abs_head
=
head_match
->
first_token
(
as
).
get_value
();
if
(
abs_head
<
abs_left
||
abs_head
>
abs_right
)
{
throw
WcclError
(
"Received head match points outside range defined by start and end matches."
);
}
if
(
!
as
->
has_channel
(
chan_name_
))
{
as
->
create_channel
(
chan_name_
);
...
...
This diff is collapsed.
Click to expand it.
libwccl/ops/match/actions/markmatch.h
+
20
−
0
View file @
1a999453
...
...
@@ -12,13 +12,30 @@ public:
MarkMatch
(
const
boost
::
shared_ptr
<
Function
<
Match
>
>&
match_from
,
const
boost
::
shared_ptr
<
Function
<
Match
>
>&
match_to
,
const
boost
::
shared_ptr
<
Function
<
Match
>
>&
head_match
,
const
std
::
string
&
annotation_name
)
:
match_from_
(
match_from
),
match_to_
(
match_to
),
head_match_
(
head_match
),
chan_name_
(
annotation_name
)
{
BOOST_ASSERT
(
match_from_
);
BOOST_ASSERT
(
match_to_
);
BOOST_ASSERT
(
head_match_
);
}
MarkMatch
(
const
boost
::
shared_ptr
<
Function
<
Match
>
>&
match_from
,
const
boost
::
shared_ptr
<
Function
<
Match
>
>&
match_to
,
const
std
::
string
&
annotation_name
)
:
match_from_
(
match_from
),
match_to_
(
match_to
),
head_match_
(
match_from
),
chan_name_
(
annotation_name
)
{
BOOST_ASSERT
(
match_from_
);
BOOST_ASSERT
(
match_to_
);
BOOST_ASSERT
(
head_match_
);
}
MarkMatch
(
...
...
@@ -26,10 +43,12 @@ public:
const
std
::
string
&
annotation_name
)
:
match_from_
(
match_from_to
),
match_to_
(
match_from_to
),
head_match_
(
match_from_to
),
chan_name_
(
annotation_name
)
{
BOOST_ASSERT
(
match_from_
);
BOOST_ASSERT
(
match_to_
);
BOOST_ASSERT
(
head_match_
);
}
/**
* @returns Name of the action.
...
...
@@ -59,6 +78,7 @@ protected:
private
:
const
boost
::
shared_ptr
<
Function
<
Match
>
>&
match_from_
;
const
boost
::
shared_ptr
<
Function
<
Match
>
>&
match_to_
;
const
boost
::
shared_ptr
<
Function
<
Match
>
>&
head_match_
;
const
std
::
string
chan_name_
;
};
...
...
This diff is collapsed.
Click to expand it.
libwccl/parser/grammar.g
+
18
−
6
View file @
1a999453
...
...
@@ -1947,10 +1947,13 @@ match_mark_action
{
boost::shared_ptr<Function<Match> > match_to;
boost::shared_ptr<Function<Match> > match_from;
boost::shared_ptr<Function<Match> > head_match;
}
: "mark" LPAREN
match_from = match_fit[tagset, vars] COMMA
(match_to = match_fit[tagset, vars] COMMA) ?
( match_to = match_fit[tagset, vars] COMMA
( head_match = match_fit[tagset, vars] COMMA )?
)?
annotation_name : STRING
RPAREN {
if (!match_to) {
...
...
@@ -1959,11 +1962,20 @@ match_mark_action
match_from,
((antlr::Token*)annotation_name)->getText()));
} else {
m_act.reset(
new MarkMatch(
match_from,
match_to,
((antlr::Token*)annotation_name)->getText()));
if (!head_match) {
m_act.reset(
new MarkMatch(
match_from,
match_to,
((antlr::Token*)annotation_name)->getText()));
} else {
m_act.reset(
new MarkMatch(
match_from,
match_to,
head_match,
((antlr::Token*)annotation_name)->getText()));
}
}
}
;
...
...
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