search_query.wos.linter

Web-of-Science query linter.

Classes

WOSQueryListLinter(parser, string_parser_class)

WOSQueryStringLinter([query_str])

Linter for WOS Query Strings

class search_query.wos.linter.WOSQueryListLinter(parser: search_query.wos.parser.WOSListParser, string_parser_class: Type[search_query.wos.parser.WOSParser])

Bases: QueryListLinter

parser: search_query.wos.parser.WOSListParser
validate_list_tokens() None

Lint the list parser.

class search_query.wos.linter.WOSQueryStringLinter(query_str: str = '')

Bases: QueryStringLinter

Linter for WOS Query Strings

DOI_VALUE_REGEX = re.compile('^10\\.\\d{4,9}/[-._;()/:A-Z0-9]+$', re.IGNORECASE)
ISBN_VALUE_REGEX = re.compile('^(?:\\d{1,5}-\\d{1,7}-\\d{1,7}-[\\dX]|\\d{3}-\\d{1,5}-\\d{1,7}-\\d{1,7}-\\d{1})$', re.IGNORECASE)
ISSN_VALUE_REGEX = re.compile('^\\d{4}-\\d{3}[\\dX]$', re.IGNORECASE)
PLATFORM: <PLATFORM.WOS: 'wos'> = 'wos'
VALID_FIELDS_REGEX: re.Pattern = re.compile('ab=|abstract=|la=|language=|ad=|address=|all=|all fields=|ai=|author identifiers=|ak=|author keywords=|au=|author=|cf=|conference=|ci=|city=|cu=|country/region=|do=|doi=|ed=|editor=|fg=|grant number=, re.IGNORECASE)
VALID_TOKEN_SEQUENCES = {TokenTypes.FIELD: [TokenTypes.SEARCH_TERM, TokenTypes.PARENTHESIS_OPEN], TokenTypes.LOGIC_OPERATOR: [TokenTypes.SEARCH_TERM, TokenTypes.FIELD, TokenTypes.PARENTHESIS_OPEN], TokenTypes.PARENTHESIS_CLOSED: [TokenTypes.PARENTHESIS_CLOSED, TokenTypes.LOGIC_OPERATOR, TokenTypes.PROXIMITY_OPERATOR], TokenTypes.PARENTHESIS_OPEN: [TokenTypes.FIELD, TokenTypes.SEARCH_TERM, TokenTypes.PARENTHESIS_OPEN], TokenTypes.PROXIMITY_OPERATOR: [TokenTypes.SEARCH_TERM, TokenTypes.PARENTHESIS_OPEN, TokenTypes.FIELD], TokenTypes.SEARCH_TERM: [TokenTypes.SEARCH_TERM, TokenTypes.LOGIC_OPERATOR, TokenTypes.PROXIMITY_OPERATOR, TokenTypes.PARENTHESIS_CLOSED]}
WILDCARD_CHARS = ['?', '$', '*']
YEAR_VALUE_REGEX = re.compile('^\\d{4}(-\\d{4})?$')
check_doi_format(query: Query) None

Check for the correct format of DOI.

check_format_left_hand_wildcards(query: Query) None

Check for wrong usage among left-hand wildcards in the search string.

check_implicit_near() None

Check for implicit NEAR operator.

check_invalid_syntax() None

Check for invalid syntax in the query string.

check_invalid_token_sequences() None

Check for the correct order of tokens in the query.

check_issn_isbn_format(query: Query) None

Check for the correct format of ISSN and ISBN.

check_nr_search_terms(query: Query) None

Check the number of search terms in the query.

check_search_fields_general() None

Check the general search field (from JSON).

check_unsupported_right_hand_wildcards(query: Query, index: int) None

Check for unsupported right-hand wildcards in the search string.

check_unsupported_wildcards(query: Query) None

Check for unsupported characters in the search string.

check_wildcards(query: Query) None

Check for the usage of wildcards in the search string.

check_year_format(query: Query) None

Check for the correct format of year.

check_year_without_search_terms(query: Query) None

Check if the year is used without a search terms.

get_nr_terms_all(query: Query) int

Get the number of terms in the query.

syntax_str_to_generic_search_field_set(field_value: str) set

Translate a search field

validate_query_tree(query: Query) None

Validate the query tree. This method is called after the query tree has been built.

validate_tokens(*, tokens: List[Token], query_str: str, search_field_general: str = '') List[Token]

Performs a pre-linting