Wikipedia API: How to get the City of a Place / Page / Article - wikipedia-api

I want to get the city of Eiffel Tower Page by using Wikipedia API.
I used below code to get the Abstract Intro, WikiPageID, WikiURL, Thumbnail/Image, WikiDataID & Coordinates of wiki title Eiffel_Tower.
https://en.wikipedia.org/w/api.php?action=query&titles=Eiffel_Tower&prop=extracts|info|pageimages|coordinates|pageprops&exintro&explaintext&redirects&inprop=url
How could I get the Parent of Places?
Suppose I want City / District / State / Country of Wikipedia Places Page.
For Eiffel Tower page Wikipedia show Location detail as in Paris [City] and France [Country].

First find the Wikidata ID of the article (manually by following the "Wikidata item" link in the sidebar, programmatically e.g. by using the action=query&prop=pageprops API module), then use the Wikidata Query Service , e.g.
SELECT ?item ?itemLabel WHERE { wd:Q243 wdt:P17|wdt:P131 ?item }

Related

amadeus api where if the list of all cityCodes

In Amadeus API the is often a reference to "cityCode"
The documentation give this example
https://test.api.amadeus.com/v2/shopping/hotel-offers?cityCode=PAR&adults=1&radius=5&radiusUnit=KM&paymentPolicy=NONE&includeClosed=false&bestRateOnly=true&view=FULL&sort=PRICE
Where is the list of ALL cityCode ???
for this example it seems PAR refers to PARIS
is this https://service.unece.org/trade/locode/fr.htm
is there a cvs format of all city codes ?
Thanks
You can use the Airport & City Search API to find an IATA code based on a city name
Otherwise, this website provides a list of IATA city codes.

How to get a parameter from Wikipedia infobox?

