Keen Learner

The tale of a thirsty mind

Connecting the dots… — May 23, 2016

Connecting the dots…

It has been over a month since Davide,Alessandro and I started working on WikiToLearn:Ratings  for GSoC-2016 and we have already started with Database design . I have already shared my experiences while setting up OrientDB inside  docker in this post. So now let’s take a step further and talk about how we made a sample graph database to represent our project (abstract here). To understand it in a better way , let’s consider the following scenario:

Jon,Jacob and Josh study Physics at a renowned university. One day they came across WikiToLearn  and they were deeply influenced by it’ s philosophy –knowledge only grows if shared. Being roommates they arrived at a collective decision to share their knowledge and author a course on Mechanics under physics  section on WikiToLearn.
So Jon decided to write about Newton Law,Josh about Work and Power . Jacob was busy with his cookery classes so Josh decided to author Pseudo Force for him while he was away.They were very happy with their work and wanted to share their work with all the university students but before that they decided to proof read each other’s work. So while doing it they improvised some of the sections of pages written. Now they came to know that WikiToLearn has this unique feature called Versions. Basically versions are a great way to keep track of the history of changes such that whenever a page is changed a new version is stacked on the top of old one such that it forms a chain of changes and only latest version is accessible to users. So they created versions on each other’s work by reviewing and editing is subsequently. Now when they are done reviewing they vote the page content so that the entire course rating can be generated by the Rating Engine.
Each user has some credibility that will determine the weight carried by his vote.This will be determined by his loyalty to WikiToLearn platform( his activities  like contributions,reviews,days active).Here it is essential to remember that a contributor can’t vote his own work.( 😛 ). So now the work of the editors is over and now it’s up to the Rating Engine to calculate the Reliability of their work.They are waiting with their fingers crossed!

So to model this type of information I basically used OrientDB as a graph database.Let’s see a simple way of doing it.

Vertices and Edges:

So in this scene we have some entities like User,Page,Course and Version. These entities will form the heart of our graphical database. Information like User’s Name , Page Name will be embedded inside these entities. These entities will interact with each other with various relationships like Jon contributes newton law. 
In OrientDB these entities are  represented by Vertices and relationships by Edges of a graph.

Setting up the vertices:

Just like the Object Oriented terminology we extend out custom made classes to the base ones so in the web editor or the console,issue the following commands:

CREATE CLASS USER EXTENDS V
CREATE CLASS PAGE EXTENDS V
CREATE CLASS COURSE EXTENDS V
CREATE CLASS VERSION EXTENDS V
CREATE CLASS CONTRIBUTE EXTENDS E
CREATE CLASS REVIEW EXTENDS E
CREATE CLASS INSIDE EXTENDS E
CREATE CLASS V_STACK EXTENDS E
CREATE CLASS P_VERSION EXTENDS E

Let’s now embed information inside the vertices and edges don’t worry if you don’t understand all the used parameters they will be explained in the subsequent posts.

USER:

CREATE VERTEX USER SET NAME="JON",J_DATE="2014-05-12"


CREATE VERTEX USER SET NAME="JOSH",J_DATE="2015-05-20"


CREATE VERTEX USER SET NAME="JACOB",J_DATE="2013-12-10"

PAGE:

CREATE VERTEX PAGE SET NAME="NEWTON LAW",C_RELIABILITY=2.0,RATING=3.4


CREATE VERTEX PAGE SET NAME="WORK AND POWER",C_RELIABILITY=2.0,RATING=3.4


CREATE VERTEX PAGE SET NAME="PSEUDO FORCE",C_RELIABILITY=2.0,RATING=3.4

VERSION:

CREATE VERTEX VERSION SET V_NO=0,P_NAME="NEWTON LAW",C_RELIABILITY=1.0,RATING=4.2


CREATE VERTEX VERSION SET V_NO=1,P_NAME="NEWTON LAW",C_RELIABILITY=1.0,RATING=4.2


CREATE VERTEX VERSION SET V_NO=1,P_NAME="WORK AND POWER",C_RELIABILITY=1.0,RATING=4.2


CREATE VERTEX VERSION SET V_NO=0,P_NAME="WORK AND POWER",C_RELIABILITY=1.0,RATING=4.2


CREATE VERTEX VERSION SET V_NO=0,P_NAME="PSEUDO FORCE",C_RELIABILITY=1.0,RATING=4.2


CREATE VERTEX VERSION SET V_NO=1,P_NAME="PSEUDO FORCE",C_RELIABILITY=1.0,RATING=4.2

COURSE:

CREATE VERTEX COURSE SET NAME="MECHANICS",C_RELIABILITY=2.0,C_VOTE=5.2

Drawing Edges:

