Creative Commons License

Tools and libraries

Tutorials and Manual pages

Python

Resize images or create thumbnail images

from PIL import Image
import matplotlib.pyplot as plot

imgfile = Image.open("flower.jpg")
#resize image to 200px x 200 px using ANTIALIAS interpolation
imgfile = imgfile.resize([200, 200], Image.ANTIALIAS)

plot.imshow(imgfile)
plot.show()

Create thumbnail images

from PIL import Image
import matplotlib.pyplot as plot

imgfile = Image.open("flower.jpg")
imgfile.thumbnail([200, 200], Image.ANTIALIAS)

plot.imshow(imgfile)
plot.show()

Create JSON data

import json

colors = [[120, 30, 120], [150, 30, 10]]
user = "user 1"

data = dict()
data['user'] = user
data['colors'] = colors

print(json.dumps(data))

Write JSON data to file

import json

colors = [[120, 30, 120], [150, 30, 10]]
user = "user 1"

data = dict()
data['user'] = user
data['colors'] = colors

with open("user.json", "w") as file:
    json.dump(data, file)

file.close()

Read JSON data from file

import json

data = ""
with open("user.json", "r") as file:
    data = json.load(file)

print(data)

SPARQL queries

Get names of 100 programming languages.

SELECT ?languageLabel (YEAR(?inception) as ?year)
WHERE
{
 #instances of programming language
 ?language wdt:P31 wd:Q9143;
  wdt:P571 ?inception;
  rdfs:label ?languageLabel.
 FILTER(lang(?languageLabel) = "en")
}
ORDER BY ?year
LIMIT 100

Get names of 100 programming languages and their paradigms.

SELECT ?languageLabel ?paradigmLabel (YEAR(?inception) as ?year)
WHERE
{
 #instances of programming language
 ?language wdt:P31 wd:Q9143;
  wdt:P571 ?inception; #inception
  wdt:P3966 ?paradigm; #programming language paradigm
  rdfs:label ?languageLabel. #label
 ?paradigm rdfs:label ?paradigmLabel #label
 FILTER(lang(?languageLabel) = "en" && lang(?paradigmLabel) = "en") #English
}
ORDER BY ?year ?paradigmLabel
LIMIT 100

Get available information of population of different countries at different periods of time.

SELECT DISTINCT ?countryLabel (YEAR(?date) as ?year) ?population
WHERE {
 ?country wdt:P31 wd:Q6256; #Country
   p:P1082 ?populationStatement;
  rdfs:label ?countryLabel. #Label
 ?populationStatement ps:P1082 ?population; #population
  pq:P585 ?date. #period in time
 FILTER(lang(?countryLabel)="en") #Label in English
}
ORDER by ?countryLabel ?year
LIMIT 1000

Get population of France at different periods of time.

SELECT (YEAR(?date) as ?year)?population
WHERE
{
  VALUES ?country {wd:Q142}
  ?country p:P1082 ?populationStatement.
  ?populationStatement ps:P1082 ?population;
     pq:P585 ?date.
}
ORDER by ?year

Get number of programming languages released every year.

SELECT ?year (COUNT(?programmingLanguage) as ?count)
WHERE
{
  ?programmingLanguage wdt:P31/wdt:P279* wd:Q9143;
    wdt:P571 ?date.
  BIND(YEAR(?date) as ?year)
}
GROUP BY ?year
ORDER by ?year

Get number of programming languages released every year belonging to different paradigms.

SELECT ?year ?paradigmLabel (COUNT(?programmingLanguage) as ?count)
WHERE
{
  ?programmingLanguage wdt:P31/wdt:P279* wd:Q9143;
    wdt:P3966 ?paradigm;
    wdt:P571 ?date.
  ?paradigm rdfs:label ?paradigmLabel FILTER(lang(?paradigmLabel)="en").
  BIND(YEAR(?date) as ?year)
}
GROUP BY ?year ?paradigmLabel
ORDER by ?year ?paradigmLabel

Get number of softwares released every year.

SELECT ?year (COUNT(?software) as ?count)
WHERE
{
  ?software wdt:P31/wdt:P279* wd:Q7397;
    wdt:P571 ?date.
  BIND(YEAR(?date) as ?year)
}
GROUP BY ?year
ORDER by ?year

Standards and tools