Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
corpus2
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Analysers
corpus2
Commits
717ff7bc
Commit
717ff7bc
authored
12 years ago
by
Pawel Orlowicz
Browse files
Options
Downloads
Patches
Plain Diff
Improved hits counting and additional output formatting
parent
cfce7c60
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
utils/relation_eval.py
+22
-15
22 additions, 15 deletions
utils/relation_eval.py
with
22 additions
and
15 deletions
utils/relation_eval.py
+
22
−
15
View file @
717ff7bc
...
...
@@ -67,36 +67,39 @@ class RelStats :
#if there was a hit on both sides of relation (dir_from, dir_to) then update counters
def
update_stats
(
self
,
both
,
chun
,
head
)
:
if
chun
==
2
:
self
.
any_hits
+=
1
if
head
==
2
:
self
.
both_hits
+=
1
else
:
self
.
chun_hits
+=
1
elif
head
==
2
:
self
.
any_hits
+=
1
if
chun
==
2
:
self
.
chun_hits
+=
1
if
head
==
2
:
self
.
head_hits
+=
1
if
chun
==
2
and
head
==
2
:
self
.
both_hits
+=
1
if
chun
==
2
or
head
==
2
:
self
.
any_hits
+=
1
def
print_stats
(
self
,
ref_rels_count
,
target_rels_count
):
def
print_stats
(
self
,
ref_rels_count
,
target_rels_count
,
stat_mode
):
p
=
0.0
if
target_rels_count
==
0
else
100.0
*
self
.
any_hits
/
target_rels_count
r
=
0.0
if
ref_rels_count
==
0
else
100.0
*
self
.
any_hits
/
ref_rels_count
f
=
0.0
if
p
+
r
==
0.0
else
2.0
*
p
*
r
/
(
p
+
r
)
print
(
'
Any chunk or head match:
\t
'
)
if
not
stat_mode
:
print
(
'
Any chunk or head match:
\t
'
)
print
'
%.2f
\t
%.2f
\t
%.2f
'
%
(
p
,
r
,
f
)
p
=
0.0
if
target_rels_count
==
0
else
100.0
*
self
.
both_hits
/
target_rels_count
r
=
0.0
if
ref_rels_count
==
0
else
100.0
*
self
.
both_hits
/
ref_rels_count
f
=
0.0
if
p
+
r
==
0.0
else
2.0
*
p
*
r
/
(
p
+
r
)
print
(
'
Chunk and head match:
\t
'
)
if
not
stat_mode
:
print
(
'
Chunk and head match:
\t
'
)
print
'
%.2f
\t
%.2f
\t
%.2f
'
%
(
p
,
r
,
f
)
p
=
0.0
if
target_rels_count
==
0
else
100.0
*
self
.
chun_hits
/
target_rels_count
r
=
0.0
if
ref_rels_count
==
0
else
100.0
*
self
.
chun_hits
/
ref_rels_count
f
=
0.0
if
p
+
r
==
0.0
else
2.0
*
p
*
r
/
(
p
+
r
)
print
(
'
Chunk match:
\t
'
)
if
not
stat_mode
:
print
(
'
Chunk match:
\t
'
)
print
'
%.2f
\t
%.2f
\t
%.2f
'
%
(
p
,
r
,
f
)
p
=
0.0
if
target_rels_count
==
0
else
100.0
*
self
.
head_hits
/
target_rels_count
r
=
0.0
if
ref_rels_count
==
0
else
100.0
*
self
.
head_hits
/
ref_rels_count
f
=
0.0
if
p
+
r
==
0.0
else
2.0
*
p
*
r
/
(
p
+
r
)
print
(
'
Head match:
\t
'
)
if
not
stat_mode
:
print
(
'
Head match:
\t
'
)
print
'
%.2f
\t
%.2f
\t
%.2f
'
%
(
p
,
r
,
f
)
def
compare
(
rel1
,
rel2
)
:
...
...
@@ -137,15 +140,19 @@ def go():
parser
.
add_option
(
'
-t
'
,
'
--tagset
'
,
type
=
'
string
'
,
action
=
'
store
'
,
dest
=
'
tagset
'
,
default
=
'
nkjp
'
,
help
=
'
set the tagset used in input; default: nkjp
'
)
parser
.
add_option
(
'
-s
'
,
'
--stat
'
,
action
=
'
store_true
'
,
dest
=
'
stat_mode
'
,
help
=
'
output P,R,f with no text labels, order like in normal mode:
\n
Chunks or heads
\n
Chunks and heads
\n
Chunks match
\n
Heads match
'
)
(
options
,
args
)
=
parser
.
parse_args
()
stat_mode
=
options
.
stat_mode
if
len
(
args
)
!=
3
:
sys
.
stderr
.
write
(
'
No args. See --help
\n
'
)
sys
.
exit
(
1
)
batch_ref
,
batch_target
,
rel_name
=
args
rel_stats
=
RelStats
()
corpus_type
=
"
document
"
...
...
@@ -198,7 +205,7 @@ def go():
line_ref
=
ref_file
.
readline
()
line_target
=
target_file
.
readline
()
rel_stats
.
print_stats
(
ref_count
,
target_count
)
rel_stats
.
print_stats
(
ref_count
,
target_count
,
stat_mode
)
if
__name__
==
'
__main__
'
:
go
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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