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
5c114f0c
Commit
5c114f0c
authored
5 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Made it impossible to do a splitword on splitedwords or to modify splitedwords
parent
8946a076
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
reading_machine/include/Action.hpp
+2
-1
2 additions, 1 deletion
reading_machine/include/Action.hpp
reading_machine/src/Action.cpp
+24
-2
24 additions, 2 deletions
reading_machine/src/Action.cpp
reading_machine/src/Transition.cpp
+3
-1
3 additions, 1 deletion
reading_machine/src/Transition.cpp
with
29 additions
and
4 deletions
reading_machine/include/Action.hpp
+
2
−
1
View file @
5c114f0c
...
...
@@ -58,11 +58,12 @@ class Action
static
Action
setRoot
();
static
Action
updateIds
();
static
Action
endWord
();
static
Action
assertIdIsEmpty
();
static
Action
attach
(
Object
governorObject
,
int
governorIndex
,
Object
dependentObject
,
int
dependentIndex
);
static
Action
addCurCharToCurWord
();
static
Action
ignoreCurrentCharacter
();
static
Action
consumeCharacterIndex
(
std
::
string
consumed
);
static
Action
setMultiwordId
(
int
multiwordSize
);
static
Action
setMultiwordId
s
(
int
multiwordSize
);
};
#endif
This diff is collapsed.
Click to expand it.
reading_machine/src/Action.cpp
+
24
−
2
View file @
5c114f0c
...
...
@@ -48,16 +48,20 @@ Action Action::moveWordIndex(int movement)
return
{
Type
::
MoveWord
,
apply
,
undo
,
appliable
};
}
Action
Action
::
setMultiwordId
(
int
multiwordSize
)
Action
Action
::
setMultiwordId
s
(
int
multiwordSize
)
{
auto
apply
=
[
multiwordSize
](
Config
&
config
,
Action
&
a
)
{
addHypothesisRelative
(
Config
::
idColName
,
Object
::
Buffer
,
0
,
fmt
::
format
(
"{}-{}"
,
config
.
getCurrentWordId
()
+
1
,
config
.
getCurrentWordId
()
+
multiwordSize
)).
apply
(
config
,
a
);
for
(
int
i
=
0
;
i
<
multiwordSize
;
i
++
)
addHypothesisRelative
(
Config
::
idColName
,
Object
::
Buffer
,
i
+
1
,
fmt
::
format
(
"{}"
,
config
.
getCurrentWordId
()
+
1
+
i
)).
apply
(
config
,
a
);
};
auto
undo
=
[](
Config
&
config
,
Action
&
)
auto
undo
=
[
multiwordSize
](
Config
&
config
,
Action
&
)
{
config
.
getLastNotEmpty
(
Config
::
idColName
,
config
.
getWordIndex
())
=
""
;
for
(
int
i
=
0
;
i
<
multiwordSize
;
i
++
)
config
.
getLastNotEmpty
(
Config
::
idColName
,
config
.
getWordIndex
()
+
1
+
i
)
=
""
;
};
auto
appliable
=
[](
const
Config
&
,
const
Action
&
)
...
...
@@ -366,6 +370,24 @@ Action Action::ignoreCurrentCharacter()
return
{
Type
::
MoveChar
,
apply
,
undo
,
appliable
};
}
Action
Action
::
assertIdIsEmpty
()
{
auto
apply
=
[](
Config
&
,
Action
&
)
{
};
auto
undo
=
[](
Config
&
,
Action
&
)
{
};
auto
appliable
=
[](
const
Config
&
config
,
const
Action
&
)
{
return
util
::
isEmpty
(
config
.
getAsFeature
(
Config
::
idColName
,
config
.
getWordIndex
()));
};
return
{
Type
::
Check
,
apply
,
undo
,
appliable
};
}
Action
Action
::
addCurCharToCurWord
()
{
auto
apply
=
[](
Config
&
config
,
Action
&
a
)
...
...
This diff is collapsed.
Click to expand it.
reading_machine/src/Transition.cpp
+
3
−
1
View file @
5c114f0c
...
...
@@ -164,6 +164,7 @@ void Transition::initEndWord()
void
Transition
::
initAddCharToWord
()
{
sequence
.
emplace_back
(
Action
::
assertIdIsEmpty
());
sequence
.
emplace_back
(
Action
::
addLinesIfNeeded
(
0
));
sequence
.
emplace_back
(
Action
::
addCurCharToCurWord
());
sequence
.
emplace_back
(
Action
::
moveCharacterIndex
(
1
));
...
...
@@ -190,11 +191,12 @@ void Transition::initAddCharToWord()
void
Transition
::
initSplitWord
(
std
::
vector
<
std
::
string
>
words
)
{
auto
&
consumedWord
=
words
[
0
];
sequence
.
emplace_back
(
Action
::
assertIdIsEmpty
());
sequence
.
emplace_back
(
Action
::
addLinesIfNeeded
(
words
.
size
()));
sequence
.
emplace_back
(
Action
::
consumeCharacterIndex
(
consumedWord
));
for
(
unsigned
int
i
=
0
;
i
<
words
.
size
();
i
++
)
sequence
.
emplace_back
(
Action
::
addHypothesisRelative
(
"FORM"
,
Action
::
Object
::
Buffer
,
i
,
words
[
i
]));
sequence
.
emplace_back
(
Action
::
setMultiwordId
(
words
.
size
()
-
1
));
sequence
.
emplace_back
(
Action
::
setMultiwordId
s
(
words
.
size
()
-
1
));
cost
=
[
words
](
const
Config
&
config
)
{
...
...
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