Skip to content

Get corpus object by corpus name #26

@turicas

Description

@turicas

Currently if I have a corpus named "test" and I want to access its object, I need some code like this:

from pypln.api import PyPLN

pypln = PyPLN('http://demo.pypln.org', ('username', 'myprecious'))
corpora = pypln.corpora()
test_corpus = [corpus for corpus in corpora if corpus.name == 'test']

We should provide better methods of retrieving corpora (better if the API provides special methods for it).
Another possible helper method is something like "get_corpus_or_create", for example:

from pypln.api import PyPLN

pypln = PyPLN('http://demo.pypln.org', ('username', 'myprecious'))
test_corpus = pypln.get_corpus_or_create('test')

We could also see other helper methods in Django's ORM to inspire us and improve library usability.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions