<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from rdflib . term import Literal <EOL> from rdflib . term import URIRef <EOL> from gutenberg . _domain_model . vocabulary import DCTERMS <EOL> from gutenberg . _domain_model . vocabulary import PGTERMS <EOL> from gutenberg . _util . abc import abstractclassmethod <EOL> from gutenberg . query . api import MetadataExtractor <EOL> class _SimplePredicateRelationshipExtractor ( MetadataExtractor ) : <EOL> """<STR_LIT>""" <EOL> @ abstractclassmethod <EOL> def predicate ( cls ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> @ classmethod <EOL> def get_metadata ( cls , etextno ) : <EOL> etext = cls . _etext_to_uri ( etextno ) <EOL> query = cls . _metadata ( ) [ etext : cls . predicate ( ) : ] <EOL> return frozenset ( result . toPython ( ) for result in query ) <EOL> @ classmethod <EOL> def get_etexts ( cls , requested_value ) : <EOL> query = cls . _metadata ( ) [ : cls . predicate ( ) : cls . contains ( requested_value ) ] <EOL> return frozenset ( cls . _uri_to_etext ( result ) for result in query ) <EOL> class AuthorExtractor ( _SimplePredicateRelationshipExtractor ) : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> def feature_name ( cls ) : <EOL> return '<STR_LIT>' <EOL> @ classmethod <EOL> def predicate ( cls ) : <EOL> return DCTERMS . creator / PGTERMS . alias <EOL> @ classmethod <EOL> def contains ( cls , value ) : <EOL> return Literal ( value ) <EOL> class TitleExtractor ( _SimplePredicateRelationshipExtractor ) : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> def feature_name ( cls ) : <EOL> return '<STR_LIT:title>' <EOL> @ classmethod <EOL> def predicate ( cls ) : <EOL> return DCTERMS . title <EOL> @ classmethod <EOL> def contains ( cls , value ) : <EOL> return Literal ( value ) <EOL> class FormatURIExtractor ( _SimplePredicateRelationshipExtractor ) : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> def feature_name ( cls ) : <EOL> return '<STR_LIT>' <EOL> @ classmethod <EOL> def predicate ( cls ) : <EOL> return DCTERMS . hasFormat <EOL> @ classmethod <EOL> def contains ( cls , value ) : <EOL> return URIRef ( value ) </s>