So now we need to link the disjoint vertices with relationships.We need to connect the contributor to his work (CONTRIBUTE), Reviewer to content reviewed(REVIEW), pages to course(INSIDE), Versions to pages in a stack like manner (V_STACK) and finally linking the current version to pages(P_VERSION). Let’s see them one by one:

CONTRIBUTE:

CREATE EDGE CONTRIBUTE FROM (SELECT FROM USER WHERE NAME="JON") TO (SELECT FROM VERSION WHERE P_NAME="NEWTON LAW")


CREATE EDGE CONTRIBUTE FROM (SELECT FROM USER WHERE NAME="JOSH") TO (SELECT FROM VERSION WHERE P_NAME="WORK AND POWER" OR (P_NAME="PSEUDO FORCE" AND V_NO=0))


CREATE EDGE CONTRIBUTE FROM (SELECT FROM USER WHERE NAME="JACOB") TO (SELECT FROM VERSION WHERE P_NAME="PSEUDO FORCE" AND V_NO=1)

REVIEW:

CREATE EDGE REVIEW FROM (SELECT FROM USER WHERE NAME="JON") TO (SELECT FROM VERSION WHERE P_NAME="PSEUDO FORCE" AND V_NO=0) SET VOTE=5


CREATE EDGE REVIEW FROM (SELECT FROM USER WHERE NAME="JOSH") TO (SELECT FROM VERSION WHERE P_NAME="NEWTON LAW" AND V_NO=1) SET VOTE=8


CREATE EDGE REVIEW FROM (SELECT FROM USER WHERE NAME="JACOB") TO (SELECT FROM VERSION WHERE P_NAME="WORK AND POWER" ) SET VOTE=9

P_VERSION:

CREATE EDGE P_VERSION FROM (SELECT * FROM VERSION WHERE P_NAME="NEWTON LAW" AND V_NO=0) TO (SELECT * FROM VERSION WHERE P_NAME="NEWTON LAW" AND V_NO=1)


CREATE EDGE P_VERSION FROM (SELECT * FROM VERSION WHERE P_NAME="PSEUDO FORCE" AND V_NO=0) TO (SELECT * FROM VERSION WHERE P_NAME="PSEUDO FORCE" AND V_NO=1)


CREATE EDGE P_VERSION FROM (SELECT * FROM VERSION WHERE P_NAME="WORK AND POWER" AND V_NO=0) TO (SELECT * FROM VERSION WHERE P_NAME="WORK AND POWER" AND V_NO=1)

V_STACK:

CREATE EDGE V_STACK FROM (SELECT * FROM VERSION WHERE P_NAME="NEWTON LAW" AND V_NO=1) TO (SELECT * FROM PAGE WHERE NAME ="NEWTON LAW")


CREATE EDGE V_STACK FROM (SELECT * FROM VERSION WHERE P_NAME="WORK AND POWER" AND V_NO=1) TO (SELECT * FROM PAGE WHERE NAME ="WORK AND POWER")


CREATE EDGE V_STACK FROM (SELECT * FROM VERSION WHERE P_NAME="PSEUDO FORCE" AND V_NO=1) TO (SELECT * FROM PAGE WHERE NAME ="PSEUDO FORCE")

Voila! here it is 🙂

ori

 

Build.Run.Contain! — May 22, 2016

Build.Run.Contain!

Once you realize how addictive and rewarding Open Source Development is, you will end up spending days with it. So here I am working on my WikiToLearn:Ratings project for GSoC-2016.Only few days back it felt that it is good time to choose a proper database application for handling our data , which can be modeled into a graph.We stumbled upon OrientDB a distributed graph database. So here I am sharing my experiences while setting up OrientDB inside Docker.

Just imagine you went to a fine restaurant and you ordered a delicious pizza, as you were busy taming your taste buds you get served with this.

maxresdefault
You are further given some red tomatoes and freshly prepared basil to make sauce and toppings on your own. I know you how do you feel not because I went to such restaurant , but because this is a common scenario that the programmers face.

When we are working in teams it becomes really essential to collaborate seamlessly. That requires that you have a uniform working environment as your fellow team mates. But unfortunately this is not the case. Ever! . There are always some differences in the developing environments that need to be bridged . Now that mostly involves installing dependencies, packages and what not. The situation similar to the pizzeria as we ourselves need to make sauce and toppings for our pizza!

But what if I tell you that there is something that can save you from all this ?

Here comes DOCKER.According to the internet:

“Docker allows you to package an application with all of its dependencies into a standardized unit for software development.”

That means to run an application on any platform you just need to install docker, build the pack with the application and all it’s supporting components and then you are done.
Now anyone using that application only needs docker installed to run that application. No more ugly setup , nothing just run docker and your application is up.

