Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

Enrichment Queue
# a typical enrichment specification: 
enrichment_profile = {
  'Krikri::Enrichments::SplitAtDelimiter' => {
     input_fields: [:rights,
                    { dataProvider: :providedLabel },
                    { sourceResource: :identifier },
                    { sourceResource: :title },
                    { sourceResource: :rights },
                    { sourceResource: :extent },
                    { sourceResource: :dcformat },
                    { sourceResource: :genre },
                    { sourceResource: :dctype }]
  },
  'Krikri::Enrichments::RemoveEmptyFields' => {
     input_fields: [:all]
  },
  'Krikri::Enrichments::StripHtml' => {
     input_fields: [:all]
  },
 'Krikri::Enrichments::StripLeadingColons' => {
    input_fields: [{sourceResource: :title}]
  },
  'Krikri::Enrichments::StripLeadingPunctuation' => {
     input_fields: [{ sourceResource: { creator: :providedLabel } },
                    { sourceResource: { contributor: :providedLabel } },
                    { sourceResource: { publisher: :providedLabel } }]
  },
  'Krikri::Enrichments::StripEndingPunctuation' => {
     input_fields: [{ sourceResource: :title },
                    { sourceResource: { creator: :providedLabel } },
                    { sourceResource: { contributor: :providedLabel } },
                    { sourceResource: { publisher: :providedLabel } }]
  },
 'Krikri::Enrichments::StripWhitespace' => {
    input_fields: [{sourceResource: :title}]
  },
 'Krikri::Enrichments::ParseDate' => {
    input_fields: [{ sourceResource: {date: :begin } },
                   { sourceResource: {date: :end } }]
  },	
 'Krikri::Enrichments::TimespanSplit' => {
    input_fields: [{ sourceResource: :date }]
  },
 'Krikri::Enrichments::DcmiTypeMap' => {
    input_fields: [{ sourceResource: :dctype }]
  }
}
 
# Queue enrichment
activity_uri = Krikri::Activity.find(activity_id).rdf_subject
Krikri::Enricher.enqueue({:generator_uri => activity_uri, :chain => enrichment_profile})
 

 

To Run Enrichments Manually

manual enrichment
# first assign a profile as above
activity_uri = Krikri::Activity.find(id).rdf_subject
enricher = Krikri::Enricher.new(generator_uri: activity_uri, chain: enrichment_profile)
 
# this could be improved :(
# choose a small `n` as these will run sequentially
enriched = enricher.generator_activity.entities.take(n).each { |rec| enricher.chain_enrichments!(rec) }
  • No labels