Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
corpus2
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
corpus2
Commits
4e5e89b3
Commit
4e5e89b3
authored
14 years ago
by
ilor
Browse files
Options
Downloads
Patches
Plain Diff
plural functions in pwrutils
parent
a20b1393
Branches
Branches containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
libpwrutils/CMakeLists.txt
+1
-0
1 addition, 0 deletions
libpwrutils/CMakeLists.txt
libpwrutils/plural.cpp
+80
-0
80 additions, 0 deletions
libpwrutils/plural.cpp
libpwrutils/plural.h
+43
-0
43 additions, 0 deletions
libpwrutils/plural.h
with
124 additions
and
0 deletions
libpwrutils/CMakeLists.txt
+
1
−
0
View file @
4e5e89b3
...
...
@@ -29,6 +29,7 @@ SET(libpwrutils_STAT_SRC
exception.cpp
whitespace.cpp
pathsearch.cpp
plural.cpp
util.cpp
)
...
...
This diff is collapsed.
Click to expand it.
libpwrutils/plural.cpp
0 → 100644
+
80
−
0
View file @
4e5e89b3
/*
Copyright (C) 2010 Tomasz Śniatowski, Adam Radziszewski
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.
See the LICENSE and COPYING files for more details.
*/
#include
<libpwrutils/plural.h>
#include
<sstream>
namespace
PwrNlp
{
std
::
string
enpl
(
int
amount
,
const
std
::
string
&
sg
)
{
if
(
amount
==
1
)
{
return
sg
;
}
else
{
return
sg
+
"s"
;
}
}
std
::
string
enpln
(
int
amount
,
const
std
::
string
&
sg
)
{
std
::
stringstream
ss
;
ss
<<
amount
<<
" "
<<
enpl
(
amount
,
sg
);
return
ss
.
str
();
}
std
::
string
enpl
(
int
amount
,
const
std
::
string
&
sg
,
const
std
::
string
&
pl
)
{
if
(
amount
==
1
)
{
return
sg
;
}
else
{
return
pl
;
}
}
std
::
string
enpln
(
int
amount
,
const
std
::
string
&
sg
,
const
std
::
string
&
pl
)
{
std
::
stringstream
ss
;
ss
<<
amount
<<
" "
<<
enpl
(
amount
,
sg
,
pl
);
return
ss
.
str
();
}
std
::
string
plpl
(
int
amount
,
const
std
::
string
&
gen0
,
const
std
::
string
&
nom1
,
const
std
::
string
&
acc2
)
{
if
(
amount
==
1
)
{
return
nom1
;
}
else
{
amount
%=
100
;
if
(
amount
>
10
&&
amount
<
20
)
{
return
gen0
;
}
else
{
amount
%=
10
;
if
(
amount
==
2
||
amount
==
3
||
amount
==
4
)
{
return
acc2
;
}
else
{
return
gen0
;
}
}
}
}
std
::
string
plpln
(
int
amount
,
const
std
::
string
&
gen0
,
const
std
::
string
&
nom1
,
const
std
::
string
&
acc2
)
{
std
::
stringstream
ss
;
ss
<<
amount
<<
" "
<<
plpl
(
amount
,
gen0
,
nom1
,
acc2
);
return
ss
.
str
();
}
}
/* end namespace PwrNlp */
This diff is collapsed.
Click to expand it.
libpwrutils/plural.h
0 → 100644
+
43
−
0
View file @
4e5e89b3
/*
Copyright (C) 2010 Tomasz Śniatowski, Adam Radziszewski
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.
See the LICENSE and COPYING files for more details.
*/
#ifndef PWRNLP_PLURAL_H
#define PWRNLP_PLURAL_H
#include
<string>
namespace
PwrNlp
{
/// Pluralize sg according to amount, regular English plural
std
::
string
enpl
(
int
amount
,
const
std
::
string
&
sg
);
/// Pluralize (English), output the number and the pluralized word
std
::
string
enpln
(
int
amount
,
const
std
::
string
&
sg
);
/// Pluralize according to amount, custom English-style plural
std
::
string
enpl
(
int
amount
,
const
std
::
string
&
sg
,
const
std
::
string
&
pl
);
/// Pluralize (English), output the number and the pluralized word
std
::
string
enpln
(
int
amount
,
const
std
::
string
&
sg
,
const
std
::
string
&
pl
);
/// Pluralize according to amount, Polish plural
std
::
string
plpl
(
int
amount
,
const
std
::
string
&
gen0
,
const
std
::
string
&
nom1
,
const
std
::
string
&
acc2
);
/// Pluralize (Polish) output the number and the pluralized word
std
::
string
plpln
(
int
amount
,
const
std
::
string
&
gen0
,
const
std
::
string
&
nom1
,
const
std
::
string
&
acc2
);
}
/* end ns PwrNlp */
#endif // PWRNLP_PATHSEARCH_H
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