Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
obc2kg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
born
obc2kg
Commits
80c33bb4
Commit
80c33bb4
authored
5 years ago
by
opitz
Browse files
Options
Downloads
Patches
Plain Diff
added comments
parent
2bb0c04b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/graph_builder.py
+8
-14
8 additions, 14 deletions
src/graph_builder.py
with
8 additions
and
14 deletions
src/graph_builder.py
+
8
−
14
View file @
80c33bb4
...
...
@@ -13,7 +13,7 @@ import logging
def
build_graph
(
years
=
[],
include_utterances
=
False
,
subcat
=
False
):
#a small helper function
def
maybe_subcat
(
string
):
if
not
subcat
:
return
False
...
...
@@ -37,16 +37,11 @@ def build_graph(years=[],include_utterances=False,subcat=False):
#and the year
year
=
exact_date
[:
4
]
#add a trial node
trialnode
=
dh
.
TrialNode
(
exact_date
,
fp
+
"
_
"
+
trial_index_infile
)
nodeindex
,
trialindex
=
gh
.
maybe_new_index
(
trialnode
,
node_index_dict
)
G
.
add_node
(
trialindex
,
label
=
"
Trial
"
,
nodeobj
=
trialnode
)
#yearnode = dh.YearNode(year)
#nodeindex,yindex = gh.maybe_new_index(yearnode,node_index_dict)
#G.add_node(yindex, label="Year", nodeobj=yearnode)
#G.add_edge(trialindex,yindex,edge_class="in-year")
...
...
@@ -55,18 +50,16 @@ def build_graph(years=[],include_utterances=False,subcat=False):
#offs = [dh.create_cat_elm(of,"offence") for of in offs]
descriptions
=
[
dh
.
HasDescriptionNode
(
of
)
for
of
in
offs
]
logging
.
info
(
"
descriptions found: {}
"
.
format
(
descriptions
))
#[desc.simplify_to_direct_object() for desc in descriptions]
offs
=
[
dh
.
OffenceNode
(
of
,
"
offence
"
,
subcat
=
maybe_subcat
(
"
offence
"
),
dummy
=
False
)
for
of
in
offs
]
#print(descriptions)
#asd
for
i
,
off
in
enumerate
(
offs
):
#
each
offence
has a text and a (symbolic) category
#
add
offence
node
nodeindex
,
offindex
=
gh
.
maybe_new_index
(
off
,
node_index_dict
)
G
.
add_node
(
offindex
,
label
=
"
Offence
"
,
nodeobj
=
off
)
G
.
add_edge
(
trialindex
,
offindex
,
edge_class
=
"
with-offence
"
)
#nodeindex+=1
# add textual description node
nodeindex
,
descr_index
=
gh
.
maybe_new_index
(
descriptions
[
i
],
node_index_dict
)
G
.
add_node
(
descr_index
,
label
=
"
Description
"
,
nodeobj
=
descriptions
[
i
])
G
.
add_edge
(
trialindex
,
descr_index
,
edge_class
=
"
with-offence-description
"
)
...
...
@@ -105,6 +98,7 @@ def build_graph(years=[],include_utterances=False,subcat=False):
ds
=
[
dh
.
NamedEntityNode
(
dname
)
for
dname
in
dnames
]
for
d
in
ds
:
#inser a defendant node and connect it to trial
nodeindex
,
dindex
=
gh
.
maybe_new_index
(
d
,
node_index_dict
)
G
.
add_node
(
dindex
,
label
=
d
.
get_fullname
(),
nodeobj
=
d
)
G
.
add_edge
(
trialindex
,
dindex
,
edge_class
=
"
with-defendant
"
)
...
...
@@ -116,7 +110,7 @@ def build_graph(years=[],include_utterances=False,subcat=False):
G
.
add_node
(
victindex
,
label
=
vict
.
get_fullname
(),
nodeobj
=
vict
)
G
.
add_edge
(
trialindex
,
victindex
,
edge_class
=
"
with-victim
"
)
#we get the text from the trial account to extract named entities and utterances
#we get the text from the trial account to extract
various other
named entities and utterances
ps
=
div
.
findAll
(
"
p
"
)
ps
=
[
p
for
p
in
ps
if
len
(
p
.
findAll
(
"
persname
"
))
==
1
and
len
(
p
.
findAll
(
"
u
"
))]
ents
=
[
p
.
findAll
(
"
persname
"
)[
0
]
for
p
in
ps
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment