You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
The code already restricts corpora by user. A user can only list and access
corpora created by himself.
On Feb 13, 2014 11:33 AM, "Flávio Codeço Coelho" [email protected]
wrote:
Where do we stand in regards to having access restricted only to owners of
the corpora?
Reply to this email directly or view it on GitHubhttps://github.com//issues/26#issuecomment-34977775
.
Without adding a new resource to pypln.web, this problem could be solved with the code:
defget_corpus_or_create(self, corpus_name, corpus_description=''):
'''Return the `Corpus` object related to a corpus. If the corpus does not exist, create it '''search_corpus= [corpusforcorpusinself.corpora() ifcorpus.name==corpus_name]
ifnotsearch_corpus: # corpus does not exist, need to create itreturnself.add_corpus(corpus_name, corpus_description)
else:
returncorpus_search[0]
Currently if I have a corpus named "test" and I want to access its object, I need some code like this:
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:
We could also see other helper methods in Django's ORM to inspire us and improve library usability.
The text was updated successfully, but these errors were encountered: