Class OntolexBasedRDFDataHandler

java.lang.Object
org.getalp.dbnary.model.DbnaryModel
org.getalp.dbnary.languages.OntolexBasedRDFDataHandler
All Implemented Interfaces:
IWiktionaryDataHandler
Direct Known Subclasses:
PostTranslationDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler, WiktionaryDataHandler

public class OntolexBasedRDFDataHandler extends DbnaryModel implements IWiktionaryDataHandler
  • Field Details

    • aBox

      @Deprecated protected org.apache.jena.rdf.model.Model aBox
      Deprecated.
      use getFeatureBox()
    • currentLexEntry

      @Deprecated protected org.apache.jena.rdf.model.Resource currentLexEntry
      Deprecated.
    • currentLexicalEntry

      protected LexicalEntry currentLexicalEntry
    • currentSense

      protected org.apache.jena.rdf.model.Resource currentSense
    • currentSenseNumber

      protected HierarchicalSenseNumber currentSenseNumber
    • translationCount

      protected CounterSet translationCount
    • reifiedNymCount

      protected CounterSet reifiedNymCount
    • shortEditionLanguageCode

      protected final String shortEditionLanguageCode
    • longEditionLanguageCode

      protected final String longEditionLanguageCode
    • shortSectionLanguageCode

      protected String shortSectionLanguageCode
    • longSectionLanguageCode

      protected String longSectionLanguageCode
    • lexvoExtractedLanguage

      protected org.apache.jena.rdf.model.Resource lexvoExtractedLanguage
    • lexvoSectionLanguage

      protected org.apache.jena.rdf.model.Resource lexvoSectionLanguage
    • nbEntries

      protected int nbEntries
    • WIKT

      protected String WIKT
    • currentEncodedLexicalEntryName

      protected String currentEncodedLexicalEntryName
    • currentLexieCount

      @Deprecated protected CounterSet currentLexieCount
      Deprecated.
    • currentMainLexEntry

      @Deprecated protected org.apache.jena.rdf.model.Resource currentMainLexEntry
      Deprecated.
      should rely on currentPage (not a Resource anymore
    • currentPage

      protected Page currentPage
    • currentCanonicalForm

      protected org.apache.jena.rdf.model.Resource currentCanonicalForm
    • currentSharedPronunciations

      protected Set<PronunciationPair> currentSharedPronunciations
    • posAndTypeValueMap

      protected static HashMap<String, OntolexBasedRDFDataHandler.PosAndType> posAndTypeValueMap
    • glossFilter

      protected final AbstractGlossFilter glossFilter
  • Constructor Details

    • OntolexBasedRDFDataHandler

      public OntolexBasedRDFDataHandler(String longEditionLanguageCode, String tdbDir)
  • Method Details

    • getCurrentEntryLanguage

      public String getCurrentEntryLanguage()
      returns the language of the current Entry
      Specified by:
      getCurrentEntryLanguage in interface IWiktionaryDataHandler
      Returns:
      a language code
    • getExtractedLanguage

      public String getExtractedLanguage()
      Description copied from interface: IWiktionaryDataHandler
      returns the short (2 letter code) id of the language of the language edition
      Specified by:
      getExtractedLanguage in interface IWiktionaryDataHandler
      Returns:
      wiktionary edition short language code
    • closeDataset

      public void closeDataset()
      Description copied from interface: IWiktionaryDataHandler
      close the dataset that eventually backs up the different feature boxes.

      Does nothing when there is no dataset backing up the boxes.

      Specified by:
      closeDataset in interface IWiktionaryDataHandler
    • enableEndolexFeatures

      public void enableEndolexFeatures(ExtractionFeature f)
      Description copied from interface: IWiktionaryDataHandler
      Enable the extraction of morphological data in a second Model if available.
      Specified by:
      enableEndolexFeatures in interface IWiktionaryDataHandler
      Parameters:
      f - Feature
    • getFeatureBox

      public org.apache.jena.rdf.model.Model getFeatureBox(ExtractionFeature f)
      Specified by:
      getFeatureBox in interface IWiktionaryDataHandler
    • getEndolexFeatureBox

      public org.apache.jena.rdf.model.Model getEndolexFeatureBox(ExtractionFeature f)
      Specified by:
      getEndolexFeatureBox in interface IWiktionaryDataHandler
    • getExolexFeatureBox

      public org.apache.jena.rdf.model.Model getExolexFeatureBox(ExtractionFeature f)
      Specified by:
      getExolexFeatureBox in interface IWiktionaryDataHandler
    • enableExolexFeatures

      public void enableExolexFeatures(ExtractionFeature f)
      Specified by:
      enableExolexFeatures in interface IWiktionaryDataHandler
    • isDisabled

      public boolean isDisabled(ExtractionFeature f)
      Specified by:
      isDisabled in interface IWiktionaryDataHandler
    • initializePageExtraction

      public void initializePageExtraction(String wiktionaryPageName)
      Specified by:
      initializePageExtraction in interface IWiktionaryDataHandler
    • finalizePageExtraction

      public void finalizePageExtraction()
      Specified by:
      finalizePageExtraction in interface IWiktionaryDataHandler
    • initializeLanguageSection

      public void initializeLanguageSection(String language)
      Specified by:
      initializeLanguageSection in interface IWiktionaryDataHandler
    • finalizeLanguageSection

      public void finalizeLanguageSection()
      Specified by:
      finalizeLanguageSection in interface IWiktionaryDataHandler
    • getEncodedPageName

      public String getEncodedPageName(String pageName, String pos, int defNumber)
    • getLexEntry

      public org.apache.jena.rdf.model.Resource getLexEntry(String languageCode, String pageName, String pos, int defNumber)
    • getLexEntry

      public org.apache.jena.rdf.model.Resource getLexEntry(String encodedPageName, org.apache.jena.rdf.model.Resource typeResource)
    • currentWiktionaryPos

      public String currentWiktionaryPos()
      Specified by:
      currentWiktionaryPos in interface IWiktionaryDataHandler
    • currentLexinfoPos

      public org.apache.jena.rdf.model.Resource currentLexinfoPos()
      Specified by:
      currentLexinfoPos in interface IWiktionaryDataHandler
    • posResource

      public org.apache.jena.rdf.model.Resource posResource(OntolexBasedRDFDataHandler.PosAndType pat)
    • typeResource

      public org.apache.jena.rdf.model.Resource typeResource(OntolexBasedRDFDataHandler.PosAndType pat)
    • posResource

      public org.apache.jena.rdf.model.Resource posResource(String pos)
    • typeResource

      public org.apache.jena.rdf.model.Resource typeResource(String pos)
    • decodePartOfSpeech

      protected OntolexBasedRDFDataHandler.PosAndType decodePartOfSpeech(String pos)
    • initializeLexicalEntry

      public void initializeLexicalEntry(String pos)
      Specified by:
      initializeLexicalEntry in interface IWiktionaryDataHandler
    • initializeLexicalEntry

      protected org.apache.jena.rdf.model.Resource initializeLexicalEntry(String pos, org.apache.jena.rdf.model.Resource lexinfoPOS, org.apache.jena.rdf.model.Resource type)
    • initializeLexicalEntry__noModel

      public org.apache.jena.rdf.model.Resource initializeLexicalEntry__noModel(String originalPOS, org.apache.jena.rdf.model.Resource normalizedPOS, org.apache.jena.rdf.model.Resource normalizedType)
    • registerPropertyOnCanonicalForm

      public void registerPropertyOnCanonicalForm(org.apache.jena.rdf.model.Property p, org.apache.jena.rdf.model.RDFNode r)
      Specified by:
      registerPropertyOnCanonicalForm in interface IWiktionaryDataHandler
    • registerPropertyOnLexicalEntry

      public void registerPropertyOnLexicalEntry(org.apache.jena.rdf.model.Property p, org.apache.jena.rdf.model.RDFNode r)
      Specified by:
      registerPropertyOnLexicalEntry in interface IWiktionaryDataHandler
    • registerAlternateSpelling

      public void registerAlternateSpelling(String alt)
      Specified by:
      registerAlternateSpelling in interface IWiktionaryDataHandler
    • registerNewDefinition

      public org.apache.jena.rdf.model.Resource registerNewDefinition(String def)
      Description copied from interface: IWiktionaryDataHandler
      Register definition def for the current lexical entry.

      This method will compute a sense number based on the rank of the definition in the entry.

      It is equivalent to registerNewDefinition(def, 1);

      Specified by:
      registerNewDefinition in interface IWiktionaryDataHandler
      Parameters:
      def - a string
      Returns:
    • registerNewDefinition

      public org.apache.jena.rdf.model.Resource registerNewDefinition(String def, int lvl)
      Description copied from interface: IWiktionaryDataHandler
      Register definition def for the current lexical entry.

      This method will compute a sense number based on the rank of the definition in the entry, taking into account the level of the definition. 1, 1a, 1b, 1c, 2, etc.

      Specified by:
      registerNewDefinition in interface IWiktionaryDataHandler
      Parameters:
      def - the definition string
      lvl - an integer giving the level of the definition (1 or 2).
      Returns:
    • registerNewDefinition

      public org.apache.jena.rdf.model.Resource registerNewDefinition(String def, String senseNumber)
      Register a definition with the given sense number.
      Specified by:
      registerNewDefinition in interface IWiktionaryDataHandler
      Parameters:
      def - the definition string
      senseNumber - a string giving the sense number of the definition.
      Returns:
    • computeSenseNum

      protected String computeSenseNum()
    • registerTranslationToEntity

      public org.apache.jena.rdf.model.Resource registerTranslationToEntity(org.apache.jena.rdf.model.Resource entity, String lang, org.apache.jena.rdf.model.Resource currentGloss, String usage, String word)
    • registerTranslation

      public void registerTranslation(String lang, org.apache.jena.rdf.model.Resource currentGloss, String usage, String word)
      Specified by:
      registerTranslation in interface IWiktionaryDataHandler
    • getPageResourceIRI

      public String getPageResourceIRI(String vocable)
    • getPageResource

      public org.apache.jena.rdf.model.Resource getPageResource(String vocable, boolean dontLinkWithType)
    • getPageResource

      public org.apache.jena.rdf.model.Resource getPageResource(String page)
    • mergePropertiesIntoResource

      protected void mergePropertiesIntoResource(HashSet<PropertyObjectPair> properties, org.apache.jena.rdf.model.Resource res)
    • isResourceCompatible

      protected boolean isResourceCompatible(org.apache.jena.rdf.model.Resource r, HashSet<PropertyObjectPair> properties)
    • addOtherFormPropertiesToLexicalEntry

      protected void addOtherFormPropertiesToLexicalEntry(org.apache.jena.rdf.model.Resource lexEntry, HashSet<PropertyObjectPair> properties)
    • computeOtherFormResourceName

      protected String computeOtherFormResourceName(org.apache.jena.rdf.model.Resource lexEntry, HashSet<PropertyObjectPair> properties)
    • registerDerivation

      public void registerDerivation(String derived)
      Specified by:
      registerDerivation in interface IWiktionaryDataHandler
    • registerDerivation

      public void registerDerivation(String derived, String note)
      Specified by:
      registerDerivation in interface IWiktionaryDataHandler
    • getDerivationStatementId

      public String getDerivationStatementId(String derived)
    • registerInflection

      public void registerInflection(String languageCode, String pos, String inflection, String canonicalForm, int defNumber, HashSet<PropertyObjectPair> props, HashSet<PronunciationPair> pronunciations)
      Specified by:
      registerInflection in interface IWiktionaryDataHandler
    • registerInflection

      public void registerInflection(String languageCode, String pos, String inflection, String canonicalForm, int defNumber, HashSet<PropertyObjectPair> props)
      Specified by:
      registerInflection in interface IWiktionaryDataHandler
      Parameters:
      languageCode - the language code of the inflection
      pos - the part of speech of the inflected form
      inflection - inflected form
      canonicalForm - canonical form
      defNumber - definition number of the word sense associated to the form
      props - morpho syntactic properties to be registered with the inflected form
    • registerInflection

      public void registerInflection(InflectionData key, Set<String> value)
      Specified by:
      registerInflection in interface IWiktionaryDataHandler
    • registerNymRelationToEntity

      public void registerNymRelationToEntity(String target, String synRelation, org.apache.jena.rdf.model.Resource entity)
    • registerNymRelationToEntity

      public void registerNymRelationToEntity(String target, String nymRelation, org.apache.jena.rdf.model.Resource entity, org.apache.jena.rdf.model.Resource gloss, String usage)
    • registerNymRelation

      public void registerNymRelation(String target, String synRelation)
      Specified by:
      registerNymRelation in interface IWiktionaryDataHandler
    • getGlossFilter

      public AbstractGlossFilter getGlossFilter()
      Specified by:
      getGlossFilter in interface IWiktionaryDataHandler
    • createGlossResource

      public org.apache.jena.rdf.model.Resource createGlossResource(String gloss)
      Specified by:
      createGlossResource in interface IWiktionaryDataHandler
    • createGlossResource

      public org.apache.jena.rdf.model.Resource createGlossResource(StructuredGloss gloss)
      Specified by:
      createGlossResource in interface IWiktionaryDataHandler
    • createGlossResource

      public org.apache.jena.rdf.model.Resource createGlossResource(String gloss, int rank)
      Specified by:
      createGlossResource in interface IWiktionaryDataHandler
    • createGlossResource

      public org.apache.jena.rdf.model.Resource createGlossResource(StructuredGloss gloss, int rank)
      Specified by:
      createGlossResource in interface IWiktionaryDataHandler
    • getGlossResourceName

      protected String getGlossResourceName(StructuredGloss gloss)
    • registerNymRelation

      public void registerNymRelation(String target, String synRelation, org.apache.jena.rdf.model.Resource gloss, String usage)
      Specified by:
      registerNymRelation in interface IWiktionaryDataHandler
    • computeNymId

      protected String computeNymId(String nym)
    • computeNymId

      protected String computeNymId(String nym, String pagename)
    • registerNymRelationOnCurrentSense

      public void registerNymRelationOnCurrentSense(String target, String synRelation, org.apache.jena.rdf.model.Resource gloss, String usage)
      Specified by:
      registerNymRelationOnCurrentSense in interface IWiktionaryDataHandler
    • registerPronunciation

      public void registerPronunciation(String pron, String lang)
      Specified by:
      registerPronunciation in interface IWiktionaryDataHandler
    • registerPronunciation

      protected void registerPronunciation(org.apache.jena.rdf.model.Resource writtenRepresentation, String pron, String lang)
    • dump

      public void dump(org.apache.jena.rdf.model.Model box, OutputStream out, String format)
      Description copied from interface: IWiktionaryDataHandler
      Write a serialized represention of this model in a specified language. The language in which to write the model is specified by the lang argument. Predefined values are "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE", "TURTLE", (and "TTL") and "N3". The default value, represented by null, is "RDF/XML".
      Specified by:
      dump in interface IWiktionaryDataHandler
      Parameters:
      box - the Model to be dumped
      out - an OutputStream
      format - a String
    • dumpAllFeaturesAsHDT

      public void dumpAllFeaturesAsHDT(OutputStream ostream, boolean isExolex)
      Specified by:
      dumpAllFeaturesAsHDT in interface IWiktionaryDataHandler
    • nbEntries

      public int nbEntries()
      Specified by:
      nbEntries in interface IWiktionaryDataHandler
    • currentPagename

      public String currentPagename()
      Specified by:
      currentPagename in interface IWiktionaryDataHandler
    • getPrefix

      public String getPrefix()
    • addTo

      public org.apache.jena.rdf.model.Resource addTo(org.apache.jena.rdf.model.Resource target, Set<org.apache.commons.lang3.tuple.Pair<org.apache.jena.rdf.model.Property, org.apache.jena.rdf.model.RDFNode>> pv)
      Specified by:
      addTo in interface IWiktionaryDataHandler
    • addToCurrentWordSense

      public org.apache.jena.rdf.model.Resource addToCurrentWordSense(Set<org.apache.commons.lang3.tuple.Pair<org.apache.jena.rdf.model.Property, org.apache.jena.rdf.model.RDFNode>> pv)
      Specified by:
      addToCurrentWordSense in interface IWiktionaryDataHandler
    • registerExample

      public org.apache.jena.rdf.model.Resource registerExample(String ex, Set<org.apache.commons.lang3.tuple.Pair<org.apache.jena.rdf.model.Property, org.apache.jena.rdf.model.RDFNode>> context)
      Description copied from interface: IWiktionaryDataHandler
      Register example ex for the current lexical sense.
      Specified by:
      registerExample in interface IWiktionaryDataHandler
      Parameters:
      ex - the example string
      context - map of property + RDFNode that are to be attached to the example object.
      Returns:
      a Resource
    • registerExampleOnResource

      public org.apache.jena.rdf.model.Resource registerExampleOnResource(String ex, Set<org.apache.commons.lang3.tuple.Pair<org.apache.jena.rdf.model.Property, org.apache.jena.rdf.model.RDFNode>> context, org.apache.jena.rdf.model.Resource sense)
      Description copied from interface: IWiktionaryDataHandler
      Register example ex for a given lexical sense.
      Specified by:
      registerExampleOnResource in interface IWiktionaryDataHandler
      Parameters:
      ex - the example string
      context - map of property + RDFNode that are to be attached to the example object.
      sense - the Resource of the lexical sens are to be attached with the example object.
      Returns:
      a Resource
    • registerExample

      public org.apache.jena.rdf.model.Resource registerExample(Set<org.apache.commons.lang3.tuple.Pair<org.apache.jena.rdf.model.Property, org.apache.jena.rdf.model.RDFNode>> context)
    • registerExampleOnResource

      public org.apache.jena.rdf.model.Resource registerExampleOnResource(Set<org.apache.commons.lang3.tuple.Pair<org.apache.jena.rdf.model.Property, org.apache.jena.rdf.model.RDFNode>> context, org.apache.jena.rdf.model.Resource sense)
    • computeStatistics

      public void computeStatistics(org.apache.jena.rdf.model.Model statsModel, org.apache.jena.rdf.model.Model sourceModel, String dumpVersion)
      Specified by:
      computeStatistics in interface IWiktionaryDataHandler
    • createGeneralStatisticsObservation

      public static void createGeneralStatisticsObservation(org.apache.jena.rdf.model.Model statsBox, String dumpVersion, String prefix, String lang, long translationCount, long pageCount, long entryCount, long senseCount)
    • createNymRelationObservation

      public static void createNymRelationObservation(org.apache.jena.rdf.model.Model box, String dumpVersion, String prefix, String lang, NymRelation nym, long cr)
    • createTranslationObservation

      public static void createTranslationObservation(org.apache.jena.rdf.model.Model statsBox, String dumpVersion, String prefix, String sourceLanguage, String targetLanguage, long c)
    • populateMetadata

      public void populateMetadata(org.apache.jena.rdf.model.Model metadataModel, org.apache.jena.rdf.model.Model sourceModel, String dumpFilename, String extractorVersion, boolean isExolex)
      //// METADATA /////////
      Specified by:
      populateMetadata in interface IWiktionaryDataHandler
    • buildDatacubeObservations

      public void buildDatacubeObservations(String l, org.getalp.dbnary.enhancer.evaluation.TranslationGlossesStat tgs, org.getalp.dbnary.enhancer.evaluation.EvaluationStats.Stat es, String dumpFileVersion)
      Specified by:
      buildDatacubeObservations in interface IWiktionaryDataHandler