Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WCCL
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Analysers
WCCL
Commits
9ad17870
Commit
9ad17870
authored
14 years ago
by
Adam Wardynski
Browse files
Options
Downloads
Patches
Plain Diff
Add some extra formatting functions
parent
1bd51e39
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libwccl/ops/formatters.cpp
+10
-14
10 additions, 14 deletions
libwccl/ops/formatters.cpp
libwccl/ops/formatters.h
+168
-23
168 additions, 23 deletions
libwccl/ops/formatters.h
with
178 additions
and
37 deletions
libwccl/ops/formatters.cpp
+
10
−
14
View file @
9ad17870
...
...
@@ -7,26 +7,24 @@ namespace Wccl {
std
::
string
UnaryFunctionFormatter
::
to_raw_string
(
const
FunctionBase
&
f
,
const
FunctionBase
&
arg_
exp
r
,
const
std
::
string
&
arg_
st
r
,
const
char
*
open_bracket
,
const
char
*
close_bracket
)
{
std
::
stringstream
ss
;
ss
<<
f
.
raw_operator_name
()
<<
open_bracket
<<
arg_expr
.
to_raw_string
()
<<
close_bracket
;
ss
<<
f
.
raw_operator_name
()
<<
open_bracket
<<
arg_str
<<
close_bracket
;
return
ss
.
str
();
}
std
::
string
UnaryFunctionFormatter
::
to_string
(
const
Corpus2
::
Tagset
&
tagset
,
const
FunctionBase
&
f
,
const
FunctionBase
&
arg_
exp
r
,
const
std
::
string
&
arg_
st
r
,
const
char
*
open_bracket
,
const
char
*
close_bracket
)
{
std
::
stringstream
ss
;
ss
<<
f
.
operator_name
(
tagset
)
<<
open_bracket
<<
arg_expr
.
to_string
(
tagset
)
<<
close_bracket
;
ss
<<
f
.
operator_name
(
tagset
)
<<
open_bracket
<<
arg_str
<<
close_bracket
;
return
ss
.
str
();
}
...
...
@@ -35,23 +33,21 @@ std::string UnaryFunctionFormatter::to_string(
std
::
string
BinaryFunctionFormatter
::
to_string
(
const
Corpus2
::
Tagset
&
tagset
,
const
FunctionBase
&
f
,
const
FunctionBase
&
arg1_
exp
r
,
const
FunctionBase
&
arg2_
exp
r
)
const
std
::
string
&
arg1_
st
r
,
const
std
::
string
&
arg2_
st
r
)
{
std
::
stringstream
ss
;
ss
<<
f
.
operator_name
(
tagset
)
<<
"("
<<
arg1_expr
.
to_string
(
tagset
)
<<
", "
<<
arg2_expr
.
to_string
(
tagset
)
<<
")"
;
ss
<<
f
.
operator_name
(
tagset
)
<<
"("
<<
arg1_str
<<
", "
<<
arg2_str
<<
")"
;
return
ss
.
str
();
}
std
::
string
BinaryFunctionFormatter
::
to_raw_string
(
const
FunctionBase
&
f
,
const
FunctionBase
&
arg1_
exp
r
,
const
FunctionBase
&
arg2_
exp
r
)
const
std
::
string
&
arg1_
st
r
,
const
std
::
string
&
arg2_
st
r
)
{
std
::
stringstream
ss
;
ss
<<
f
.
raw_operator_name
()
<<
"("
<<
arg1_expr
.
to_raw_string
()
<<
", "
<<
arg2_expr
.
to_raw_string
()
<<
")"
;
ss
<<
f
.
raw_operator_name
()
<<
"("
<<
arg1_str
<<
", "
<<
arg2_str
<<
")"
;
return
ss
.
str
();
}
...
...
This diff is collapsed.
Click to expand it.
libwccl/ops/formatters.h
+
168
−
23
View file @
9ad17870
...
...
@@ -10,33 +10,74 @@ namespace Wccl {
*/
struct
UnaryFunctionFormatter
{
/**
* String representation of an unary function.
/**
* @returns String representation of an unary function.
* It is in form of
* operator_name(arg_str)
* although the open and close brackets can be changed
* (some operators use [])
*/
static
std
::
string
to_string
(
const
Corpus2
::
Tagset
&
tagset
,
const
FunctionBase
&
f
,
const
std
::
string
&
arg_str
,
const
char
*
open_bracket
=
"("
,
const
char
*
close_bracket
=
")"
);
/**
* @returns String representation of an unary function.
* It is in form of
* operator_name(argument_expression_string)
* although the open and close brackets can be changed
* (some operators use [])
*/
* operator_name(argument_expression_string)
* although the open and close brackets can be changed
* (some operators use [])
*/
static
std
::
string
to_string
(
const
Corpus2
::
Tagset
&
tagset
,
const
FunctionBase
&
f
,
const
FunctionBase
&
arg_expr
,
const
char
*
open_bracket
=
"("
,
const
char
*
close_bracket
=
")"
)
{
return
to_string
(
tagset
,
f
,
arg_expr
.
to_string
(
tagset
),
open_bracket
,
close_bracket
);
}
/**
* @returns Raw string representation of an unary function.
* Does not require tagset, may contain internal info
* and/or be incomplete. It is in form of
* raw_operator_name(arg_str)
* although the open and close brackets can be changed
* (some operators use [])
*/
static
std
::
string
to_raw_string
(
const
FunctionBase
&
f
,
const
std
::
string
&
arg_str
,
const
char
*
open_bracket
=
"("
,
const
char
*
close_bracket
=
")"
);
/**
* Raw string representation of an unary function.
/**
*
@returns
Raw string representation of an unary function.
* Does not require tagset, may contain internal info
* and/or be incomplete. It is in form of
* raw_operator_name(raw_argument_expression_string)
* although the open and close brackets can be changed
* (some operators use [])
*/
* raw_operator_name(raw_argument_expression_string)
* although the open and close brackets can be changed
* (some operators use [])
*/
static
std
::
string
to_raw_string
(
const
FunctionBase
&
f
,
const
FunctionBase
&
arg_expr
,
const
char
*
open_bracket
=
"("
,
const
char
*
close_bracket
=
")"
);
const
char
*
close_bracket
=
")"
)
{
return
to_raw_string
(
f
,
arg_expr
.
to_raw_string
(),
open_bracket
,
close_bracket
);
}
};
/**
...
...
@@ -44,27 +85,131 @@ struct UnaryFunctionFormatter
*/
struct
BinaryFunctionFormatter
{
/**
* String representation of a binary function.
/**
* @returns String representation of a binary function.
* It is in form of
* operator_name(arg1_str, arg2_str)
*/
static
std
::
string
to_string
(
const
Corpus2
::
Tagset
&
tagset
,
const
FunctionBase
&
f
,
const
std
::
string
&
arg1_str
,
const
std
::
string
&
arg2_str
);
/**
* @returns String representation of a binary function.
* It is in form of
* operator_name(arg1_
expr_string
, arg2_expr_string)
*/
* operator_name(arg1_
str
, arg2_expr_string)
*/
static
std
::
string
to_string
(
const
Corpus2
::
Tagset
&
tagset
,
const
FunctionBase
&
f
,
const
std
::
string
&
arg1_str
,
const
FunctionBase
&
arg2_expr
)
{
return
to_string
(
tagset
,
f
,
arg1_str
,
arg2_expr
.
to_string
(
tagset
));
}
/**
* @returns String representation of a binary function.
* It is in form of
* operator_name(arg1_expr_string, arg2_str)
*/
static
std
::
string
to_string
(
const
Corpus2
::
Tagset
&
tagset
,
const
FunctionBase
&
f
,
const
FunctionBase
&
arg1_expr
,
const
std
::
string
&
arg2_str
)
{
return
to_string
(
tagset
,
f
,
arg1_expr
.
to_string
(
tagset
),
arg2_str
);
}
/**
* @returns String representation of a binary function.
* It is in form of
* operator_name(arg1_expr_string, arg2_expr_string)
*/
static
std
::
string
to_string
(
const
Corpus2
::
Tagset
&
tagset
,
const
FunctionBase
&
f
,
const
FunctionBase
&
arg1_expr
,
const
FunctionBase
&
arg2_expr
)
{
return
to_string
(
tagset
,
f
,
arg1_expr
.
to_string
(
tagset
),
arg2_expr
.
to_string
(
tagset
));
}
/**
* @returns Raw string representation of a binary function.
* Does not require tagset, may contain internal info
* and/or be incomplete. It is in form of
* raw_op_name(arg1_str, arg2_str)
*/
static
std
::
string
to_raw_string
(
const
FunctionBase
&
f
,
const
std
::
string
&
arg1_str
,
const
std
::
string
&
arg2_str
);
/**
* @returns Raw string representation of a binary function.
* Does not require tagset, may contain internal info
* and/or be incomplete. It is in form of
* raw_op_name(arg1_str, raw_arg2_expr_string)
*/
static
std
::
string
to_raw_string
(
const
FunctionBase
&
f
,
const
std
::
string
&
arg1_str
,
const
FunctionBase
&
arg2_expr
)
{
return
to_raw_string
(
f
,
arg1_str
,
arg2_expr
.
to_raw_string
());
}
/**
* @returns Raw string representation of a binary function.
* Does not require tagset, may contain internal info
* and/or be incomplete. It is in form of
* raw_op_name(raw_arg1_expr_string, arg1_str)
*/
static
std
::
string
to_raw_string
(
const
FunctionBase
&
f
,
const
FunctionBase
&
arg1_expr
,
const
FunctionBase
&
arg2_expr
);
const
std
::
string
&
arg2_str
)
{
return
to_raw_string
(
f
,
arg1_expr
.
to_raw_string
(),
arg2_str
);
}
/**
* Raw string representation of a binary function.
/**
*
@returns
Raw string representation of a binary function.
* Does not require tagset, may contain internal info
* and/or be incomplete. It is in form of
* raw_op_name(raw_arg1_expr_string, raw_arg2_expr_string)
*/
* raw_op_name(raw_arg1_expr_string, raw_arg2_expr_string)
*/
static
std
::
string
to_raw_string
(
const
FunctionBase
&
f
,
const
FunctionBase
&
arg1_expr
,
const
FunctionBase
&
arg2_expr
);
const
FunctionBase
&
arg2_expr
)
{
return
to_raw_string
(
f
,
arg1_expr
.
to_raw_string
(),
arg2_expr
.
to_raw_string
());
}
};
}
/* end ns Wccl */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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