Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Libkissinference
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Klemm, Carl Philipp
Libkissinference
Commits
016d5b08
Commit
016d5b08
authored
1 year ago
by
uvos
Browse files
Options
Downloads
Patches
Plain Diff
Fix kiss_eis_to_relaxis swallowing serial operators and improve the bracket handling
parent
31e51ea2
Branches
main
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
test.cpp
+10
-0
10 additions, 0 deletions
test.cpp
translators.cpp
+46
-0
46 additions, 0 deletions
translators.cpp
with
56 additions
and
0 deletions
test.cpp
+
10
−
0
View file @
016d5b08
...
...
@@ -302,6 +302,16 @@ bool testTranslate()
free
(
cdc
);
free
(
relaxis
);
model
=
"rc-rc-rc"
;
cdc
=
kiss_eis_to_cdc
(
model
);
relaxis
=
kiss_eis_to_relaxis
(
model
);
std
::
cout
<<
"Eis: "
<<
model
<<
'\n'
;
std
::
cout
<<
"CDC: "
<<
cdc
<<
'\n'
;
std
::
cout
<<
"RelaxIS: "
<<
relaxis
<<
'\n'
;
free
(
cdc
);
free
(
relaxis
);
return
true
;
}
...
...
This diff is collapsed.
Click to expand it.
translators.cpp
+
46
−
0
View file @
016d5b08
...
...
@@ -200,6 +200,48 @@ static void replaceBraket(std::string& in, size_t start, size_t num)
}
static
bool
removeUnnededBracket
(
std
::
string
&
in
,
size_t
start_index
)
{
size_t
level
=
0
;
for
(
size_t
i
=
start_index
;
i
<
in
.
size
();
++
i
)
{
if
(
in
[
i
]
==
'('
)
{
++
level
;
}
else
if
(
level
==
0
)
{
if
(
in
[
i
]
==
'-'
)
break
;
else
if
(
in
[
i
]
==
')'
)
{
if
(
i
-
start_index
>
2
)
{
in
.
erase
(
i
,
1
);
in
.
erase
(
start_index
,
1
);
return
true
;
}
break
;
}
}
else
if
(
in
[
i
]
==
')'
)
{
--
level
;
}
}
return
false
;
}
static
void
removeUnnededBrackets
(
std
::
string
&
in
)
{
for
(
size_t
i
=
0
;
i
<
in
.
size
();
++
i
)
{
if
(
in
[
i
]
==
'('
&&
removeUnnededBracket
(
in
,
i
)
&&
i
>
0
)
--
i
;
}
}
char
*
kiss_eis_to_relaxis
(
const
char
*
in
)
{
char
*
workcstr
=
kiss_eis_to_cdc
(
in
);
...
...
@@ -222,6 +264,8 @@ char* kiss_eis_to_relaxis(const char* in)
out
.
pop_back
();
out
.
push_back
(
')'
);
--
level
;
if
(
level
%
2
==
0
)
out
.
push_back
(
'-'
);
}
else
{
...
...
@@ -241,6 +285,8 @@ char* kiss_eis_to_relaxis(const char* in)
if
(
out
.
back
()
==
'-'
)
out
.
pop_back
();
removeUnnededBrackets
(
out
);
return
strdup
(
out
.
c_str
());
}
...
...
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