search_query.ebscohost.parser

EBSCO query parser.

Classes

EBSCOListParser(query_list[, field_general, ...])

Parser for EBSCO (list format) queries.

EBSCOParser(query_str, *[, field_general, ...])

Parser for EBSCO queries.

class search_query.ebscohost.parser.EBSCOListParser(query_list: str, field_general: str = '', ignore_failing_linter: bool = False)

Bases: QueryListParser

Parser for EBSCO (list format) queries.

linter: EBSCOListLinter
parse() Query

Parse EBSCO list query.

class search_query.ebscohost.parser.EBSCOParser(query_str: str, *, field_general: str = '', offset: dict | None = None, original_str: str | None = None, silent: bool = False, ignore_failing_linter: bool = False)

Bases: QueryStringParser

Parser for EBSCO queries.

FIELD_REGEX = re.compile('\\b([A-Z]{2})\\b')
LOGIC_OPERATOR_REGEX = re.compile('(?i:\\b(AND|OR|NOT)\\b)')
OPERATOR_REGEX: re.Pattern = re.compile('(?i:\\b(AND|OR|NOT)\\b)|(?i:[NW]\\d+|(NEAR|N|WITHIN)/\\d+)')
PARENTHESIS_REGEX = re.compile('[()]')
PROXIMITY_OPERATOR_REGEX = re.compile('(?i:[NW]\\d+|(NEAR|N|WITHIN)/\\d+)')
QUOTATION_MARK_REGEX = re.compile('"')
TERM_REGEX = re.compile('[^\\s()"]+')
fix_ambiguous_tokens() None

Fix ambiguous tokens that could be misinterpreted as a search field.

parse() Query

Parse a query string.

parse_query_tree(tokens: list[Token], field_context: SearchField | None = None) Query

Top-down predictive parser for query tree.

pattern = re.compile('[()]|(?i:\\b(AND|OR|NOT)\\b)|(?i:[NW]\\d+|(NEAR|N|WITHIN)/\\d+)|\\b([A-Z]{2})\\b|"|[^\\s()"]+')
tokenize() None

Tokenize the query_str.