Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
macaon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Franck Dary
macaon
Commits
e7ee9509
Commit
e7ee9509
authored
4 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Splited REDUCE transition in two, relaxed and strict
parent
70dc620b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
reading_machine/include/Transition.hpp
+2
-1
2 additions, 1 deletion
reading_machine/include/Transition.hpp
reading_machine/src/Transition.cpp
+40
-3
40 additions, 3 deletions
reading_machine/src/Transition.cpp
with
42 additions
and
4 deletions
reading_machine/include/Transition.hpp
+
2
−
1
View file @
e7ee9509
...
...
@@ -24,7 +24,8 @@ class Transition
void
initDeprel
(
std
::
string
label
);
void
initEagerLeft
();
void
initEagerRight
();
void
initReduce
();
void
initReduce_strict
();
void
initReduce_relaxed
();
void
initEOS
(
int
bufferIndex
);
void
initNothing
();
void
initIgnoreChar
();
...
...
This diff is collapsed.
Click to expand it.
reading_machine/src/Transition.cpp
+
40
−
3
View file @
e7ee9509
...
...
@@ -11,8 +11,10 @@ Transition::Transition(const std::string & name)
[
this
](
auto
sm
){(
initAdd
(
sm
[
3
],
sm
[
1
],
sm
[
2
],
sm
[
4
]));}},
{
std
::
regex
(
"SHIFT"
),
[
this
](
auto
){
initShift
();}},
{
std
::
regex
(
"REDUCE"
),
[
this
](
auto
){
initReduce
();}},
{
std
::
regex
(
"REDUCE_strict"
),
[
this
](
auto
){
initReduce_strict
();}},
{
std
::
regex
(
"REDUCE_relaxed"
),
[
this
](
auto
){
initReduce_relaxed
();}},
{
std
::
regex
(
"eager_LEFT_rel (.+)"
),
[
this
](
auto
sm
){(
initEagerLeft_rel
(
sm
[
1
]));}},
{
std
::
regex
(
"eager_RIGHT_rel (.+)"
),
...
...
@@ -449,7 +451,7 @@ void Transition::initEagerRight()
};
}
void
Transition
::
initReduce
()
void
Transition
::
initReduce
_strict
()
{
sequence
.
emplace_back
(
Action
::
assertIsNotEmpty
(
Config
::
headColName
,
Config
::
Object
::
Stack
,
0
));
sequence
.
emplace_back
(
Action
::
popStack
());
...
...
@@ -485,6 +487,41 @@ void Transition::initReduce()
};
}
void
Transition
::
initReduce_relaxed
()
{
sequence
.
emplace_back
(
Action
::
popStack
());
cost
=
[](
const
Config
&
config
)
{
if
(
!
config
.
isToken
(
config
.
getStack
(
0
)))
return
0
;
int
cost
=
0
;
auto
stackIndex
=
config
.
getStack
(
0
);
auto
stackGovIndex
=
config
.
getConst
(
Config
::
headColName
,
stackIndex
,
0
);
for
(
int
i
=
config
.
getWordIndex
();
config
.
has
(
0
,
i
,
0
);
++
i
)
{
if
(
!
config
.
isToken
(
i
))
continue
;
auto
otherGovIndex
=
config
.
getConst
(
Config
::
headColName
,
i
,
0
);
if
(
stackGovIndex
==
std
::
to_string
(
i
)
||
otherGovIndex
==
std
::
to_string
(
stackIndex
))
++
cost
;
if
(
config
.
getConst
(
Config
::
EOSColName
,
i
,
0
)
==
Config
::
EOSSymbol1
)
break
;
}
if
(
config
.
getConst
(
Config
::
EOSColName
,
config
.
getStack
(
0
),
0
)
==
Config
::
EOSSymbol1
)
++
cost
;
return
cost
;
};
}
void
Transition
::
initEOS
(
int
bufferIndex
)
{
sequence
.
emplace_back
(
Action
::
setRoot
(
bufferIndex
));
...
...
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