search_query.wos.parser

Web-of-Science query parser.

Classes

WOSListParser(query_list, ...)

Parser for Web-of-Science (list format) queries.

WOSParser(query_str, *[, ...])

Parser for Web-of-Science queries.

class search_query.wos.parser.WOSListParser(query_list: str, search_field_general: str, mode: str)

Bases: QueryListParser

Parser for Web-of-Science (list format) queries.

LIST_ITEM_REFERENCE = re.compile('#\\d+')
LIST_ITEM_REGEX: Pattern = re.compile('^(\\d+).\\s+(.*)$')
OPERATOR_NODE_REGEX = re.compile('#\\d+|AND|OR')
parse() Query

Parse the list of queries.

query_dict: dict
tokenize_operator_node(query_str: str, node_nr: int) list

Tokenize the query_list.

class search_query.wos.parser.WOSParser(query_str: str, *, search_field_general: str = '', mode: str = 'strict')

Bases: QueryStringParser

Parser for Web-of-Science queries.

LOGIC_OPERATOR_REGEX = re.compile('\\b(AND|OR|NOT)\\b', re.IGNORECASE)
OPERATOR_REGEX: re.Pattern = re.compile('\\b(AND|OR|NOT)\\b|\\b(NEAR/\\d{1,2}|NEAR)\\b')
PARENTHESIS_REGEX = re.compile('[\\(\\)]')
PROXIMITY_OPERATOR_REGEX = re.compile('\\b(NEAR/\\d{1,2}|NEAR)\\b', re.IGNORECASE)
SEARCH_FIELDS_REGEX = re.compile('\\b(?!and\\b)[a-zA-Z]+(?:\\s(?!and\\b)[a-zA-Z]+)*')
SEARCH_FIELD_REGEX = re.compile('\\b\\w{2}=|\\b\\w{3}=')
SEARCH_TERM_REGEX = re.compile('\\*?[\\w\\-/\\.\\!\\*,&\\\\]+(?:[\\*\\$\\?][\\w\\-/\\.\\!\\*,&\\\\]*)*|"[^"]+"')
combine_subsequent_terms() None

Combine subsequent terms in the list of tokens.

parse() Query

Parse a query string.

parse_query_tree(index: int = 0, search_field: SearchField | None = None) Tuple[Query, int]

Parse tokens starting at the given index, handling parentheses, operators, search fields and terms recursively.

pattern = re.compile('\\b\\w{2}=|\\b\\w{3}=|\\b(AND|OR|NOT)\\b|\\b(NEAR/\\d{1,2}|NEAR)\\b|\\*?[\\w\\-/\\.\\!\\*,&\\\\]+(?:[\\*\\$\\?][\\w\\-/\\.\\!\\*,&\\\\]*)*|"[^"]+"|[\\(\\)]')
tokenize() None

Tokenize the query_str.