Skip to content
Snippets Groups Projects
Commit 33f0e18c authored by Eliott Sammier's avatar Eliott Sammier
Browse files

Comments are now added to RDF graph

parent fd18fec7
No related branches found
No related tags found
No related merge requests found
......@@ -116,7 +116,7 @@ def parse_manifest_rec(
def main():
g = create_graph()
extract_page.parse_page(SOURCE_DIR+"/contenu/pages/pg60.html", "pg60")
extract_page.parse_page(g, SOURCE_DIR + "/contenu/pages/pg112.html", "pg112")
parse_manifest(g)
export_graph(g)
......
......@@ -3,6 +3,7 @@ from pprint import pprint
from typing import List
from lxml import html
from rdflib import Graph, Literal
from constants import *
......@@ -37,7 +38,7 @@ class Page:
regex_comment = re.compile(r"(\D*)(\d*)")
def parse_page(filepath: str, id: str):
def parse_page(graph: Graph, filepath: str, id: str):
page = Page()
# Parse with lxml
tree = html.parse(filepath)
......@@ -58,13 +59,16 @@ def parse_page(filepath: str, id: str):
print(f"Comment, num={num}")
comment.num = int(num)
page.comments_misc.append(comment)
graph.add((NS[id], NS["commentaireInfo"], Literal(comment.text)))
case ["divSugg", num]:
print(f"Suggestion, num={num}")
comment.num = int(num)
page.comments_sugg.append(comment)
graph.add((NS[id], NS["commentaireSugg"], Literal(comment.text)))
case ["divCmtSucces", _]:
print(f"Succès")
page.comment_success = comment
graph.add((NS[id], NS["commentaireSucces"], Literal(comment.text)))
case [other, _]:
print(f"other: {other}")
pprint(page)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment