def get_wikipedia_network_structure(concepts):

  wkn = WikipediaNetwork(concepts)
 
  wkn.build()

  store_mapping(wkn.mapping)

  return wkn.graph
Exemplo n.º 2
0
# -*- coding: utf-8 -*-
import os
import codecs
import sys
import urllib
import json

from wekeypedia.wikipedia_page import WikipediaPage as Page, url2title, url2lang
from wekeypedia.wikipedia_network import WikipediaNetwork
from wekeypedia.exporter.nx_json import NetworkxJson

source = "List_of_geometry_topics"

hl = WikipediaNetwork("")
hl.keywords = hl.get_page_links(source)

hl.build()

exporter = NetworkxJson(hl.graph)
exporter.nx_export("adjacency", "_data/network.json")

# print hl.keywords
print ""

def fetch_page(source):
  print "📄  fetching: %s" % source.encode('utf-8-sig')

  p = Page()
  r = p.fetch_from_api_title(source.strip(), { "redirects":"true", "rvparse" : "true", "prop": "info|revisions", "inprop": "url", "rvprop": "content" })

  with open("path_points/%s.json" % (source), "w") as f: