Settings

The default SuperTagging settings are:

SUPERTAGGING_SETTINGS = {
    'ENABLED': False,
    'DEBUG': False,
    'WATCHED_FIELDS': {},
    'AUTO_PROCESS': False,
    'ONLY_NON_TAGGED_OBJECTS': False,
    'CONTENTTYPE_NAME_MAPPING': {},
    'INCLUDE_DISPLAY_FIELDS': True,
    'REGISTER_MODELS': True,
    'REMOVE_REL_ON_DISABLE': True,
    'RESOLVE_PROPERTY_KEYS': True,
    'SUBSTITUTE_TAG_UPDATE': True,
    'USE_QUEUE': False,
    'FILE_STORAGE': 'django.core.files.storage.FileSystemStorage',
    'EXCLUSIONS': {
        'MIN_RELEVANCE': 0,
        'REL_TYPE_EXCLUSIONS': [],
        'TAG_TYPE_EXCLUSIONS': [],
        'TAG_TYPE_QUERY_EXCLUSIONS': []},
    'FREEBASE': {
        'DESCRIPTION_URL': 'http://www.freebase.com/api/trans/raw',
        'ENABLED': False,
        'RETRIEVE_DESCRIPTIONS': False,
        'TYPE_MAPPINGS': {}},
    'MARKUP': {
        'CONTENT_CACHE_TIMEOUT': 3600,
        'ENABLED': False,
        'EXCLUDE': [],
        'FIELD_SUFFIX': 'tagged',
        'MIN_RELEVANCE': 0},
    'OPEN_CALAIS': {
        'API_KEY': '',
        'DEFAULT_PROCESS_TYPE': 'TEXT/RAW',
        'PROCESSING_DIRECTIVES': {
            'calculateRelevanceScore': True,
            'contentType': 'TEXT/RAW',
            'docRDFaccessible': True,
            'enableMetadataType': '',
            'outputFormat': 'application/json',
            'reltagBaseURL': ''},
        'PROCESS_RELATIONS': True,
        'PROCESS_SOCIALTAGS': True,
        'PROCESS_TOPICS': True,
        'USER_DIRECTIVES': {
            'allowDistribution': False,
            'allowSearch': False,
            'externalID': '',
            'submitter': 'python-calais client v.1.5'}},
}

ENABLED

Default: False

Whether or not SuperTagging is enabled. Will not process any objects if False. This allows starting and stopping tag processing while preserving the value of AUTO_PROCESS.

DEBUG

Default: False

If True, errors will fail loudly in order to debug the code.

WATCHED_FIELDS

Default: {}

This settings is a dictionary that specifies all the models, fields and options.

The keys of the dictionary are strings in the format app_name.model_name. The value of each key is a dictionary, where the fields and other options are specified.

  • fields - (Required) List of dictionaries that specify field names and its options
    • name - (Required) String The name of the field
    • process_type - (Optional) String The process type that OpenCalais should use when tagging the data, possible values are TEXT/RAW, TEXT/HTML, TEXT/HTMLRAW, or TEXT/XML. Default is the value of DEFAULT_PROCESS_TYPE.
    • markup - (Optional) bool Should SuperTagging automatically markup this field? Default is False.
    • combine_fields - (Optional) list A list of two or more fields on the model to combine into one submission to OpenCalais for processing. Markup is not available for these combined fields.
  • match_kwargs - (Optional) dict A dictionary of extra query parameters to check when processing instances of the model. Performs an extra .get(**kwargs) on the instance to ensure it validates against the extra query parameters.
  • date_field - (Optional) String The name of the field to retrieve the instance date. If this is not specified, supertagging will try to retrieve the data from the instance _meta.get_latest_by or _meta.ordering. This field is saved into SuperTaggedItem to allow easy sorting of the items by date.

Here is a complete example:

SUPERTAGGING_MODULES = {
    'stories.story': {
        'fields': [{
                'name': 'body',
                'process_type': 'TEXT/HTML',
                'markup': True
            }, {
                'name': 'tease'
            }, {
                'name': 'kicker',
                'markup': True
            }],
        'match_kwargs': {
            'status__in': [1,2,3,],
            'published_date__isnull': False},
        'date_field': 'published_date'
    },
    'media.image': {
        'fields': [{'name': 'caption',
                    'process_type': 'TEXT/HTML',
                    'markup': True}],
        'date_field': 'creation_date'
    }
}

INCLUDE_DISPLAY_FIELDS

Default: True

Should SuperTagging include three extra fields for display purposes:

  • description - a text field
  • icon - a image field
  • related - a many2many field to ‘self’ (SuperTag)

AUTO_PROCESS

Default: False

If True, will set up post_save and post_delete signals to process the data.

ONLY_NON_TAGGED_OBJECTS

Default: False

Used with AUTO_PROCESS. If True, will only process objects that have not been tagged before. Objects that have tags but need re-processing must be added to the queue manually.

If False, process all objects.

RESOLVE_PROPERTY_KEYS

Default: True

If True, SuperTagging will try resolve the Calais ID to a tag name.

REGISTER_MODELS

Default: False

If True, an additional attribute will be avilable in a model’s instance for easy query related access to SuperTagging.

SUBSTITUTE_TAG_UPDATE

Default: False

When True, and a substitute is specified in SuperTag all associated SuperTaggedItem and SuperTagRelation will be updated with the new tag.

REMOVE_REL_ON_UPDATE

Default: False

If True, all content related to a tag is removed (items from models SuperTaggedItem and SuperTaggedRelationItem.

FILE_STORAGE

Default: settings.DEFAULT_FILE_STORAGE

Default file storage used for the icon display field.

USE_QUEUE

Default: False

If True, use the queuing system. When a object is saved, it will be saved to a queue for later processing. A management command is included for you to process the queue.

If False, process the object on save.

CONTENTTYPE_NAME_MAPPING

Default: {}

A dict of mapped content type ids to names, used for the views

{
    34: 'stories',
    83: 'images',
}

Where the key is the content type id and the value is the string used in the url:

This:

/supertagging/tag/barack_obama/stories/

/supertagging/tag/barack_obama/images/

instead of this:

/supertagging/tag/barack_obama/34/

/supertagging/tag/barack_obama/83/

This was done in order to make readable urls.

OPEN_CALAIS

DEFAULT_PROCESS_TYPE

Default: TEXT/RAW

Tells the default process type for OpenCalais to process the data.

There are four options that can be supplied.

  • TEXT/RAW
  • TEXT/HTML
  • TEXT/HTMLRAW
  • TEXT/XML

API_KEY

Default: ''

Your OpenCalais API Key

These next two settings are options for open calais.

USER_DIRECTIVES

Default:

{
    "allowDistribution": False,
    "allowSearch": False,
    "externalID": '',
    "submitter": "python-calais client v.1.5",
}

View Input Parameters on OpenCalais.com for more information.

PROCESSING_DIRECTIVES

Default:

{
    "contentType": "TEXT/RAW",
    "outputFormat": "application/json",
    "reltagBaseURL": '',
    "calculateRelevanceScore": True,
    "enableMetadataType": '',
    "docRDFaccessible": True,
}

View Input Parameters on OpenCalais.com for more information.

PROCESS_RELATIONS

Default: False

If True, save the tag relations (Events/Facts) returned by OpenCalais

PROCESS_TOPICS

Default: False

If True, save the topics returned by OpenCalais. These will simply be added as tags, but will not include all tag details.

PROCESS_SOCIALTAGS

Default: False

If True, save the social tags returned by OpenCalais. These will simply be added as tags, but will not include all tag details.

EXCLUSIONS

TAG_TYPE_EXCLUSIONS

Default: []

Tag types as strings to exclude from being added. These tags should be all the “Entities” listed on the following link.

OpenCalais Entities, Events and Facts

REL_TYPE_EXCLUSIONS

Default: []

Same as above but these are the relations and are shown on the following link as “Events and Facts”

OpenCalais Entities, Events and Facts

TAG_TYPE_QUERY_EXCLUSIONS

NOT IMPLEMENTED (YET)

Tags will be saved, but not returned in the queries

MIN_RELEVANCE

Default: 0

Integer between 0 and 1000, will only save tags that have a higher relevance that this setting.

FREEBASE

ENABLED

Default: False

Use Freebase to disambiguate the tags?

TYPE_MAPPINGS

Default: {}

For better disambiguation, use this setting to map Calais types to freebase types.

RETRIEVE_DESCRIPTIONS

Default: False

If the display fields are enabled, you can have freebase retrieve the description for the tags.

DESCRIPTION_URL

Default: "http://www.freebase.com/api/trans/raw"

The first part of the url from where to retrieve the descriptions.

MARKUP

ENABLED

Default: False

Is automatic markup of content enabled?

MIN_RELEVANCE

Default: 0

Integer between 0 and 1000, tells SuperTagging the minimum relevance to use when marking up the content.

FIELD_SUFFIX

Default: "tagged"

If markup is enabled, SuperTagging will add a field to the instance with the marked up content, this setting specifies the suffix.

For example: if 'body' field is marked for tagging, by default a field called 'body__tagged' will be available in the instance that contains the content with marked up content.

EXCLUDES

Default: []

List of strings of values to exclude from being marked up. For example, OpenCalais returns ‘his’, ‘her’, ‘him’ etc. in reference to a tag.

CONTENT_CACHE_TIMEOUT

Default: 3600

Cache timeout for the markup content in seconds.