Giter VIP home page Giter VIP logo

wikidata-parser's Introduction

Wikidata Parser

Parser

Parsing one line (Wikidata Item & it's Claims) from the wikidata dump could be done using DumpElement

Parsing line from Dump

Example:

import org.idio.wikidata.dump.element._

val element = DumpElement.parseElement(dumpLine)

element match{
  case e:Item  = > println("It is a topic")
  case e:Property => println("It is a relationship type")
}

Playing with Topics

import org.idio.wikidata.dump.element._
val topic = DumpElement.parseElement(dumpLine).asInstanceOf[Item]

topic.getId() // the Qid of the topic
topic.getAliases("en") // aliases of the topic for english
topic.getRelationshipTuples // list of relationship tuples i.e (P130, Q123),(P30, Q01)....
  • getRelationshipTuples: be aware it only extracts relationships out of main snaks where the argument of the relationship is another entity.

Extractor

It is an utility to extract relationships out of the wikidata dump for a given set of Qids.

  • Input:

    • Wikidata Dump
    • tsv containing list of Qids:
      • tsv must container a header
      • qid should be the first field
  • Output:

    • One triple per line : ( startTopic, endTopic, relationshipType )
    • startTopic and endTopic are referenced as lineIds within the given Qids map i.e: if the qid: Q123 is in the line 10, then it will be referenced in the output as topic 10
    • Relationships connecting topics which are not in the given list of Qids are ignored.
    • Relationship types are output as: label_Pid

Usage:

  1. get Spark 1.2.0

  2. do :

SPARK_FOLDER/bin/spark-submit --class "org.idio.wikidata.dump.Extractor" target/scala-2.10/wikidata-assembly-1.0.jar /path/to/nodesmapping.tsv /path/to/wikidatadump /path/to/outputfile.tsv

Compiling

  • sbt assembly

wikidata-parser's People

Contributors

dav009 avatar

Watchers

thomasO avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.