0

i'm building a simple online semantic search engine to find jobs and i found a simple program that reads a local owl file but i want it to be online to fined jobs and employers using the semantic web and linked data

from owlready2 import *


class SparqlQueries:
def __init__(self):
    my_world = World()
    my_world.get_ontology("file://ExampleOntolohy.owl").load() #path to the owl file is given here
    sync_reasoner(my_world)  #reasoner is started and synchronized here
    self.graph = my_world.as_rdflib_graph()

def search(self):
    #Search query is given here
    #Base URL of your ontology has to be given here
    query = "base <http://www.semanticweb.org/ExampleOntology> " \
            "SELECT ?s ?p ?o " \
            "WHERE { " \
            "?s ?p ?o . " \
            "}"

    #query is being run
    resultsList = self.graph.query(query)

    #creating json object
    response = []
    for item in resultsList:
        s = str(item['s'].toPython())
        s = re.sub(r'.*#',"",s)

        p = str(item['p'].toPython())
        p = re.sub(r'.*#', "", p)

        o = str(item['o'].toPython())
        o = re.sub(r'.*#', "", o)
        response.append({'s' : s, 'p' : p, "o" : o})

    print(response) #just to show the output
    return response


runQuery = SparqlQueries()
runQuery.search()

I've tried to use RDFlib like what it was mentioned in the documentation

import rdflib
g=rdflib.Graph()
g.load('http://dbpedia.org/resource/Semantic_Web')

for s,p,o in g:
    print s,p,o

what i should do to get data and links about jobs ? or about employers or companies ?

and how should i write the owl file ?

Mosa Abbas
  • 139
  • 1
  • 1
  • 16
  • 2
    obviously by finding public job datasets? And then, you have to convert them to RDF...are you sure you're able to do this? You need your own ontology schema, have to write mappings and all the things necessary to convert data to RDF. – UninformedUser Jul 30 '19 at 15:23

1 Answers1

2

schema.org have a JobPosting specification. If you're lucky you'll find some websites using it and using it well. Depending on how they do (in the linked docs), you'll be able to scrape it into your own graph. That'll save authoring an ontology at least.

I just looked at just one job website: Monster.com, they're kind enough to put Schema lists in JSON-LD on their collection pages, line 1187 in the linked source, as well as Schema JobPostings on the linked pages, line 261 in the linked source.

If you have both rdflib and rdflib-jsonld pip installed, then it's a simple as:

from rdflib import Graph
g = Graph()
g.parse("https://job-openings.monster.com/software-engineer-principal-software-engineer-northridge-ca-us-northrop-grumman/0d2caa9e-3b3c-46fa-94d1-cddc75d9ae27")

# Demo
print(len(g))
for s, p, o in g:
    print(s, p, o)
Paul Brown
  • 2,235
  • 12
  • 18
  • 1
    The links are to the webpages, your browser will display them as such. You can either use your browsers option to view-souce to see the HTML, with embedded JSON-LD, or curl the URL to view the same in your terminal. – Paul Brown Jul 31 '19 at 17:11