Functionality similar to CoreNLP's OpenIE on spaCy - tuples

I like spaCy. However, I want functionality like that of CoreNLP's OpenIE, wherein I get the Subject, Verb & Predicate out-of-the-box. What are my options? Should I use both the frameworks?

Try AllenNLP's pretrained OpenIE model: https://demo.allennlp.org/open-information-extraction. (Note: AllenNLP uses spaCy)

Related

Using UniqueEntity outside of Symfony stack

I have an app built on top of Silex and I'm using Doctrine as my ORM.
I have a problem where I'm trying to get a clean error for when a user tries to reuse an email, I found the validator UniqueEntity but it seems to be designed for the full stack version of Symfony.
My question is, is this true? I'm going a limb and assuming it as I haven't found anyone who successfully used it outside of Symfony.
My second question is, if I'm not able to use UniqueEntity, whats my next best option? I'm using the Symfony Validator component and would like to use something that's plugged into that to keep it all in the same block of code.
You can use UniqueEntity with Silex.
Here's the service provider package with the Doctrine ManagerRegistry implementation - saxulum/saxulum-doctrine-orm-manager-registry-provider. Also you can find the instructions how to use it with the UniqueEntity validator in README.
But you may want to implement you own UniqueEntity validator.
For example, if you want to validate DTO object (or any non-entity object), because it's not supported by Symfony's UniqueEntity validator (see issue on GitHub).

django internalization in urls? how to make urls like this: "en/articles" and "pt/artigos"...?

Hy!
I would need to make urls based on language.
Example:
If I had the language english and subcategory named "articles" then the url might be like this:
/en/articles/...
If the language were portuguese and subcategory already translated is "artigos" then the url will be:
/pt/artigos/...
How can I do it?
I must use the urls.py or some monkeypatches?
thanks
This features is already existing in the yet-to-be released version 1.4. You can read about it in the release note.
If your really need this feature, and no existing app feets your needs, you can still try to apply the corresponding patch yourself.
Django LocaleURL is a piece of middleware that does exactly this. The documentation can be found in the source, or online.
Edit: I read over the fact that you want to translate the url itself... I'm not aware of any piece of code that provides this. Perhaps you could extend the LocalURL middleware to take care of the translations for you. Say you have a regex match like (?P<articles>\w+), you could in the middleware determine which view you want to use. Something like the following mapping perhaps?
if article_slug in ['articles', 'artigos', 'article']:
article(request) # Call the article view
I've been using transurlvania with great success, it does exactly what you need and more, however i see that in the next Django release django-i18nurls will be included in django core so perhaps it would be better to learn that

How do you access/configure summaries/snippets in Django Haystack

I'm working on getting django-haystack set up on my site, and am trying to have snippets in my search results roughly like so:
Title of result one about Wikis ...this special thing about wiki values is that...I always use a wiki when I walk...snippet value three talks about wikis too...and here's another snippet value
about wikis.
I know there's a template tag that uses Haystack code to do the the highlighting, but the snippets it generates are pretty limited:
they always start with the query word
there's only one snippet value
they don't support asterisk queries
and other stuff?
Is there a way to use the Solr backend to generate proper snippets as shown above?
Bottom line is that the Solr highlighting can't really be used by Haystack in a flexible way. I spoke to the main developer for Haystack on IRC, and he said basically, if I want to have the kind of highlighting I'm looking for, the only way to get it is to extend the Solr backend that Haystack uses.
I dabbled in that for about half a day, but couldn't get Haystack to recognize my custom back end. Haystack has some magic backend loading code that just wasn't working with me.
Consequently, I've switched over to sunburnt, which provides a lighter-weight and more extensible wrapper around Solr. I'm hoping it will fare better.
from haystack.utils import Highlighter
my_text = 'This is a sample block that would be more meaningful in real life.'
my_query = 'block meaningful'
highlight = Highlighter(my_query)
highlight.highlight(my_text)
http://docs.haystacksearch.org/dev/highlighting.html

Product of two fields annotation

I currently have a line in my Django app like this:
db.execute("SELECT SUM(price * qty) FROM inventory_orderline WHERE order_id = %s", [self.id])
I'd rather perform this through the models interface provided my Django, but can't find any references.
I'm pretty sure this can be done with an annotation, but the examples only cover a few of them and I can't find a list in the documentation.
I'd like to do something like this:
self.line_items.annotate(lineprice=Product('orderline__price', 'orderline__qty')).aggregate(Sum('lineprice'))
Can anyone suggest an annotation class to use to perform the multiplication? Even better, a link to the API listing all these annotation/aggregation classes?
It's not clearly documented, but this can be done with the F() function:
from django.db.models import F
self.line_items.annotate(lineprice=F('orderline__price') * F('orderline__qty')).aggregate(Sum('lineprice'))
Unfortunately, there aren't enough inbuilt Aggregate functions and specifically, there is not one for Product.
But that doesn't limit you in any way other than having to write a "non-concise" ORM query. Specifically for your case, you should be able to do:
self.line_items.extra(select=("lineprice": "orderline__price*orderline__qty")).aggregate(Sum('lineprice'))

Is there anything like ruby's .send in HTMLBars or Handlebars?

Was wondering if there's anything like ruby's .send for htmlbars. Been trying to search for it, but can't seem to find a proper answer. Here's what I want to do:
{{"name-of-helper" arguments}}
As simple as this. Is there any trick under it to achieve this effect?
There is no built-in one or supplemented one but if you need it you can write one for yourself.
Ember includes "component" helper which allows you to dynamically build component - it's not exactly the same, but might suit your needs.