NCBI C++ ToolKit
Macros | Functions | Variables
pub_tests.cpp File Reference
#include <ncbi_pch.hpp>
#include <sstream>
#include <objects/general/User_object.hpp>
#include <objects/seq/Pubdesc.hpp>
#include <objects/pub/Pub.hpp>
#include <objects/pub/Pub_equiv.hpp>
#include <objects/biblio/Cit_gen.hpp>
#include <objects/biblio/Cit_sub.hpp>
#include <objects/biblio/Cit_art.hpp>
#include <objects/biblio/Cit_jour.hpp>
#include <objects/biblio/Cit_let.hpp>
#include <objects/biblio/Cit_book.hpp>
#include <objects/biblio/Cit_pat.hpp>
#include <objects/biblio/Cit_proc.hpp>
#include <objects/biblio/Title.hpp>
#include <objects/biblio/Auth_list.hpp>
#include <objects/biblio/Author.hpp>
#include <objects/biblio/Affil.hpp>
#include <objects/biblio/Imprint.hpp>
#include <objects/general/Name_std.hpp>
#include <objects/general/Object_id.hpp>
#include <objects/general/Person_id.hpp>
#include <objects/submit/Submit_block.hpp>
#include <objects/submit/Contact_info.hpp>
#include <corelib/ncbistre.hpp>
#include <objmgr/seqdesc_ci.hpp>
#include "discrepancy_core.hpp"
+ Include dependency graph for pub_tests.cpp:

Go to the source code of this file.

Go to the SVN repository for this file.

Macros

#define ADD_TO_AFFIL_SUMMARY(Fieldname)
 
#define REPORT_CITSUBAFFIL_CONFLICT(order, field, alias)
 

Functions

 USING_SCOPE (objects)
 
string GetAuthorString (const CName_std &name_std)
 
string GetAuthorString (const CAuthor &author)
 
string GetAuthorString (const CAuth_list &auth_list)
 
void GetPubTitleAndAuthors (const CPub &pub, string &title, string &authors)
 
void GetPubTitleAndAuthors (const CPubdesc &pubdesc, string &title, string &authors)
 
bool IsPubUnpublished (const CImprint &imp)
 
bool IsPubUnpublished (const CCit_jour &journal)
 
bool IsPubUnpublished (const CCit_book &book)
 
bool IsPubUnpublished (const CCit_proc &proc)
 
bool IsPubUnpublished (const CCit_let &let)
 
bool IsPubUnpublished (const CPub &pub)
 
bool HasUnpubWithoutTitle (const CPubdesc &pubdesc)
 
bool HasNoAffiliation (const CAffil &affil)
 
bool IsCitSubMissingAffiliation (const CPubdesc &pubdesc)
 
string SummarizeAffiliation (const CAffil::C_Std &affil)
 
string SummarizeAffiliation (const CAffil &affil)
 
static int RemoveConsortium (CAuth_list &authors)
 
static const CCit_subGetCitSubFromPub (const CPub &pub)
 
static bool AffilStreetEndsWith (const string &street, const string &tail)
 
static bool AffilStreetContainsDup (const CAffil &affil)
 
static bool RemoveAffilStreetEnd (string &street, const string &tail, bool country)
 
static bool RemoveAffilDup (CCit_sub *cit_sub)
 
static bool IsValidStateAbbreviation (const string &state)
 
static bool ReplaceStateAbbreviation (CAffil *affil)
 
static bool IsCapNameCorrect (const string &name)
 
static bool IsCapInitialsCorrect (const string &initials)
 
static bool FixCapitalization (string &name, bool apostroph)
 
static bool FixCapitalization (CAuth_list *auth_list)
 

Variables

const string kTitleAuthorConflictStart = "[n] articles have title '"
 
const string kTitleAuthorConflictEnd = "' but do not have the same author list"
 
static constexpr CDiscrepancyCaseProps s_testcase_props_TITLE_AUTHOR_CONFLICT = { CDiscrepancyVisitorImpl<eTestNames:: TITLE_AUTHOR_CONFLICT >::Create, eTestTypes:: DESC , eTestNames:: TITLE_AUTHOR_CONFLICT , "TITLE_AUTHOR_CONFLICT" , "Publications with the same titles should have the same authors" , eDisc | eOncaller | eSmart | eFatal , nullptr }
 
static const char * kTitleAuthorConflict = "Publication Title/Author Inconsistencies"
 
static constexpr CDiscrepancyCaseProps s_testcase_props_UNPUB_PUB_WITHOUT_TITLE = { CDiscrepancyVisitorImpl<eTestNames:: UNPUB_PUB_WITHOUT_TITLE >::Create, eTestTypes:: PUBDESC , eTestNames:: UNPUB_PUB_WITHOUT_TITLE , "UNPUB_PUB_WITHOUT_TITLE" , "Unpublished pubs should have titles" , eDisc | eOncaller | eSubmitter | eSmart | eBig | eFatal , nullptr }
 
static constexpr CDiscrepancyCaseProps s_testcase_props_MISSING_AFFIL = { CDiscrepancyVisitorImpl<eTestNames:: MISSING_AFFIL >::Create, eTestTypes:: PUBDESC , eTestNames:: MISSING_AFFIL , "MISSING_AFFIL" , "Missing affiliation" , eDisc | eOncaller | eFatal , nullptr }
 
const string kCitSubSummary = "Citsub affiliation conflicts found"
 
const string kSummaries = "summaries"
 
static constexpr CDiscrepancyCaseProps s_testcase_props_CITSUBAFFIL_CONFLICT = { CDiscrepancyVisitorImpl<eTestNames:: CITSUBAFFIL_CONFLICT >::Create, eTestTypes:: AUTHORS , eTestNames:: CITSUBAFFIL_CONFLICT , "CITSUBAFFIL_CONFLICT" , "All Cit-subs should have identical affiliations" , eDisc | eOncaller | eSmart | eFatal , nullptr }
 
static constexpr CDiscrepancyCaseProps s_testcase_props_SUBMITBLOCK_CONFLICT = { CDiscrepancyVisitorImpl<eTestNames:: SUBMITBLOCK_CONFLICT >::Create, eTestTypes:: SUBMIT , eTestNames:: SUBMITBLOCK_CONFLICT , "SUBMITBLOCK_CONFLICT" , "Records should have identical submit-blocks" , eDisc | eOncaller | eSmart , nullptr }
 
static constexpr CDiscrepancyCaseProps s_testcase_props_CONSORTIUM = { CDiscrepancyVisitorImpl<eTestNames:: CONSORTIUM >::Create, eTestTypes:: AUTHORS , eTestNames:: CONSORTIUM , "CONSORTIUM" , "Submitter blocks and publications have consortiums" , eOncaller , nullptr }
 
const string kMissingAuthorsName = "[n] pub[s] missing author\'s first or last name"
 
static constexpr CDiscrepancyCaseProps s_testcase_props_CHECK_AUTH_NAME = { CDiscrepancyVisitorImpl<eTestNames:: CHECK_AUTH_NAME >::Create, eTestTypes:: AUTHORS , eTestNames:: CHECK_AUTH_NAME , "CHECK_AUTH_NAME" , "Missing authors or first/last author's names" , eDisc | eOncaller | eSubmitter | eSmart , nullptr }
 
static constexpr CDiscrepancyCaseProps s_testcase_props_CITSUB_AFFIL_DUP_TEXT = { CDiscrepancyVisitorImpl<eTestNames:: CITSUB_AFFIL_DUP_TEXT >::Create, eTestTypes:: PUBDESC , eTestNames:: CITSUB_AFFIL_DUP_TEXT , "CITSUB_AFFIL_DUP_TEXT" , "Cit-sub affiliation street contains text from other affiliation fields" , eOncaller , nullptr }
 
static pair< string, stringus_state_abbreviations []
 
static size_t kNumOfAbbreviations = ArraySize(us_state_abbreviations)
 
static constexpr CDiscrepancyCaseProps s_testcase_props_USA_STATE = { CDiscrepancyVisitorImpl<eTestNames:: USA_STATE >::Create, eTestTypes:: PUBDESC , eTestNames:: USA_STATE , "USA_STATE" , "For country USA, state should be present and abbreviated" , eDisc | eOncaller | eSmart , nullptr }
 
static const string kIncorrectCap = "[n] pub[s] [has] incorrect author capitalization"
 
static constexpr CDiscrepancyCaseProps s_testcase_props_CHECK_AUTH_CAPS = { CDiscrepancyVisitorImpl<eTestNames:: CHECK_AUTH_CAPS >::Create, eTestTypes:: AUTHORS , eTestNames:: CHECK_AUTH_CAPS , "CHECK_AUTH_CAPS" , "Check for correct capitalization in author names" , eDisc | eOncaller | eSmart , nullptr }
 

