mirror of
https://github.com/nexus-stc/hyperboria
synced 2024-12-13 05:07:47 +01:00
fff80cd4e7
- fix(nexus): Preparing configs to be published - feat(nexus): Various fixes for opening left sources - fix(nexus): Fine-tune versions 1 internal commit(s) GitOrigin-RevId: 6c834cd3f4f5f18109a159a73503700dac63b0bb
32 lines
842 B
Python
32 lines
842 B
Python
from nexus.meta_api.query_extensionner.grammar import (
|
|
FieldResolver,
|
|
MorphyResolver,
|
|
OrOperation,
|
|
UnknownOperationResolver,
|
|
parser,
|
|
)
|
|
|
|
from . import checks
|
|
from .checks import QueryClass
|
|
|
|
|
|
class QueryProcessor:
|
|
checks = tuple()
|
|
|
|
def process(self, query, language):
|
|
raise NotImplementedError()
|
|
|
|
|
|
class ClassicQueryProcessor(QueryProcessor):
|
|
checks = (checks.check_doi, checks.check_isbn, checks.check_nid, checks.check_url)
|
|
|
|
def process(self, query, language):
|
|
uor = UnknownOperationResolver(OrOperation)
|
|
fr = FieldResolver()
|
|
morphy = MorphyResolver(language)
|
|
for c in self.checks:
|
|
r = c(query)
|
|
if r:
|
|
return r
|
|
return {'query': str(uor.visit(fr.visit(morphy.visit(parser.parse(query))))), 'class': QueryClass.Default}
|