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
caaca1a7
Commit
caaca1a7
authored
4 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
AddToHypothesis is now sorted
parent
1baa7d2a
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
common/include/util.hpp
+11
-0
11 additions, 0 deletions
common/include/util.hpp
reading_machine/src/Action.cpp
+14
-9
14 additions, 9 deletions
reading_machine/src/Action.cpp
with
25 additions
and
9 deletions
common/include/util.hpp
+
11
−
0
View file @
caaca1a7
...
...
@@ -79,6 +79,17 @@ bool doIfNameMatch(const std::regex & reg, std::string_view name, const std::fun
bool
choiceWithProbability
(
float
probability
);
template
<
typename
T
>
std
::
string
join
(
const
std
::
string
&
delim
,
const
std
::
vector
<
T
>
elems
)
{
std
::
string
result
;
for
(
unsigned
int
i
=
0
;
i
<
elems
.
size
();
i
++
)
result
=
fmt
::
format
(
"{}{}{}"
,
result
,
elems
[
i
],
i
==
elems
.
size
()
-
1
?
""
:
delim
);
return
result
;
}
};
template
<
>
...
...
This diff is collapsed.
Click to expand it.
reading_machine/src/Action.cpp
+
14
−
9
View file @
caaca1a7
...
...
@@ -147,18 +147,23 @@ Action Action::addToHypothesis(const std::string & colName, std::size_t lineInde
{
auto
apply
=
[
colName
,
lineIndex
,
addition
](
Config
&
config
,
Action
&
)
{
auto
&
current
=
config
.
getLastNotEmptyHyp
(
colName
,
lineIndex
);
current
=
util
::
isEmpty
(
current
)
?
addition
:
current
.
get
()
+
'|'
+
addition
;
auto
currentElems
=
util
::
split
(
config
.
getLastNotEmptyHypConst
(
colName
,
lineIndex
).
get
(),
'|'
);
currentElems
.
emplace_back
(
addition
);
std
::
sort
(
currentElems
.
begin
(),
currentElems
.
end
());
config
.
getLastNotEmptyHyp
(
colName
,
lineIndex
)
=
util
::
join
(
"|"
,
currentElems
);
};
auto
undo
=
[
colName
,
lineIndex
](
Config
&
config
,
Action
&
)
auto
undo
=
[
colName
,
lineIndex
,
addition
](
Config
&
config
,
Action
&
)
{
std
::
string
newValue
=
config
.
getLastNotEmpty
(
colName
,
lineIndex
);
while
(
!
newValue
.
empty
()
and
newValue
.
back
()
==
'|'
)
newValue
.
pop_back
();
if
(
!
newValue
.
empty
())
newValue
.
pop_back
();
config
.
getLastNotEmpty
(
colName
,
lineIndex
)
=
newValue
;
auto
curElems
=
util
::
split
(
config
.
getLastNotEmptyHypConst
(
colName
,
lineIndex
).
get
(),
'|'
);
std
::
vector
<
std
::
string
>
newElems
;
for
(
auto
&
elem
:
curElems
)
if
(
elem
!=
addition
)
newElems
.
emplace_back
(
elem
);
config
.
getLastNotEmptyHyp
(
colName
,
lineIndex
)
=
util
::
join
(
"|"
,
newElems
);
};
auto
appliable
=
[
colName
,
lineIndex
,
addition
](
const
Config
&
config
,
const
Action
&
)
...
...
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