Skip to main content

Plug-n-Play Simple Tag Library

Project description

Build Status Coverage Status PyPi

Source

https://github.com/yangacer/simpletag

Usage

>>> import simpletag

>>> ns = simpletag.TextNS('myTextTagSpace') # Create a namespace of text IDs
... # Create integer IDs namespace with `simpletag.IntNS()`

>>> doc_1 = '/a/b'
>>> tags_1 = ['tag']

>>> doc_2 = '/b/a'
>>> tags_2 = 'tag simple!'

>>> ns.update(doc_1, tags_1)
>>> ns.update(doc_2, tags_2)

>>> print [ doc for doc in ns.query_ids('tag') ]
[u'/a/b', u'/b/a']

>>> print [ tag for tag in ns.query_tags(doc_1) ]
[u'tag']

>>> print [ st for st in ns.stats() ]
[{
    'term': u'simple', 'documents': 1, 'occurrences': 1
}, {
    'term': u'tag', 'documents': 2, 'occurrences': 2
}]

>>> ns.purge()

Tag Query

Tag set query with SQLite FTS query syntax.

>>> ns.update(1, [u'民主', u'自由'])
>>> ns.update(2, [u'民主', u'Cxin123'])

>>> query  = ''
... # Query IDs of tags '民主' but not 'Cxin*' (tags start with Cxin)

>>> if ns.using_parenthesis_query:
>>>     query = u'民主 NOT Cxin*'
>>> else:
>>>     query = u'民主 -Cxin*'

>>> print [tag for tag in ns.query_ids(query)]
[1]
NOTE SQLite supports standard and parenthesis syntax, and the two are enabled mutual exclusively at compiling SQLite. Detect which one being used thru simpletag.ns.using_parenthesis. See SQLite documentation for further information.

TODOs

  • As a Flask plug-in

  • Benchmark

  • Further tags analytics (e.g. top-k ~ KNN classification)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simpletag-0.1.6.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file simpletag-0.1.6.tar.gz.

File metadata

  • Download URL: simpletag-0.1.6.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for simpletag-0.1.6.tar.gz
Algorithm Hash digest
SHA256 d922194a8f9d25521fc74a170fee9aef0cb419328c72df6ef0cea1be9f8daa87
MD5 82bb5c97e74ff716f2c2bd7a0a14a36b
BLAKE2b-256 eaf2976982acae396301890745efc94bbcc90d232b1e64cd269a1f3002305ad1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page