Repository navigation
Research
This page is about what has been researched for the project.
Git is a distributed version control system that tracks versions of your code. It was created to be used for Linux kernel development by Linus Torvalds.
Git maintains a local copy of your repository (repo). This repo tracks commit and version history without connecting to a network or a central server since repos are stored in a directory on every computer. With git you can synchronize with remote repos, and also copy them directly.
Git's structure is an acyclic directed graph. Each commit is a node in the graph, and branches and tags are pointers to nodes.
Relevant video for learning git
git config
git config --global user.name "<firstname lastname>”
Command for configuring user information. Name can also be e-mail.
git init
git init
Command for initializing a git directory.
git clone
git clone <url>
Command for retrieving a remote repo from URL.
git status
git status
Command for showing modified files in the current directory.
git add
git add <file>
Command for adding a file to next commit stage.
git reset
git reset <file>
Command for removing a file from commit stage.
git commit
git commit -m "<message>"
Command for committing staged files as a new snapshot.
git branch
git branch <branch name>
Command for creating a new branch at the current commit. Without this lists all your branches.
git checkout
git checkout
Command for switching to another branch and check it out into the working directory.
git merge
git merge <branch>
Command for merging specified branch's history into the current branch.
git log
git log
Command for showing all commit history in current branch.
git push
git push <alias> <branch>
Command for sending local commits to the remote repo.
git pull
git pull
Command for fetching and merging any commits from the remote branch.
Wikidata is a free, collaborative, multilingual, secondary knowledge base project that collects organized information to support Wikipedia, Wikimedia Commons, and to anyone in the world.
It uses Markdown for its syntax.
Wikidata is a central repo that can be accessed by others like Wikipedia. This repo consists of items. Each item has a label, a description, and number of aliases. Item id notated as Q with a number after it. For example Q42, the meaning of life, is refer to wiki page of Douglas Adams.
To describe characteristics of an item (like Douglas Adams), items have properties and values capsulated as statements. Properties are notated with P followed by a number. So for example, P69 is "educated at". Following the example, if you want to specify where he was educated you can specify a value for the school. Hence it becomes:
| Item | Property | Value |
|---|---|---|
| Q42 | P69 | Q691283 |
| Douglas Adams | educated at | St. John's College |
You can also link a property to external database, like coordinates to a place. This is called an identifier.
Wikidata's wikibase uses REST API. This API allows you to query data by fetching to this endpoint:
https://www.wikidata.org/w/api.php
You can add certain parameters with '?' at the beginning, and separated by '&', to the request to tell what data you want. An example using previous item:
https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q42&format=json
This URL get entities with Q42 id and formats the query as json. You can check this URL with a web browser.
wbgetentities gives you the data from Wikibase. It needs the ID (like Q42). This ID can be found with wbsearchentities using labels like "Douglas Adams".
Fetching API data in Java:
public static String fetchWikidata(String entityId) {
StringBuilder result = new StringBuilder();
// Create the URL to query the Wikidata API
String urlStr = "https://www.wikidata.org/w/api.php?action=wbgetentities&ids=" + entityId + "&format=json";
URL url = new URL(urlStr);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
// Read the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
result.append(line);
}
rd.close();
return result.toString();
}After that you can parse json data.
Good resources for Wikidata API:
Official wiki
A good blog post about the API