I would like to get infobox section from Wikipedia. I tried to use the Wikipedia API but the response is very complex:
https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&rvsection=0&titles=Cristiano_Ronaldo&format=json
I need for example to extract only date of birth parameter. Is it possible?
In your example, you need date of birth for Cristiano Ronaldo, but this Wikipedia article is associated with Wikidata Item Q11571. This item usually include the most of Wikipedia Infobox parameters (as Property:P569 - date of birth).
So, for your case it is better idea to use Wikidata API:
https://www.wikidata.org/w/api.php?action=wbgetentities&sites=enwiki&props=claims&titles=Cristiano_Ronaldo
The response include the date of birth under property P569, and a lot of other information as place of birth, image, sex, official website, country, etc:
...
"P569": [{
"mainsnak": {
"datavalue": {
"value": {
"time": "+1985-02-05T00:00:00Z",
...

Babelnet categories

I'm trying to retrieve all the synsets categories of a given word in Babelnet via RESTful API.
E.G.
If you go to http://babelnet.org and search for Java you can see 17 results beloging to 7 categories (Game and videogames, Drink and beverage, Information Technology and so on).
How can I get the category of each synSet via API?
In the API list there is no reference to the categories..
Thank you all.
You can get all synset's categories using the getCategories() method.
BabelSynset by = bn.getSynset(new BabelSynsetID("bn:03083790n"));
List<BabelCategory> cats = by.getCategories();

Fashion related content queries (DBpedia or Freebase)

I'm trying to figure out how to make some queries through which I should get fashion related content, like an list of known cloth types, or cloth manufactures, or well known fashion designers.
I have spent the last few days trying to figure out to make such an query through DBpedia or Freebase, but I couldn't seem to figure it out. Examples that kinda match what I need I couldn't find...
Can someone help me with this, some short example on which I can start to work on or some tutorials that explain how can I achieve something like this?
Thank you
Later Edit
I have also found that DBpedia contains an ontology property "dressCode" and I've found these pages: http://en.wikipedia.org/wiki/Dress_code_(Western) and http://en.wikipedia.org/wiki/Dress_code which lists some basic dress codes, like "Formal", "Casual"...
Now my idea is to get properties from each one of these sub-categories (or what they are defined as on DBpedia, as I see they differ from one other).
Any suggestion on how to do this ?
Later Edit
I have managed to make some queries to display some information that could actually help me:
SPARQL - list of social events
SELECT DISTINCT (?label as ?sub)
WHERE {
{
?sub skos:broader <http://dbpedia.org/resource/Category:Social_events> .
?sub rdfs:label ?label.
OPTIONAL {?subsub dcterms:subject ?sub}
}
}
SPARQL - list of dress codes
SELECT DISTINCT (?label as ?dressCode)
WHERE {
{
?dressCode dcterms:subject <http://dbpedia.org/resource/Category:Dress_codes> .
?dressCode rdfs:label ?label.
filter(langMatches(lang(?label),"EN"))
}
}
Now I would like to retrieve the "subject of" for each dress code so that I can connect somehow the dress codes to the social events, but I'm having issues to do that.
Later Edit
I got to the conclusion that I can't find an ontology that actually matches my needs. Basically I need to get cloth properties based on event types so I can make cloth recommendations. Except the restrictions from the event types I also want to add other properties like the current fashion trend, the season in which the event will take place, geo-location (if possible), and other small details like these.
Now I'm trying to use existing ontologies and data that exists on DBpedia & Freebase, like: 'Dress code', 'Event type', 'Colors', 'Fashion designer', 'Fabric', 'Texture', 'Manufacturer', 'Size' and combine them into an ontology which I can actually use in my project to actually make cloth recommendations.
Can anyone help me with some guidelines on how I can do this ? I tried to use Protege to combine some ontologies and extend them after that, but finally I failed to do this.
May be one of the first places you can start with is the DBpedia ontology. When I search for keywords like Fashion, I can see that there are classes like FashionDesigner. So I can check about about the information about fashion designers in DPpedia with a simple SPARQL query like the following using the DPpedia public SPARQL endpoint.
(a) a list of fashion designers:
select distinct ?fashionDesigner
where {
?fashionDesigner a dbpedia-owl:FashionDesigner
}
LIMIT 100
(b) what are the information generally available about a fashion designer
select distinct ?property
where {
?fashionDesigner a dbpedia-owl:FashionDesigner;
?property ?value .
}
I can also select one of the results of query (a) such as Donna Karan take a look what kind of information she has.
So now, my task is to see who the well-known fashion designers. I don't know much about fashion but I see some of them have awards. So I can query for the fashion designers who have won awards.
(c) Fashion designers who have won awards
select distinct ?fashionDesigner ?award
where {
?fashionDesigner a dbpedia-owl:FashionDesigner;
dbpprop:awards ?award .
}
I was only using very basic SPARQL queries but you can use more complex queries when you get to know more about the fashion related concepts and properties in the data.
You can follow a similar approach for classes such as LineOfFashion, Clothing, etc.
For example
(d) a list of clothing manufactures
select distinct ?company where {
?company dbpedia-owl:product dbpedia:Clothing;
dcterms:subject category:Clothing_brands .
} LIMIT 100
The more you explore, you can build better queries. I hope this will help you to get started.
Here's a query that returns award winning fashion designers from Freebase: https://www.googleapis.com/freebase/v1/search?limit=10&scoring=entity&filter=(all+type%3A%2Faward%2Faward_winner+notable%3A%22fashion+designer%22)&lang=en&indent=true
There's a little on-line utility that you can use to experiment with this and check out some of the other items that you were interested in:
http://freebase-search.freebaseapps.com/?filter=(all+type%3A%2Faward%2Faward_winner+notable%3A%22fashion+designer%22)&limit=10&scoring=entity&lang=en

ESPN API - How can I retrieve college basketball conferences using the Teams API?

The support forums on ESPN.com recommend using Stack Overflow with the ESPN tag. That's why I'm here.
I'm trying to obtain a list of all NCAA college basketball teams using ESPN's Teams API. I started with this GET request:
http://api.espn.com/v1/sports/basketball/mens-college-basketball/teams?apikey=MY_API_KEY
That gave me a list of teams, but many of them are missing. For example, there is no Nebraska. So then I thought that maybe I need to get a list of teams by conference. So I read this in the documentation:
GROUPS: Allows for filtering by "group" or division, e.g. AL East, NFC South, etc. For group IDs and their corresponding values, make a request to http://developer.espn.com/v1/{resource}/leagues. Not applicable to golf and tennis.
So then I try to make a request to `http://developer.espn.com/v1/sports/basketball/mens-college-basketball/leagues?apikey=MY_API_KEY' and it says the page does not exist.
Is this a bug or user error?
First, I think you forgot sports in the resource. Try this:
http://api.espn.com/v1/sports/basketball/mens-college-basketball?apikey=MY_API_KEY&leagues
That will return a mapping of integers to conferences it seems according to the documentation.
That fetched me:
{"name" :"Atlantic Coast Conference","abbreviation" :"acc","groupId" :2,"shortName" :"ACC"}
...and much more.
Then once you have that, let's say 2 = ACC. You should be able to do this:
http://api.espn.com/v1/sports/basketball/mens-college-basketball?groups=2&apikey=MY_API_KEY'
to get everything on ACC mens' basketball teams.
Bear in mind the API is in beta though.
I could not figure out how to get a list of conferences, but I found out how to get the missing teams. When I was making the first get request, it was limiting me to 50 results by default:
http://api.espn.com/v1/sports/basketball/mens-college-basketball/teams?apikey=MY_API_KEY
They have a sandbox where you can play with your parameters, and I saw a limit and offset option:
http://developer.espn.com/io-docs
To get more than 50 results, you have to make multiple requests using the limit and offset parameters.
First Call:
http://api.espn.com/v1/sports/basketball/mens-college-basketball/teams/?limit=50&offset=0&_accept=text%2Fxml&apikey=MY_API_KEY
Next Call:
http://api.espn.com/v1/sports/basketball/mens-college-basketball/teams/?limit=50&offset=50&_accept=text%2Fxml&apikey=MY_API_KEY
And so on...