Estensione:CommonsMetadata

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page Extension:CommonsMetadata and the translation is 23% complete.

Outdated translations are marked like this.
Other languages:
English • ‎dansk • ‎español • ‎italiano • ‎polski • ‎sicilianu • ‎中文 • ‎日本語
Manuale sulle Estensioni MediaWiki
OOjs UI icon advanced.svg
CommonsMetadata
Stato della release: stabile
Implementazione API
Descrizione Prova ad estrarre metadati dalle pagine commons
Autore(i) Brian Wolff (bawolfftalk)
Politica di compatibilità release branches
MediaWiki 1.25+
PHP 5.4+
Cambi della base di dati No
Licenza GNU General Public License 2.0 or later
Scaricare
Parametri

  • $wgCommonsMetadataForceRecalculate
  • $wgCommonsMetadataSetTrackingCategories
Hook usati
GetExtendedMetadata
ValidateExtendedMetadataCache
ContentAlterParserOutput
Traducete l'estensione CommonsMetadata se è disponibile su translatewiki.net
Verificare uso e versione della matrice.
Problemi Compiti aperti · Riportare un bug

L'estensione CommonsMetadata è un tentativo di estrarre metadati dalle pagine di Wikimedia Commons. Aggiunge alcune informazioni extra all'API imageinfo, basate su template e categorie presenti nella descrizione dell'immagine.

L'estensione nella sua forma attuale è intesa come soluzione temporanea, da sostituirsi con Wikidata su Commons.

Motivazioni e scelte progettuali

Vedi http://lists.wikimedia.org/pipermail/wikitech-l/2013-August/071593.html

Le assunzioni fatte per questa estensione sono le seguenti.

  • Ad un certo punto in futuro, wikidata prenderà in mano la gestione dei metadati su commons. Per evitare cambiamenti troppo marcati, che verrebbero subito modificati nuovamente, l'estensione dovrebbe lavorare con i metadati di commons, come avviene attualmente (senza introdurre nuove funzioni di analisi). Da qui lo screen scraping.
  • The content of many of the fields on a commons description page include rich formatting (In particular: Links, italics, bold. In some cases more complex things like embedded images)
    • As a result, extension outputs parsed html (wikitext sucks, plain text doesn't capture the data)
    • Futhermore, the data tends to be formatted for human display, rather than (for example) machine formatted dates. When the date field says something like "circa 1600s", its hard to convert that to a precise date (otoh, many examples can be).
    • To carry that forward, also apply formatting to exif metadata, which is controlled on wiki (For example, commons links the camera name to a wikipedia article)
  • If we can't extract info from the description page, but the file has the author tagged in exif/XMP/iptc metadata, we should use that as a fallback.
  • Ideally such a system would be as commons-inspecific as possible, with the commons and non-commons part separated.
  • Commons description pages have multilingual descriptions. Lots of users probably just want one language.
    • In this implementation, it applies per language conventions to dates and things. Additionally for explicitly multi-lingual fields (description), there is an option to return all, or just a single language. Even in single language mode, some things are still language specific (like the thousands seperator on numbers)

Installazione

  • Download and place the file(s) in a directory called CommonsMetadata in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    wfLoadExtension( 'CommonsMetadata' );
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

To users running MediaWiki 1.24 or earlier:

The instructions above describe the new way of installing this extension using wfLoadExtension() If you need to install this extension on these earlier versions (MediaWiki 1.24 and earlier), instead of wfLoadExtension( 'CommonsMetadata' );, you need to use:

require_once "$IP/extensions/CommonsMetadata/CommonsMetadata.php";

Testing

Attenzione Attenzione: If you're developing or testing this extension, we do NOT suggest you copy the Commons templates for image metadata, as they take extremely long to compile and have complicated dependencies like Scribunto. Instead, get an expanded version that has only wikitext/HTML and put in the various parameter references (or don't) manually. You can find an example (to be used with Special:Import) here. Or use Vagrant which includes certain templates by default.

When testing with remote images (e.g. Commons images if you have enabled $wgUseInstantCommons ), you can set $wgCommonsMetadataForceRecalculate = true; to force CommonsMetadata to parse the description page of the image and extract the metadata (normally, if the remote repository had CommonsMetadata installed as well, it would just copy the API output from there).

Uso

Usa l'API imageinfo ed inserisci extmetadata come proprietà dell'informazione dell'immagine specificata attraverso il parametro iiprop.

https://commons.wikimedia.org/w/api.php?action=query&prop=imageinfo&format=json&iiprop=extmetadata&iilimit=10&titles=File%3ACommon%20Kingfisher%20Alcedo%20atthis.jpg
https://www.mediawiki.org/wiki/Special:ApiSandbox#action=query&prop=imageinfo&format=json&iiprop=extmetadata&iilimit=10&titles=File%3ACommon%20Kingfisher%20Alcedo%20atthis.jpg

Returned data

The extension currently provides the following items in the extmetadata field of the response (the field names were chosen, where possible, to follow the IPTC-IIM format used in EXIF headers):

Data based on machine-readable data in the Information template:

  • ImageDescription - image description
  • Artist - author name (might contain complex HTML, multiple authors etc)
  • Credit - source
  • DateTimeOriginal - time of creation (space-separated ISO 8601 timestamp whenever possible, but can be any other textual description of a date, possibly with HTML mixed in)
  • ObjectName - title (for a book/painting; otherwise just the file name)
  • Permission - contents of the Permission field of the template. Can be a lot of things (license template, OTRS id, details on how to attribute...)
  • AuthorCount - the number of templates with authors (e.g. Book, Photograph...). The number of actual authors might be higher if a template describes multiple authors in a single string.

Data based on machine-readable data in the Location template:

  • GPSLatitude - latitude
  • GPSLongitude - longitude
  • GPSMapDatum - coordinate type (only WGS-84 supported for now)

Data based on machine-readable data in the license template:

  • LicenseShortName - short human-readable license name
  • LicenseUrl
  • UsageTerms
  • Copyrighted - True or False (for public domain images)

For multi-licensed images these values are currently unreliable.

  • Attribution - custom attribution that should replace Artist + Credit (can also originate from the Information template)
  • AttributionRequired - booleanish (phab:T86726), tells whether there is a legal requirement to attribute
  • NonFree - booleanish, true means the image is not under a free license. (Used for non-Commons images only.)

Other data:

  • CommonsMedadataExtension - contains the metadata parser version number; mostly for internal use
  • License - a best guess at the license of the image (mostly for internal use by MediaViewer, might change; LicenseShortName is probably more reliable)
  • Categories - a |-separated list of the categories of the image.
  • Assessments - a |-separated list of the assessments of the image (currently five values are supported: poty, potd, featured, quality, valued). Based on parsing category names, probably won't work for images not hosted on Commons.
  • Restrictions - reuse restrictions such as trademarks or personality rights; an array of keywords (the class names from this table, without the restriction- prefix). See also the restrict-* icons in MediaViewer.
  • DeletionReason - if set, the template is being considered for deletion. (Based on the nuke template, probably not reliable outside Commons.) It contains a deletion reason, but it is phrased to be applicable for a log entry, so it might be misleading (e.g. past tense when actually it is not yet decided whether the image will be deleted).

Vedi anche