Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Social Media Mining with Python

You're reading from   Mastering Social Media Mining with Python Unearth deeper insight from your social media data with advanced Python techniques for acquisition and analysis

Arrow left icon
Product type Paperback
Published in Jul 2016
Publisher Packt
ISBN-13 9781783552016
Length 338 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Marco Bonzanini Marco Bonzanini
Author Profile Icon Marco Bonzanini
Marco Bonzanini
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Social Media, Social Data, and Python FREE CHAPTER 2. #MiningTwitter – Hashtags, Topics, and Time Series 3. Users, Followers, and Communities on Twitter 4. Posts, Pages, and User Interactions on Facebook 5. Topic Analysis on Google+ 6. Questions and Answers on Stack Exchange 7. Blogs, RSS, Wikipedia, and Natural Language Processing 8. Mining All the Data! 9. Linked Data and the Semantic Web

Mining relations from DBpedia


DBpedia is one of the best-known sources of Linked Data. Based on Wikipedia, it augments the content of the popular wiki-based encyclopedia with semantic connections between entities. The structured information from DBpedia can be accessed via the Web using a SQL-like language called SPARQL, a semantic query language for RDF.

In Python, while we have the option of querying the database with SPARQL, we can take advantage of the RDFLib package, a library used to work with RDF.

From our virtual environment, we can install it using pip:

$ pip install rdflib

Given the complexity of the Semantic Web topic, we prefer to dig into an example so that you can have the flavor of the capabilities of DBpedia, and at the same time, get an overview of how to use the RDFLib package.

The rdf_summarize_entity.py script looks up for a given entity and tries to output its summary to the user:

# Chap09/rdf_summarize_entity.py 
from argparse import ArgumentParser 
import rdflib...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image