com.aetrion.flickr.machinetags
Class MachinetagsInterface

java.lang.Object
  extended by com.aetrion.flickr.machinetags.MachinetagsInterface

public class MachinetagsInterface
extends java.lang.Object

A more precise way to tag and to search photos.

What are machine tags?

Machine tags are tags that use a special syntax to define extra information about a tag.
Machine tags have a namespace, a predicate and a value. The namespace defines a class or a facet that a tag belongs to ('geo', 'flickr', etc.) The predicate is name of the property for a namespace ('latitude', 'user', etc.) The value is, well, the value.
Like tags, there are no rules for machine tags beyond the syntax to specify the parts of a machine tag. For example, you could tag a photo with:

Flickr has already used machine tags, informally, on a couple of occasions:

What is the spec for machine tags?

Machine tags are divided in to three parts:
  1. A "namespace":

    Namespaces MUST begin with any character between a - z; remaining characters MAY be a - z, 0 - 9 and underbars. Namespaces are case-insensitive.

  2. A "predicate":

    Predicates MUST begin with any character between a - z; remaining characters MAY be a - z, 0 - 9 and underbars. Namespaces are case-insensitive.

  3. A "value":

    Values MAY contain any characters that a "plain vanilla" tags use. Values may also contain spaces but, like regular tags, they need to wrapped in quotes.

Namespace and predicates are separated by a colon : ":"

Predicates and values are separated by an equals symbol : "="

For example:

Why can't I use non-ASCII characters for namespaces and predicates?

Simple steps, first.

Can I define another machine tag as the value of a machine tag?

Sure, but it will not be processed as a machine tag itself.

How do I add machine tags?

By adding tags! No, really. Machine tags are added *exactly* the same as any other tag whether it is done through the website or the API. When the Flickr supercomputer processes your tags, we take a moment to check whether it is a machine tag. If it is we leverage the powerful Do What I Mean engine to, well, do what you mean.

How do I query machine tags?

Via the API!

Specifically, using the "machinetags" parameter in the 'flickr.photos.search' method. Like tags, you can specify multiple machine tags as a comma separated list.

Can I query the various part of a machine tag?

Yes. Aside from passing in a fully formed machine tag, there is a special syntax for searching on specific properties :

Is there a limit to the number of machine tags I can query?

Yes. The limit depends on the tag mode (ALL or ANY) that you are querying with. "ALL" (AND) queries are limited to (16) machine tags. "ANY" (OR) queries are limited to (8).

Can I do range queries on machine tags?

No. Not yet, anyway.

It is a hard problem for reasons far too dull to get in to here. It's on the list.

Are machine tag namespaces reserved?

No. Anyone can use a namespace for anything they want.

If you are concerned about colliding namespaces you should consider adding an additional machine tag to define your namespace. For example:

dc:subject=tags
xmlns:dc=http://purl.org/dc/elements/1.1/
Like tags, in general, we expect (hope?) that the community will develop its own standards by consensus over time.

What about all the machine tags that are already in the Flickr database?

At the moment, they are still treated as plain old tags.

We have plans to go back and re-import them as machine tags but for now, only new tags will be processed as machine tags.

In the meantime, if you re-save a machine from the 'edit this tag' page it will be re-imported as a machine tag.

Is the predicate *really* a predicate?

You are in a dark cave. In the corner is a fire and a man making bunny shadows on the wall with his hands. Whether or not it's really a 'predicate' depends on how much time you spend on the semantic-web mailing list. ;-)

It's close enough to being a predicate that it makes for a good short-hand.

Wait, aren't machine tags just RDF?

No, machine tags are not RDF; they could play RDF on television, though.

See also: http://weblog.scifihifi.com/2005/08/05/meta-tags-the-poor-mans-rdf

Huh, what is RDF?

RDF Describes Flickr. That's really all you need to know about RDF.

Version:
$Id: MachinetagsInterface.java,v 1.3 2009/07/11 20:30:27 x-mago Exp $
Author:
mago
See Also:
http://code.flickr.com/blog/2008/07/18/wildcard-machine-tag-urls/, http://code.flickr.com/blog/2008/08/28/machine-tags-lastfm-and-rocknroll/, http://blech.vox.com/library/post/flickr-exif-machine-tags.html, machine-tag-browser

Constructor Summary
MachinetagsInterface(java.lang.String apiKey, java.lang.String sharedSecret, Transport transportAPI)
           
 
Method Summary
 NamespacesList getNamespaces(java.lang.String predicate, int perPage, int page)
          Return a list of unique namespaces, optionally limited by a given predicate, in alphabetical order.
 NamespacesList getPairs(java.lang.String namespace, java.lang.String predicate, int perPage, int page)
          Return a list of unique namespace and predicate pairs, optionally limited by predicate or namespace, in alphabetical order.
 NamespacesList getPredicates(java.lang.String namespace, int perPage, int page)
          Return a list of unique predicates, optionally limited by a given namespace.
 NamespacesList getRecentValues(java.lang.String namespace, java.lang.String predicate, java.util.Date addedSince)
          Fetch recently used (or created) machine tags values.
 NamespacesList getValues(java.lang.String namespace, java.lang.String predicate, int perPage, int page)
          Return a list of unique values for a namespace and predicate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MachinetagsInterface

public MachinetagsInterface(java.lang.String apiKey,
                            java.lang.String sharedSecret,
                            Transport transportAPI)
Method Detail

getNamespaces

public NamespacesList getNamespaces(java.lang.String predicate,
                                    int perPage,
                                    int page)
                             throws FlickrException,
                                    java.io.IOException,
                                    org.xml.sax.SAXException
Return a list of unique namespaces, optionally limited by a given predicate, in alphabetical order. This method does not require authentication.

Parameters:
predicate -
perPage -
page -
Returns:
NamespacesList
Throws:
FlickrException
java.io.IOException
org.xml.sax.SAXException

getPairs

public NamespacesList getPairs(java.lang.String namespace,
                               java.lang.String predicate,
                               int perPage,
                               int page)
                        throws FlickrException,
                               java.io.IOException,
                               org.xml.sax.SAXException
Return a list of unique namespace and predicate pairs, optionally limited by predicate or namespace, in alphabetical order. This method does not require authentication.

Parameters:
namespace - optional, can be null
predicate - optional, can be null
perPage - The number of photos to show per page
page - The page offset
Returns:
NamespacesList containing Pair-objects
Throws:
FlickrException
java.io.IOException
org.xml.sax.SAXException

getPredicates

public NamespacesList getPredicates(java.lang.String namespace,
                                    int perPage,
                                    int page)
                             throws FlickrException,
                                    java.io.IOException,
                                    org.xml.sax.SAXException
Return a list of unique predicates, optionally limited by a given namespace. This method does not require authentication.

Parameters:
namespace - The namespace that all values should be restricted to.
perPage - The number of photos to show per page
page - The page offset
Returns:
NamespacesList containing Predicate
Throws:
FlickrException
java.io.IOException
org.xml.sax.SAXException

getValues

public NamespacesList getValues(java.lang.String namespace,
                                java.lang.String predicate,
                                int perPage,
                                int page)
                         throws FlickrException,
                                java.io.IOException,
                                org.xml.sax.SAXException
Return a list of unique values for a namespace and predicate. This method does not require authentication.

Parameters:
namespace - The namespace that all values should be restricted to.
predicate - The predicate that all values should be restricted to.
perPage - The number of photos to show per page
page - The page offset
Returns:
NamespacesList
Throws:
FlickrException
java.io.IOException
org.xml.sax.SAXException

getRecentValues

public NamespacesList getRecentValues(java.lang.String namespace,
                                      java.lang.String predicate,
                                      java.util.Date addedSince)
                               throws FlickrException,
                                      java.io.IOException,
                                      org.xml.sax.SAXException
Fetch recently used (or created) machine tags values. This method does not require authentication.

Parameters:
namespace - The namespace that all values should be restricted to.
predicate - The predicate that all values should be restricted to.
addedSince - Only return machine tags values that have been added since this Date.
Returns:
NamespacesList
Throws:
FlickrException
java.io.IOException
org.xml.sax.SAXException


Copyright (C) 2005-2008 Aetrion LLC. All Rights Reserved.