Is it possible to filter dbpedia results using url parameters? - dbpedia

A sample dbpedia page: http://dbpedia.org/page/United_States
How do get back just the abstract text?
Can this be done using just url parameters and get the result back in json?

The result back in JSON is easy, try this http://dbpedia.org/data/United_States.jsod
for more control I suppose you need to use SPARQL

Related

How to convert user natural query into SQL query?

I am trying to build a chatbot in Rasa/Dialogflow, the problem i ham facing is to convert English to SQL query so that what user write in English can be converted into SQL fetch data from MYSQL database and display result to use.
Can someone suggest me how to do it?
Ideally this is only possible through solutions like SEQ2SQL(Link here for reference).
But I implemented it in a workaround fashion:-
I got the json using tracker.latest_message .
After which I processed the json to make our own structured json like:
[{'column_name':'a',
'operator': '=',
'value':'100'},
{'column_name':'b',
'operator': '>',
'value':'100'}]
Above structure was used to form the where clause of the query.
Same way I made a custom json for Select Part as well :-
[{sum:column1},{count:column2}]
5.Then I looped through the json I had created and made our queries.
Note:- This json Structure will not be able to cover all possible scenarios but worked decently for me.

Marklogic : "highlight" seem not work withe Node.js and QueryBuilder

I try to get an extract of the text with the searched words highlighted on a JSON collection.
My search syntax is:
qb.word(qb.field('doc_text'),vartxt)
With 'doc_text' declared as field
(field type: root, include root: false, includes: doc_text), in an Node.js application.
The search works well, and it is done well on this field ...
But in txt[0].results[kl].matches[0]['match-text'], I find the first 3 properties of the JSON,
and not an extract from 'doc_text' with the words found.
I have another application in which the highlights work correctly, but it is based on XML.
Did I forget something in the field declaration, or is the operation different between JSON
and XML data, or is the highlight system not running on JSON via Node.js and QueryBuilder ?
Kind regards
Fields do not work quite the same way in XML and JSON. I think you're running into this limitation:
http://docs.marklogic.com/guide/app-dev/json#id_24090
The value of a field in XML can be the concatenation of all the text nodes, but the same does not apply in JSON.
I think I understood !!!
This query gives a correct snippet, with the extract and the words highlighted :
mkcq.and(mkcq.collection('document'), mkcq.word(mkcq.field('doc_text'), 'connaitre'))
On the other hand, this query gives the first 3 fields of the JSON :
mkcq.and(mkcq.collection('document'), mkcq.word(mkcq.field('doc_text'), 'connaitre'), mkcq.value(mkcq.element('','doc_user'), 'mbp'))
I do not know if this is normal or not, but it should be able to be corrected either by a simplified query and a selection on the returned records, evening by a particular snippeter.
Kind regards

How can the submitted values in a POST message be accessed in Rust/Iron framework?

I am using a form which uses the POST method to submit the input. Is it possible to access the input like accessing a dictionary? I think there must be a better way than parsing the request body.
You can use the params crate for this.
With this crate, you can get the POST parameters with:
let params = req.get_ref::<Params>();
(See the example for a complete code.)

Zend Framework 2 Paginating Search Results

I'm making a complex search form with a lot of inputs to query and I want to paginate the search results using Zend Framework 2.
I've found a few people who are trying to do something similar but I have yet to find a good solution.
Some people suggested switching to $_GET method instead of $_POST but i would prefer to avoid this because of the number of form elements.
The results are coming up fine, but as soon as i try to navigate to the second page, the query is lost and it is essentially paginating all records on the table.
What is the best way to store the original search query so that the paginated results are the actual results?
I can't imagine ZF2 doesn't have an easy way to paginate $_POST results but I haven't been able to figure it out yet
well you either need to repost the search parameters on every page request or keep the search parameters in a session and on the second request check if the request is get or post and use the session if it is get

Looking up types from Freebase

I am trying to find a list of relevant types to a certain string from Freebase, lets say for example i enter Jordan, then i will have a list with types country, person, athlete .. etc.
I have found several ways for the query, for example:
First Query
trying to get the JSON fails, using:
$.getJSON('http://api.freebase.com/api/service/search?query=jordan',function (data) {
console.log(data);
});
There is another query that gives me better result, as i only get the types here but i also cannot get the JSON file from it.
Will appreciate any help.
Your problem has probably less to do with freebase and more to do the fact that you can't do cross domain http requests. You are requesting data from api.freebase.com but you are probably hosting this page in another domain.
You can use the JSONP mechanism to circumvent that restriction, here is some documentation:
http://api.jquery.com/jQuery.getJSON/
Read the section JSONP.
Another couple of points:
Are you trying to search for all entities that somehow match the word "jordan" or are you looking for exactly all the entities that are named "jordan" ? Your best bet is to use the /search API instead of /mqlread which is for structured database queries.
You are also using the legacy API that is deprecated. Here is some docs on the new API:
http://wiki.freebase.com/wiki/API
Here's how your request will look (note that you 'll need an API key for production):
https://www.googleapis.com/freebase/v1/search?query=jordan&mql_output=[{%22name%22%20:%20null,%22type%22:[]}]

Resources