any_change =
false;
55 if(author.IsSetName()) {
56 switch(author.GetName().Which()) {
58any_change = s_CleanupNameStdBC(author.SetName().SetName(), fix_initials);
61 n= author.GetName().GetMl().size();
63 if(
n!= author.GetName().GetMl().size() ) {
71 n= author.GetName().GetStr().size();
73 if(
n!= author.GetName().GetStr().size() ) {
81 n= author.GetName().GetConsortium().size();
83 if(
n!= author.GetName().GetConsortium().size() ) {
105original_name->Assign( name );
109 boolupcaseinits =
false;
114 stringfirst_initials;
144string::size_type next_pos = 0;
145 while( next_pos <
first.length() ) {
147next_pos =
first.find_first_not_of(
" -", next_pos);
148 if( string::npos == next_pos )
break;
151first_initials +=
first[next_pos];
154next_pos =
first.find_first_of(
" -", next_pos);
155 if( string::npos == next_pos )
break;
157 if(
first[next_pos] ==
'-') {
158first_initials +=
'-';
166 const string&middle = name.
GetMiddle();
167string::size_type next_pos = 0;
168 while( next_pos < middle.length() ) {
170next_pos = middle.find_first_not_of(
" -", next_pos);
171 if( string::npos == next_pos )
break;
173 if(
isalpha( middle[next_pos] ) ) {
174first_initials += middle[next_pos];
177next_pos = middle.find_first_of(
" -", next_pos);
178 if( string::npos == next_pos )
break;
180 if( middle[next_pos] ==
'-') {
181first_initials +=
'-';
187 if(!first_initials.empty()) {
189first_initials.clear();
191}
else if(fix_initials) {
195string::size_type initials_first_good_idx = 0;
196 for( ; initials_first_good_idx < initials.length() &&
197initials_first_good_idx < first_initials.length() &&
198 toupper(initials[initials_first_good_idx]) ==
toupper(first_initials[initials_first_good_idx]) ;
199++initials_first_good_idx )
204 if( initials_first_good_idx > 0 ) {
205initials.erase( 0, initials_first_good_idx );
211 if( fix_initials && ! first_initials.empty() ) {
222string::const_iterator initials_iter = initials.begin();
224 for( ; initials_iter != initials.end(); ++initials_iter ) {
225 const charch = *initials_iter;
229new_initials +=
'-';
239 if( (initials_iter + 1) != initials.end()) {
240 const charnext_char = *(initials_iter + 1);
243new_initials +=
'.';
249 if( initials != new_initials ) {
250initials.swap(new_initials);
251new_initials.clear();
329name.
SetSuffix(initials.substr( initials.length() - 3 ) );
330initials.resize( initials.length() - 3 );
343 if(pos == 2 && temp.length() >= 5 && temp[1] ==
'.'&& temp [4] ==
'.') {
344name.
SetFirst(temp.substr(0, 1) +
'-'+ temp.substr(3, 1));
348 return(!original_name->Equals(name));
381 if(initials.find(
'.') ==
NPOS) {
386 #define EXTRACTSUFFIXFROMINITIALS( OLD, NEW ) \ 387 if( NStr::EndsWith(initials, OLD) ) { \ 388 initials.resize( initials.length() - strlen(OLD) ); \ 389 name.SetSuffix(NEW); \ 400 #undef EXTRACTSUFFIXFROMINITIALS 426 if(affil.
IsStr()) {
429 else if(affil.
IsStd()) {
455 const string*
str=
nullptr;
456 switch(name.
Which()) {
516 auto& std = alnames.SetStd();
517 autocleaner = [&rval, fix_initials](
CRef<CAuthor>& author) {
522std::for_each(std.begin(), std.end(), cleaner);
523 size_tbefore = std.size();
525std.erase(
std::remove_if(std.begin(), std.end(), em), std.end());
526 if(std.size() != before) {
539 for(
string& it :
names.SetStr()) {
547 if(
names.GetStr().empty()) {
559al.
SetNames().SetStr().push_back(
"?");
570list< string > &auth_list =
names.SetStr();
572auth_list.push_back(
"?");
588 switch(af.
Which()) {
596 #define CLEAN_AFFIL_MEMBER(x) \ 597 if (std.IsSet##x()) { \ 598 string& val = std.Set##x(); \ 599 rval |= CleanAndCompressJunk(val); \ 616 #undef CLEAN_AFFIL_MEMBER 631 stringoldsub = std.
GetSub();
void remove_if(Container &c, Predicate *__pred)
@Affil.hpp User-defined methods of the data storage class.
@Auth_list.hpp User-defined methods of the data storage class.
void ConvertMlToStandard(bool normalize_suffix=false)
static bool CleanupAffil(CAffil &af)
static void s_FixEtAl(CName_std &name)
static bool CleanupAuthList(CAuth_list &al, bool fix_initials=true)
static bool CleanupAuthor(CAuthor &author, bool fix_initials=true)
static bool IsEmpty(const CAuth_list::TAffil &affil)
static void ResetAuthorNames(CAuth_list::TNames &names)
static bool s_CleanupNameStdBC(CName_std &name, bool fix_initials)
static void s_ExtractSuffixFromInitials(CName_std &name)
@Name_std.hpp User-defined methods of the data storage class.
bool ExtractSuffixFromLastName()
static void FixSuffix(string &suffix)
class CStaticArrayMap<> provides access to a static array in much the same way as CStaticArraySet<>,...
#define CLEAN_AFFIL_MEMBER(x)
static const TStringPair bad_sfxs[]
CStaticArrayMap< string, string > TSuffixMap
#define EXTRACTSUFFIXFROMINITIALS(OLD, NEW)
SStaticPair< const char *, const char * > TStringPair
DEFINE_STATIC_ARRAY_MAP_WITH_COPY(TSuffixMap, sc_BadSuffixes, bad_sfxs)
static bool CleanAndCompressJunk(string &str)
bool CleanVisString(string &str)
bool CleanVisStringJunk(string &str, bool allow_ellipses)
bool Asn2gnbkCompressSpaces(string &val)
weird space compression from C Toolkit
bool CleanVisStringContainer(C &str_cont)
Include a standard set of the NCBI C++ Toolkit most basic headers.
static const struct name_t names[]
static void DLIST_NAME() init(DLIST_LIST_TYPE *list)
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
static const char * str(char *buf, int n)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string (in-place)
static SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)
Find the pattern in the string.
static bool EqualCase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-sensitive equality of a substring with another string.
static string & Replace(const string &src, const string &search, const string &replace, string &dst, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
static bool Equal(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2, ECase use_case=eCase)
Test for equality of a substring with another string.
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
const char *const kEmptyCStr
Empty "C" string (points to a '\0').
@ eTrunc_Begin
Truncate leading whitespace only.
bool IsSetAffil(void) const
author affiliation Check if a value has been assigned to Affil data member.
void SetCountry(const TCountry &value)
Assign a value to Country data member.
void SetSub(const TSub &value)
Assign a value to Sub data member.
bool IsSetPhone(void) const
Check if a value has been assigned to Phone data member.
const TAffil & GetAffil(void) const
Get the Affil member data.
bool IsSetStreet(void) const
street address, not ANSI Check if a value has been assigned to Street data member.
const TStr & GetStr(void) const
Get the variant data.
bool IsSetCity(void) const
Author Affiliation, City Check if a value has been assigned to City data member.
void SetAffil(TAffil &value)
Assign a value to Affil data member.
bool IsSetEmail(void) const
Check if a value has been assigned to Email data member.
const TName & GetName(void) const
Get the Name member data.
const TSub & GetSub(void) const
Get the Sub member data.
bool IsStr(void) const
Check if variant Str is selected.
TStr & SetStr(void)
Select the variant.
bool IsSetNames(void) const
Check if a value has been assigned to Names data member.
E_Choice Which(void) const
Which variant is currently selected.
void SetNames(TNames &value)
Assign a value to Names data member.
bool IsSetFax(void) const
Check if a value has been assigned to Fax data member.
bool IsSetDiv(void) const
Author Affiliation, Division Check if a value has been assigned to Div data member.
const TCountry & GetCountry(void) const
Get the Country member data.
const TStd & GetStd(void) const
Get the variant data.
bool IsSetName(void) const
Author, Primary or Secondary Check if a value has been assigned to Name data member.
const TNames & GetNames(void) const
Get the Names member data.
void ResetAffil(void)
Reset Affil data member.
bool IsStd(void) const
Check if variant Std is selected.
bool IsSetPostal_code(void) const
Check if a value has been assigned to Postal_code data member.
bool IsSetCountry(void) const
Author Affiliation, Country Check if a value has been assigned to Country data member.
bool IsSetAffil(void) const
Author Affiliation, Name Check if a value has been assigned to Affil data member.
TStd & SetStd(void)
Select the variant.
E_Choice Which(void) const
Which variant is currently selected.
bool IsSetSub(void) const
Author Affiliation, County Sub Check if a value has been assigned to Sub data member.
E_Choice Which(void) const
Which variant is currently selected.
const TStr & GetStr(void) const
Get the variant data.
void ResetLast(void)
Reset Last data member.
void SetInitials(const TInitials &value)
Assign a value to Initials data member.
bool IsSetSuffix(void) const
Jr, Sr, III Check if a value has been assigned to Suffix data member.
void ResetInitials(void)
Reset Initials data member.
const TInitials & GetInitials(void) const
Get the Initials member data.
void ResetFirst(void)
Reset First data member.
bool IsSetMiddle(void) const
Check if a value has been assigned to Middle data member.
void SetLast(const TLast &value)
Assign a value to Last data member.
bool IsSetFull(void) const
full name eg.
void SetFirst(const TFirst &value)
Assign a value to First data member.
bool IsSetInitials(void) const
first + middle initials Check if a value has been assigned to Initials data member.
bool IsSetTitle(void) const
Dr., Sister, etc Check if a value has been assigned to Title data member.
const TMl & GetMl(void) const
Get the variant data.
bool IsSetLast(void) const
Check if a value has been assigned to Last data member.
void SetMiddle(const TMiddle &value)
Assign a value to Middle data member.
const TMiddle & GetMiddle(void) const
Get the Middle member data.
const TConsortium & GetConsortium(void) const
Get the variant data.
void SetSuffix(const TSuffix &value)
Assign a value to Suffix data member.
const TSuffix & GetSuffix(void) const
Get the Suffix member data.
void ResetTitle(void)
Reset Title data member.
const TFirst & GetFirst(void) const
Get the First member data.
void ResetFull(void)
Reset Full data member.
void ResetMiddle(void)
Reset Middle data member.
const TLast & GetLast(void) const
Get the Last member data.
const TName & GetName(void) const
Get the variant data.
bool IsSetFirst(void) const
Check if a value has been assigned to First data member.
void ResetSuffix(void)
Reset Suffix data member.
@ e_Ml
MEDLINE name (semi-structured) eg. "Jones RM".
@ e_Consortium
consortium name
@ e_Str
unstructured name
@ e_not_set
No variant selected.
bool operator()(CRef< CAuthor > &cauth)
Template structure SStaticPair is simlified replacement of STL pair<> Main reason of introducing this...
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4