Skip to content
Snippets Groups Projects
Commit 50606d90 authored by ilor's avatar ilor
Browse files

Merge branch 'master' of nlp.pwr.wroc.pl:wccl

parents 5a14e741 1a999453
No related branches found
No related tags found
No related merge requests found
......@@ -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_);
......
......@@ -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_;
};
......
......@@ -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) {
......@@ -1958,14 +1961,23 @@ match_mark_action
new MarkMatch(
match_from,
((antlr::Token*)annotation_name)->getText()));
} else {
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()));
}
}
}
;
// Match unmark action
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment