Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
old_macaon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Franck Dary
old_macaon
Commits
6afe9f26
Commit
6afe9f26
authored
6 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Fixed oracle for systematic backtracking
parent
8353c4cc
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
transition_machine/src/Oracle.cpp
+16
-95
16 additions, 95 deletions
transition_machine/src/Oracle.cpp
with
16 additions
and
95 deletions
transition_machine/src/Oracle.cpp
+
16
−
95
View file @
6afe9f26
...
...
@@ -94,6 +94,19 @@ void Oracle::createDatabase()
return
1
;
})));
auto
backSys
=
[](
Config
&
c
,
Oracle
*
oracle
)
{
if
(
oracle
->
data
.
count
(
"systematic"
))
{
if
(
Action
(
"BACK "
+
oracle
->
data
[
"systematic"
]).
appliable
(
c
))
return
std
::
string
(
"BACK "
+
oracle
->
data
[
"systematic"
]);
return
std
::
string
(
"EPSILON"
);
}
return
std
::
string
(
"EPSILON"
);
};
str2oracle
.
emplace
(
"error_tagger"
,
std
::
unique_ptr
<
Oracle
>
(
new
Oracle
(
[](
Oracle
*
oracle
)
{
...
...
@@ -113,40 +126,7 @@ void Oracle::createDatabase()
}
}
},
[](
Config
&
c
,
Oracle
*
oracle
)
{
int
stateHistorySize
=
c
.
getStateHistory
(
"tagger"
).
size
();
if
(
c
.
getCurrentStateHistory
().
size
()
>=
2
&&
(
c
.
getCurrentStateHistory
().
top
()
==
"BACK"
||
c
.
getCurrentStateHistory
().
getElem
(
1
)
==
"BACK"
))
return
std
::
string
(
"EPSILON"
);
if
(
c
.
hashHistory
.
contains
(
c
.
computeHash
()))
return
std
::
string
(
"EPSILON"
);
if
(
oracle
->
data
.
count
(
"systematic"
))
{
if
(
stateHistorySize
>
std
::
stoi
(
oracle
->
data
[
"systematic"
]))
return
std
::
string
(
"BACK "
+
oracle
->
data
[
"systematic"
]);
return
std
::
string
(
"EPSILON"
);
}
auto
&
pos
=
c
.
getTape
(
"POS"
);
if
(
c
.
getHead
()
>
0
&&
pos
[
-
1
]
!=
pos
.
getRef
(
-
1
)
&&
pos
[
-
1
]
==
"det"
&&
pos
[
0
]
==
"prorel"
)
return
std
::
string
(
"BACK 1"
);
if
(
c
.
getHead
()
>
0
&&
pos
[
-
1
]
!=
pos
.
getRef
(
-
1
)
&&
pos
[
-
1
]
==
"det"
&&
pos
[
0
]
==
"prep"
)
return
std
::
string
(
"BACK 1"
);
if
(
c
.
getHead
()
>
0
&&
pos
[
-
1
]
!=
pos
.
getRef
(
-
1
)
&&
pos
[
-
1
]
==
"nc"
&&
pos
[
0
]
==
"nc"
)
return
std
::
string
(
"BACK 1"
);
if
(
c
.
getHead
()
>
0
&&
pos
[
-
1
]
!=
pos
.
getRef
(
-
1
)
&&
pos
[
-
1
]
==
"nc"
&&
pos
[
0
]
==
"prep"
)
return
std
::
string
(
"BACK 1"
);
return
std
::
string
(
"EPSILON"
);
},
backSys
,
[](
Config
&
,
Oracle
*
,
const
std
::
string
&
)
{
return
0
;
...
...
@@ -171,47 +151,7 @@ void Oracle::createDatabase()
}
}
},
[](
Config
&
c
,
Oracle
*
oracle
)
{
int
stateHistorySize
=
c
.
getStateHistory
(
"morpho"
).
size
();
if
(
c
.
getCurrentStateHistory
().
size
()
>=
2
&&
(
c
.
getCurrentStateHistory
().
top
()
==
"BACK"
||
c
.
getCurrentStateHistory
().
getElem
(
1
)
==
"BACK"
))
return
std
::
string
(
"EPSILON"
);
if
(
c
.
hashHistory
.
contains
(
c
.
computeHash
()))
return
std
::
string
(
"EPSILON"
);
if
(
oracle
->
data
.
count
(
"systematic"
))
{
if
(
stateHistorySize
>
std
::
stoi
(
oracle
->
data
[
"systematic"
]))
return
std
::
string
(
"BACK "
+
oracle
->
data
[
"systematic"
]);
return
std
::
string
(
"EPSILON"
);
}
auto
&
morpho
=
c
.
getTape
(
"MORPHO"
);
if
(
c
.
getHead
()
<=
0
)
return
std
::
string
(
"EPSILON"
);
auto
&
morphoRef
=
morpho
.
getRef
(
-
1
);
auto
&
morpho0
=
morpho
[
-
1
];
auto
&
morpho1
=
morpho
[
0
];
if
(
morpho0
==
morphoRef
)
return
std
::
string
(
"EPSILON"
);
auto
genre0
=
split
(
morpho0
,
'|'
)[
0
];
auto
genre1
=
split
(
morpho1
,
'|'
)[
0
];
if
(
genre0
==
"g=f"
&&
genre1
==
"g=m"
)
return
std
::
string
(
"BACK 1"
);
if
(
genre0
==
"g=m"
&&
genre1
==
"g=f"
)
return
std
::
string
(
"BACK 1"
);
return
std
::
string
(
"EPSILON"
);
},
backSys
,
[](
Config
&
,
Oracle
*
,
const
std
::
string
&
)
{
return
0
;
...
...
@@ -236,26 +176,7 @@ void Oracle::createDatabase()
}
}
},
[](
Config
&
c
,
Oracle
*
oracle
)
{
int
stateHistorySize
=
c
.
getStateHistory
(
"parser"
).
size
();
if
(
c
.
getCurrentStateHistory
().
size
()
>=
2
&&
(
c
.
getCurrentStateHistory
().
top
()
==
"BACK"
||
c
.
getCurrentStateHistory
().
getElem
(
1
)
==
"BACK"
))
return
std
::
string
(
"EPSILON"
);
if
(
c
.
hashHistory
.
contains
(
c
.
computeHash
()))
return
std
::
string
(
"EPSILON"
);
if
(
oracle
->
data
.
count
(
"systematic"
))
{
if
(
stateHistorySize
>
std
::
stoi
(
oracle
->
data
[
"systematic"
]))
return
std
::
string
(
"BACK "
+
oracle
->
data
[
"systematic"
]);
return
std
::
string
(
"EPSILON"
);
}
return
std
::
string
(
"EPSILON"
);
},
backSys
,
[](
Config
&
,
Oracle
*
,
const
std
::
string
&
)
{
return
0
;
...
...
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