extraction-framework icon indicating copy to clipboard operation
extraction-framework copied to clipboard

GenderExtractor: Replace hardcoded URI strings with ontology lookups

Open PritamP20 opened this issue 3 weeks ago • 2 comments

Description

GenderExtractor.scala currently hardcodes URI strings for ontology properties and classes instead of leveraging the framework's ontology lookup mechanism. This creates maintenance issues and inconsistencies across extractors.

Current Problem

The following hardcoded URIs should be replaced with proper ontology lookups:

// Don't use string constant, use context.ontology (or at least RdfNamespace.FOAF)
private val genderProperty = "http://xmlns.com/foaf/0.1/gender"

// Don't use string constant, use context.ontology (or at least RdfNamespace.RDF)
private val typeProperty = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"

// Don't use string constant, use context.ontology (or at least DBpediaNamespace.ONTOLOGY)
private val personUri = "http://dbpedia.org/ontology/Person"

These URIs are fragile, difficult to maintain, and don't follow the framework's established patterns.

Proposed Solution

Replace hardcoded strings with ontology lookups:

private val genderProperty = context.ontology.properties("foaf:gender")
private val typeProperty = context.ontology.properties("rdf:type")
private val personClass = context.ontology.classes("Person")

Benefits

  • Consistency: Aligns with the framework's ontology lookup pattern used across other extractors
  • Maintainability: Ontology definitions become the single source of truth
  • Clarity: Removes FIXME comments and clarifies intent
  • Flexibility: Enables easier updates to ontology mappings without code changes

File Location

core/src/main/scala/org/dbpedia/extraction/mappings/GenderExtractor.scala (lines 31–36)

PritamP20 avatar Dec 19 '25 17:12 PritamP20