Macro Definition Documentation

◆ ADD_TO_AFFIL_SUMMARY

#define ADD_TO_AFFIL_SUMMARY (   Fieldname)
Value:
if(affil.IsSet##Fieldname() && !NStr::IsBlank(affil.Get##Fieldname())) { \
if (!NStr::IsBlank(rval)) { \
rval += ", "; \
} \
rval += affil.Get##Fieldname(); \
}
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106

Definition at line 440 of file pub_tests.cpp.

◆ REPORT_CITSUBAFFIL_CONFLICT

#define REPORT_CITSUBAFFIL_CONFLICT (   order,
  field,
  alias 
)
Value:
if (m_Objs[#field].GetMap().size() > 1) {\
for (const auto& it : m_Objs[#field].GetMap()) {\
string two = "[n] affiliation[s] [has] "#alias" value '" + it.first + "'";\
for (auto& robj : m_Objs[#field][it.first].GetObjects()) {\
out[kCitSubSummary]["[*"#order"*]Affiliations have different values for "#alias][two].Ext().Add(*robj, false);\
}\
}\
}
const struct ncbi::grid::netcache::search::fields::SIZE size
const string kCitSubSummary
Definition: pub_tests.cpp:480

Function Documentation

◆ AffilStreetContainsDup()

static bool AffilStreetContainsDup ( const CAffil affil)
static

◆ AffilStreetEndsWith()

static bool AffilStreetEndsWith ( const string street,
const string tail 
)
static

Definition at line 704 of file pub_tests.cpp.

References NStr::EndsWith(), NStr::eNocase, ispunct(), and isspace().

Referenced by AffilStreetContainsDup(), and RemoveAffilStreetEnd().

◆ FixCapitalization() [1/2]

static bool FixCapitalization ( CAuth_list auth_list)
static

◆ FixCapitalization() [2/2]

static bool FixCapitalization ( string name,
bool  apostroph 
)
static

◆ GetAuthorString() [1/3]

string GetAuthorString ( const CAuth_list auth_list)

◆ GetAuthorString() [2/3]

string GetAuthorString ( const CAuthor author)

◆ GetAuthorString() [3/3]

string GetAuthorString ( const CName_std name_std)

Definition at line 69 of file pub_tests.cpp.

References NStr::IsBlank().

Referenced by GetAuthorString(), and GetPubTitleAndAuthors().

◆ GetCitSubFromPub()

static const CCit_sub* GetCitSubFromPub ( const CPub pub)
static

◆ GetPubTitleAndAuthors() [1/2]

void GetPubTitleAndAuthors ( const CPub pub,
string title,
string authors 
)

◆ GetPubTitleAndAuthors() [2/2]

void GetPubTitleAndAuthors ( const CPubdesc pubdesc,
string title,
string authors 
)

◆ HasNoAffiliation()

bool HasNoAffiliation ( const CAffil affil)

◆ HasUnpubWithoutTitle()

bool HasUnpubWithoutTitle ( const CPubdesc pubdesc)

◆ IsCapInitialsCorrect()

static bool IsCapInitialsCorrect ( const string initials)
static

Definition at line 1104 of file pub_tests.cpp.

References isalpha(), and islower().

Referenced by FixCapitalization().

◆ IsCapNameCorrect()

static bool IsCapNameCorrect ( const string name)
static

◆ IsCitSubMissingAffiliation()

bool IsCitSubMissingAffiliation ( const CPubdesc pubdesc)

◆ IsPubUnpublished() [1/6]

bool IsPubUnpublished ( const CCit_book book)

◆ IsPubUnpublished() [2/6]

bool IsPubUnpublished ( const CCit_jour journal)

Definition at line 274 of file pub_tests.cpp.

References IsPubUnpublished(), and journal().

◆ IsPubUnpublished() [3/6]

bool IsPubUnpublished ( const CCit_let let)

◆ IsPubUnpublished() [4/6]

bool IsPubUnpublished ( const CCit_proc proc)

Definition at line 294 of file pub_tests.cpp.

References IsPubUnpublished(), and proc.

◆ IsPubUnpublished() [5/6]

bool IsPubUnpublished ( const CImprint imp)

◆ IsPubUnpublished() [6/6]

bool IsPubUnpublished ( const CPub pub)

◆ IsValidStateAbbreviation()

static bool IsValidStateAbbreviation ( const string state)
static

◆ RemoveAffilDup()

static bool RemoveAffilDup ( CCit_sub cit_sub)
static

◆ RemoveAffilStreetEnd()

static bool RemoveAffilStreetEnd ( string street,
const string tail,
bool  country 
)
static

◆ RemoveConsortium()

static int RemoveConsortium ( CAuth_list authors)
static

Definition at line 610 of file pub_tests.cpp.

References n, names, and CAuth_list_Base::SetNames().

Referenced by CDiscrepancyVisitorImpl< _Name >::Autofix().

◆ ReplaceStateAbbreviation()

static bool ReplaceStateAbbreviation ( CAffil affil)
static

◆ SummarizeAffiliation() [1/2]

string SummarizeAffiliation ( const CAffil affil)

◆ SummarizeAffiliation() [2/2]

string SummarizeAffiliation ( const CAffil::C_Std affil)

◆ USING_SCOPE()

USING_SCOPE ( objects  )

Variable Documentation

◆ kCitSubSummary

const string kCitSubSummary = "Citsub affiliation conflicts found"

Definition at line 480 of file pub_tests.cpp.

Referenced by CDiscrepancyVisitorImpl< _Name >::Summarize().

◆ kIncorrectCap

const string kIncorrectCap = "[n] pub[s] [has] incorrect author capitalization"
static

Definition at line 1042 of file pub_tests.cpp.

◆ kMissingAuthorsName

const string kMissingAuthorsName = "[n] pub[s] missing author\'s first or last name"

Definition at line 657 of file pub_tests.cpp.

◆ kNumOfAbbreviations

size_t kNumOfAbbreviations = ArraySize(us_state_abbreviations)
static

Definition at line 936 of file pub_tests.cpp.

Referenced by IsValidStateAbbreviation(), and ReplaceStateAbbreviation().

◆ kSummaries

const string kSummaries = "summaries"

Definition at line 481 of file pub_tests.cpp.

Referenced by CDiscrepancyVisitorImpl< _Name >::Summarize().

◆ kTitleAuthorConflict

const char* kTitleAuthorConflict = "Publication Title/Author Inconsistencies"
static

Definition at line 234 of file pub_tests.cpp.

Referenced by CDiscrepancyVisitorImpl< _Name >::Summarize().

◆ kTitleAuthorConflictEnd

const string kTitleAuthorConflictEnd = "' but do not have the same author list"

Definition at line 67 of file pub_tests.cpp.

◆ kTitleAuthorConflictStart

const string kTitleAuthorConflictStart = "[n] articles have title '"

Definition at line 66 of file pub_tests.cpp.

◆ s_testcase_props_CHECK_AUTH_CAPS

constexpr CDiscrepancyCaseProps s_testcase_props_CHECK_AUTH_CAPS = { CDiscrepancyVisitorImpl<eTestNames:: CHECK_AUTH_CAPS >::Create, eTestTypes:: AUTHORS , eTestNames:: CHECK_AUTH_CAPS , "CHECK_AUTH_CAPS" , "Check for correct capitalization in author names" , eDisc | eOncaller | eSmart , nullptr }
staticconstexpr

Definition at line 1119 of file pub_tests.cpp.

◆ s_testcase_props_CHECK_AUTH_NAME

constexpr CDiscrepancyCaseProps s_testcase_props_CHECK_AUTH_NAME = { CDiscrepancyVisitorImpl<eTestNames:: CHECK_AUTH_NAME >::Create, eTestTypes:: AUTHORS , eTestNames:: CHECK_AUTH_NAME , "CHECK_AUTH_NAME" , "Missing authors or first/last author's names" , eDisc | eOncaller | eSubmitter | eSmart , nullptr }
staticconstexpr

Definition at line 659 of file pub_tests.cpp.

◆ s_testcase_props_CITSUB_AFFIL_DUP_TEXT

constexpr CDiscrepancyCaseProps s_testcase_props_CITSUB_AFFIL_DUP_TEXT = { CDiscrepancyVisitorImpl<eTestNames:: CITSUB_AFFIL_DUP_TEXT >::Create, eTestTypes:: PUBDESC , eTestNames:: CITSUB_AFFIL_DUP_TEXT , "CITSUB_AFFIL_DUP_TEXT" , "Cit-sub affiliation street contains text from other affiliation fields" , eOncaller , nullptr }
staticconstexpr

Definition at line 743 of file pub_tests.cpp.

◆ s_testcase_props_CITSUBAFFIL_CONFLICT

constexpr CDiscrepancyCaseProps s_testcase_props_CITSUBAFFIL_CONFLICT = { CDiscrepancyVisitorImpl<eTestNames:: CITSUBAFFIL_CONFLICT >::Create, eTestTypes:: AUTHORS , eTestNames:: CITSUBAFFIL_CONFLICT , "CITSUBAFFIL_CONFLICT" , "All Cit-subs should have identical affiliations" , eDisc | eOncaller | eSmart | eFatal , nullptr }
staticconstexpr

Definition at line 484 of file pub_tests.cpp.

◆ s_testcase_props_CONSORTIUM

constexpr CDiscrepancyCaseProps s_testcase_props_CONSORTIUM = { CDiscrepancyVisitorImpl<eTestNames:: CONSORTIUM >::Create, eTestTypes:: AUTHORS , eTestNames:: CONSORTIUM , "CONSORTIUM" , "Submitter blocks and publications have consortiums" , eOncaller , nullptr }
staticconstexpr

Definition at line 590 of file pub_tests.cpp.

◆ s_testcase_props_MISSING_AFFIL

constexpr CDiscrepancyCaseProps s_testcase_props_MISSING_AFFIL = { CDiscrepancyVisitorImpl<eTestNames:: MISSING_AFFIL >::Create, eTestTypes:: PUBDESC , eTestNames:: MISSING_AFFIL , "MISSING_AFFIL" , "Missing affiliation" , eDisc | eOncaller | eFatal , nullptr }
staticconstexpr

Definition at line 428 of file pub_tests.cpp.

◆ s_testcase_props_SUBMITBLOCK_CONFLICT

constexpr CDiscrepancyCaseProps s_testcase_props_SUBMITBLOCK_CONFLICT = { CDiscrepancyVisitorImpl<eTestNames:: SUBMITBLOCK_CONFLICT >::Create, eTestTypes:: SUBMIT , eTestNames:: SUBMITBLOCK_CONFLICT , "SUBMITBLOCK_CONFLICT" , "Records should have identical submit-blocks" , eDisc | eOncaller | eSmart , nullptr }
staticconstexpr

Definition at line 560 of file pub_tests.cpp.

◆ s_testcase_props_TITLE_AUTHOR_CONFLICT

constexpr CDiscrepancyCaseProps s_testcase_props_TITLE_AUTHOR_CONFLICT = { CDiscrepancyVisitorImpl<eTestNames:: TITLE_AUTHOR_CONFLICT >::Create, eTestTypes:: DESC , eTestNames:: TITLE_AUTHOR_CONFLICT , "TITLE_AUTHOR_CONFLICT" , "Publications with the same titles should have the same authors" , eDisc | eOncaller | eSmart | eFatal , nullptr }
staticconstexpr

Definition at line 219 of file pub_tests.cpp.

◆ s_testcase_props_UNPUB_PUB_WITHOUT_TITLE

constexpr CDiscrepancyCaseProps s_testcase_props_UNPUB_PUB_WITHOUT_TITLE = { CDiscrepancyVisitorImpl<eTestNames:: UNPUB_PUB_WITHOUT_TITLE >::Create, eTestTypes:: PUBDESC , eTestNames:: UNPUB_PUB_WITHOUT_TITLE , "UNPUB_PUB_WITHOUT_TITLE" , "Unpublished pubs should have titles" , eDisc | eOncaller | eSubmitter | eSmart | eBig | eFatal , nullptr }
staticconstexpr

Definition at line 377 of file pub_tests.cpp.

◆ s_testcase_props_USA_STATE

constexpr CDiscrepancyCaseProps s_testcase_props_USA_STATE = { CDiscrepancyVisitorImpl<eTestNames:: USA_STATE >::Create, eTestTypes:: PUBDESC , eTestNames:: USA_STATE , "USA_STATE" , "For country USA, state should be present and abbreviated" , eDisc | eOncaller | eSmart , nullptr }
staticconstexpr

Definition at line 949 of file pub_tests.cpp.

◆ us_state_abbreviations

pair<string, string> us_state_abbreviations[]
static

Definition at line 839 of file pub_tests.cpp.

Referenced by IsValidStateAbbreviation(), and ReplaceStateAbbreviation().

Modified on Tue May 28 05:52:04 2024 by modify_doxy.py rev. 669887