Tasty-Pizza

So recently I got a chance to use docker to fire up my OrientDB database. Therefore in the remaining post I will be explaining what it took to run OrientDB inside Docker!
I am using Ubuntu 14.04(LTS)

  1. Initially we need to download the Docker image of OrientDB .Think of this image as your full application along with all the necessary components to run it.
    So need to a need a set of instructions to download all the dependencies and  install them. This instructions can be run in a batch process with the help of a Dockerfile. Just copy the contents of this file and save it on your disk with your favorite text editor, then run this command on the terminal to build the image from the Dockerfile:docker build -f /path/to/a/Dockerfile .
  2.  

  3. Now once you have the image and the other dependencies you need to run this:docker run -d -p 2424:2424 -p 2480:2480  -v config:/orientdb/config     -v database:/orientdb/databases  -v backup:/orientdb/backup     -e ORIENTDB_ROOT_PASSWORD=mypasswdhere     orientdb:latestSo let’s understand what we just did. We need to run an instance of the image we just built. Docker provides a faculty known as Containers to do it. Containers are like resource friendly virtual machines , a sandbox where you will run your application.
    The -d parameter will detach the container so that it won’t hog the terminal and the container will be up even if your close the terminal.
    -p is used to map the ports.
    As we will be working with the databases we need persistent storage to hold our changes in memory. But the moment we will kill the containers running the application all the data associated with it are destroyed. Therefore we will use Volumes to store the data in main memory.So -v to specify volumes.
  4.  

  5. Your server is up now you can access the web interface by going on this address:http://localhost:2480/
  6.  

  7. If you want to run console you need to additionally issue this command:
    docker run -it --net="host" orientdb:latest /orientdb/bin/console.sh
    The –net=”host” will select the host networking mode in docker. You can read more about networking in docker here.To connect to your database issue:orientdb> connect remote:localhost root <Passwd>
  8.  

  9. Now if you need to kill the container you can issue this command to see the running containers:
    docker ps

    You can see the container name you wish to kill and use:
    docker kill <container name>

 

Congratulations! now you have a fully functional OrientDB server running inside a docker container.

blog local.png

Google Summer of Code 2016 — May 12, 2016

Google Summer of Code 2016

Final logo“If you want to go fast walk alone

If you want to go further walk together”

I have always seen computers as the portals to travel into the new era. To change things . Being a computer science  student myself I am often faced by this question-“What can I do to bring a change?”.
It was this question that introduced me to the open source culture. The idea of having a vibrant community, all sharing a common purpose to innovate is what makes open source development a noble and exciting pursuit at the same time. I started by developing some of my own small projects. I can tell you it feels really great to see your own idea take shape. It is like you grow with the product you are developing and it imparts a pleasant satisfaction.
During my experiments with the open source community I came to know about Google Summer of Code program. When I researched more about it I found out it was a wonderful opportunity for any student like me to not only gain exposure and insights into real world programming  paradigms but also  to work with the top craftsmen of the open source community. So I started looking for the proposed projects under various organisations.
And then I found this lovely organisation named WikiToLearn under the umbrella organisation of KDE which had  a project named WikiToLearn Ratings(Click to view abstract!) that caught my attention.

WikiToLearn works on the ideology that “knowledge only grows if shared“. It provides a platform where learners and teachers can together complete, refine and re-assemble notes, lecture notes in order to create text books, tailored precisely to their needs, so that we can provide free, collaborative and accessible text books to the whole world.

Our project is basically aimed at ranking the content on wiki-style learning platforms. The content on such platforms is more or less of good quality but it still depends on various parameters like author’s credibility, interconnections between different pages and user votes. Also we will pay special attention on how different versions will stack on the top of old ones to change their cumulative ratings.

We will be developing a Rating Engine that will be used rate the the users based on their interactions with WikiToLearn platform and then using their votes as one of the indicators for the page quality.In fact through this approach we will further calculate the final rating of the whole course. This will give user a general assessment of the course quality even before taking the course.

Of course for doing great work you need a great team so I am being guided and helped by my mentor Davide Valsecchi along with helpful folks from my WikiToLearn family( Yes! I can proudly call it a family ❤ ❤ ). Davide really helped me in understanding the problem to the core and with the constant support and feedback from the community I was able to produce a fine proposal that got me selected!

So in a nutshell I feel really great to be a part of WikiToLearn family! We have a lot of fun at telegram channel(Sometimes we even discuss why spaghetti aren’t noodles 😛 ).People here are really amazing and always come forward to resolve even the slightest issues.It has been an exciting journey so far and I am sure it will only get better from here.Cheers!!!

Let the summer of code begins! 

😎