dossier/store/store.py
def feature_index(*feature_names):
    '''Returns a index creation function.

    Returns a valid index ``create`` function for the feature names
    given. This can be used with the :meth:`Store.define_index`
    method to create indexes on any combination of features in a
    feature collection.

    :type feature_names: list(unicode)
    :rtype: ``(val -> index val)
              -> (content_id, FeatureCollection)
              -> generator of [index val]``
    '''
    def _(trans, (cid, fc)):
        for fname in feature_names:
            feat = fc.get(fname)
            if feat is None:
                continue
            elif isinstance(feat, unicode):
                yield trans(feat)
            else:  # string counter, sparse/dense vector
                for val in feat.iterkeys():
                    yield trans(val)
    return _
def feature_index(*feature_names):
    '''Returns a index creation function.

    Returns a valid index ``create`` function for the feature names
    given. This can be used with the :meth:`Store.define_index`
    method to create indexes on any combination of features in a
    feature collection.

    :type feature_names: list(unicode)
    :rtype: ``(val -> index val)
              -> (content_id, FeatureCollection)
              -> generator of [index val]``
    '''
    def _(trans, (cid, fc)):
        for fname in feature_names:
            feat = fc.get(fname)
            if feat is None:
                continue
            elif isinstance(feat, unicode):
                yield trans(feat)
            else:  # string counter, sparse/dense vector
                for val in feat.iterkeys():
                    yield trans(val)
    return _
Returns a index creation function.

    Returns a valid index ``create`` function for the feature names
    given. This can be used with the :meth:`Store.define_index`
    method to create indexes on any combination of features in a
    feature collection.

    :type feature_names: list(unicode)
    :rtype: ``(val -> index val)
              -> (content_id, FeatureCollection)
              -> generator of [index val]``