def facets(self): # maybe if each entry in the list could be a tuple or a single # element. If it's a tuple, then the first elements' selector # values (eg organizations) become top level facets, the # second elements' selector values become subsection # underneath, and possibly more levels. def altlabel(row, binding, resource_graph): uri = URIRef(row[binding]) if resource_graph.value(uri, SKOS.altLabel): return str(resource_graph.value(uri, SKOS.altLabel)) else: return row[binding] def mainfs(row, binding, resource_graph): uri = URIRef(row[binding]) mainuri = resource_graph.value(uri, DCTERMS.isReplacedBy) if mainuri: uri = mainuri return util.uri_leaf(uri) return [Facet(RPUBL.forfattningssamling, selector=altlabel, identificator=mainfs, use_for_toc=True), Facet(RPUBL.arsutgava, indexingtype=fulltextindex.Label(), selector_descending=True, use_for_toc=True), Facet(RDF.type, use_for_toc=False, use_for_feed=False), Facet(DCTERMS.title, use_for_toc=False), Facet(DCTERMS.publisher, use_for_toc=False, pagetitle="Författningar utgivna av %(selected)s"), Facet(DCTERMS.identifier)] + self.standardfacets
def facets(self): labels = { 'dir': 'Komittédirektiv', 'sou': 'SOU', 'ds': 'Ds', 'prop': 'Propositioner' } # rdf:type rpubl:Kommittedirektiv => "Kommittédirektiv" # rdf:type rpubl:Utredningsbetankande, rpubl:utrSerie .*sou => "SOU" # rdf:type rpubl:Utredningsbetankande, rpubl:utrSerie .*ds => "Ds" # rdf:type rpubl:Proposition => "Propositioner" def select(row, binding, extra): return labels[ident(row, binding, extra)] # This is a selector that can CLEARLY not run on arbitrary rows def ident(row, binding, extra): rdftype = row[binding] if rdftype == str(self.ns['rpubl'].Utredningsbetankande): if row['rpubl_utrSerie']: leaf = util.uri_leaf(row['rpubl_utrSerie']) if leaf.startswith("ds"): return "ds" elif leaf.startswith("sou"): return "sou" else: assert leaf in ( "sou", "ds" ), "leaf was %s, unsure whether this is a SOU or a Ds." % leaf else: self.log.error( "Row for %s is rpubl:Utredning but lacks rpubl:utrSerie" % row['uri']) elif rdftype == str(self.ns['rpubl'].Kommittedirektiv): return "dir" elif rdftype == str(self.ns['rpubl'].Proposition): return "prop" else: pass # self.log.error("Row for %s has unrecognized type %s" % (row['uri'], row['rdf_type'])) return [ Facet(RDF.type, selector=select, pagetitle="Alla %(selected)s", identificator=ident), Facet(RPUBL.arsutgava, indexingtype=fulltextindex.Label(), selector_descending=True) ]
def facets(self): # The facets of a repo control indexing, particularly the # synthesized 'label', 'creator' and 'issued'. By only # defining a facet for 'label' we avoid having to define # issued and creator for static pages. Or maybe we should try # to do that? return [Facet(RDFS.label, use_for_toc=False, use_for_feed=False, toplevel_only=False, dimension_label="label", dimension_type="value", multiple_values=False, indexingtype=fulltextindex.Label(boost=16))]
def test_repr(self): self.assertEqual("<Identifier>", repr(fulltextindex.Identifier())) self.assertEqual("<Identifier boost=16>", repr(fulltextindex.Identifier(boost=16))) self.assertEqual("<Label boost=16 foo=bar>", repr(fulltextindex.Label(boost=16, foo='bar')))
def test_eq(self): id1 = fulltextindex.Identifier(boost=16) id2 = fulltextindex.Identifier(boost=16) lbl = fulltextindex.Label(boost=16) self.assertEqual(id1, id2) self.assertNotEqual(id1, lbl)
'selector': Facet.resourcelabel_or_qname, 'identificator': Facet.term, 'dimension_type': "term", 'pagetitle': 'All %(selected)s documents'}, DCTERMS.title: { 'indexingtype': fulltextindex.Text(boost=4), 'toplevel_only': False, 'use_for_toc': True, 'selector': Facet.firstletter, 'key': Facet.titlesortkey, 'identificator': Facet.firstletter, 'dimension_type': None, # or "value", 'pagetitle': 'Documents starting with "%(selected)s"' }, DCTERMS.identifier: { 'indexingtype': fulltextindex.Label(boost=16), 'toplevel_only': False, 'use_for_toc': False, # typically no info that isn't already in title 'selector': Facet.firstletter, 'key': Facet.titlesortkey, 'identificator': Facet.firstletter, }, DCTERMS.abstract: { 'indexingtype': fulltextindex.Text(boost=2), 'toplevel_only': True, 'use_for_toc': False }, DC.creator: { 'indexingtype': fulltextindex.Label(), 'toplevel_only': True, 'use_for_toc': True,