23use Wikimedia\Purtle\RdfWriter;
32 private const ONTOLOGY_PREFIX =
'mediawiki';
36 private const ONTOLOGY_URL =
'https://www.mediawiki.org/ontology#';
40 public const OWL_URL =
'https://www.mediawiki.org/ontology/ontology.owl';
50 private const SPECIAL_DUMP =
'Special:CategoryDump';
57 $this->rdfWriter = $writer;
64 $this->rdfWriter->prefix( self::ONTOLOGY_PREFIX, self::ONTOLOGY_URL );
65 $this->rdfWriter->prefix(
'rdfs',
'http://www.w3.org/2000/01/rdf-schema#' );
66 $this->rdfWriter->prefix(
'owl',
'http://www.w3.org/2002/07/owl#' );
67 $this->rdfWriter->prefix(
'schema',
'http://schema.org/' );
68 $this->rdfWriter->prefix(
'cc',
'http://creativecommons.org/ns#' );
77 $titleFrom = Title::makeTitle(
NS_CATEGORY, $fromName );
78 $titleTo = Title::makeTitle(
NS_CATEGORY, $toName );
79 $this->rdfWriter->about( $this->titleToUrl( $titleFrom ) )
80 ->say( self::ONTOLOGY_PREFIX,
'isInCategory' )
81 ->is( $this->titleToUrl( $titleTo ) );
96 $title = Title::makeTitle(
NS_CATEGORY, $categoryName );
97 $this->rdfWriter->about( $this->titleToUrl( $title ) )
99 ->is( self::ONTOLOGY_PREFIX,
'Category' );
101 $this->rdfWriter->is( self::ONTOLOGY_PREFIX,
'HiddenCategory' );
103 $titletext = $title->getText();
104 $this->rdfWriter->say(
'rdfs',
'label' )->value( $titletext );
106 $this->rdfWriter->say( self::ONTOLOGY_PREFIX,
'pages' )->value( $pages );
108 $this->rdfWriter->say( self::ONTOLOGY_PREFIX,
'subcategories' )->value( $subcategories );
118 return $this->titleToUrl( Title::makeTitle(
NS_CATEGORY, $titleLabel ) );
126 private function titleToUrl(
Title $title ) {
135 return $this->titleToUrl( Title::makeTitle(
NS_MAIN, self::SPECIAL_DUMP ) );
143class_alias( CategoriesRdf::class,
'CategoriesRdf' );