Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
7c8ae161
Commit
7c8ae161
authored
4 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Fix context size and codestyle
parent
9a1efbe5
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/corpora/cqi/models/attributes.py
+2
-1
2 additions, 1 deletion
app/corpora/cqi/models/attributes.py
app/corpora/cqi/models/corpora.py
+6
-3
6 additions, 3 deletions
app/corpora/cqi/models/corpora.py
app/corpora/cqi/models/subcorpora.py
+6
-5
6 additions, 5 deletions
app/corpora/cqi/models/subcorpora.py
with
14 additions
and
9 deletions
app/corpora/cqi/models/attributes.py
+
2
−
1
View file @
7c8ae161
...
@@ -130,7 +130,8 @@ class StructuralAttribute(Attribute):
...
@@ -130,7 +130,8 @@ class StructuralAttribute(Attribute):
else
:
else
:
cpos_list_lbound
=
first_cpos
cpos_list_lbound
=
first_cpos
rc_rbound
=
\
rc_rbound
=
\
self
.
cpos_by_id
(
min
((
last_id
+
context
),
(
self
.
attrs
[
'
size
'
]
-
1
)))[
1
]
self
.
cpos_by_id
(
min
((
last_id
+
context
),
(
self
.
attrs
[
'
size
'
]
-
1
)))[
1
]
if
rc_rbound
!=
last_cpos
:
if
rc_rbound
!=
last_cpos
:
rc_lbound
=
min
((
last_cpos
+
1
),
rc_lbound
=
min
((
last_cpos
+
1
),
(
self
.
collection
.
corpus
.
attrs
[
'
size
'
]
-
1
))
(
self
.
collection
.
corpus
.
attrs
[
'
size
'
]
-
1
))
...
...
This diff is collapsed.
Click to expand it.
app/corpora/cqi/models/corpora.py
+
6
−
3
View file @
7c8ae161
...
@@ -30,14 +30,16 @@ class Corpus(Model):
...
@@ -30,14 +30,16 @@ class Corpus(Model):
for
attr
in
self
.
positional_attributes
.
list
():
for
attr
in
self
.
positional_attributes
.
list
():
cpos_attr_values
=
attr
.
values_by_cpos
(
cpos_list
)
cpos_attr_values
=
attr
.
values_by_cpos
(
cpos_list
)
for
i
,
cpos
in
enumerate
(
cpos_list
):
for
i
,
cpos
in
enumerate
(
cpos_list
):
lookups
[
'
cpos_lookup
'
][
cpos
][
attr
.
attrs
[
'
name
'
]]
=
cpos_attr_values
[
i
]
lookups
[
'
cpos_lookup
'
][
cpos
][
attr
.
attrs
[
'
name
'
]]
=
\
cpos_attr_values
[
i
]
for
attr
in
self
.
structural_attributes
.
list
():
for
attr
in
self
.
structural_attributes
.
list
():
if
attr
.
attrs
[
'
has_values
'
]:
if
attr
.
attrs
[
'
has_values
'
]:
continue
continue
cpos_attr_ids
=
attr
.
ids_by_cpos
(
cpos_list
)
cpos_attr_ids
=
attr
.
ids_by_cpos
(
cpos_list
)
for
i
,
cpos
in
enumerate
(
cpos_list
):
for
i
,
cpos
in
enumerate
(
cpos_list
):
if
cpos_attr_ids
[
i
]
!=
-
1
:
if
cpos_attr_ids
[
i
]
!=
-
1
:
lookups
[
'
cpos_lookup
'
][
cpos
][
attr
.
attrs
[
'
name
'
]]
=
cpos_attr_ids
[
i
]
lookups
[
'
cpos_lookup
'
][
cpos
][
attr
.
attrs
[
'
name
'
]]
=
\
cpos_attr_ids
[
i
]
occured_attr_ids
=
list
(
filter
(
lambda
x
:
x
!=
-
1
,
occured_attr_ids
=
list
(
filter
(
lambda
x
:
x
!=
-
1
,
set
(
cpos_attr_ids
)))
set
(
cpos_attr_ids
)))
if
not
occured_attr_ids
:
if
not
occured_attr_ids
:
...
@@ -53,7 +55,8 @@ class Corpus(Model):
...
@@ -53,7 +55,8 @@ class Corpus(Model):
for
subattr
in
subattrs
:
for
subattr
in
subattrs
:
subattr_values
=
subattr
.
values_by_ids
(
occured_attr_ids
)
subattr_values
=
subattr
.
values_by_ids
(
occured_attr_ids
)
for
i
,
subattr_value
in
enumerate
(
subattr_values
):
for
i
,
subattr_value
in
enumerate
(
subattr_values
):
subattr_name
=
subattr
.
attrs
[
'
name
'
][(
len
(
attr
.
attrs
[
'
name
'
])
+
1
):]
subattr_name
=
\
subattr
.
attrs
[
'
name
'
][(
len
(
attr
.
attrs
[
'
name
'
])
+
1
):]
lookups
[
lookup_name
][
occured_attr_ids
[
i
]][
subattr_name
]
=
\
lookups
[
lookup_name
][
occured_attr_ids
[
i
]][
subattr_name
]
=
\
subattr_value
subattr_value
return
lookups
return
lookups
...
...
This diff is collapsed.
Click to expand it.
app/corpora/cqi/models/subcorpora.py
+
6
−
5
View file @
7c8ae161
...
@@ -37,9 +37,10 @@ class Subcorpus(Model):
...
@@ -37,9 +37,10 @@ class Subcorpus(Model):
return
{
"
matches
"
:
[]}
return
{
"
matches
"
:
[]}
first_match
=
max
(
0
,
offset
)
first_match
=
max
(
0
,
offset
)
last_match
=
min
((
offset
+
cutoff
-
1
),
(
self
.
attrs
[
'
size
'
]
-
1
))
last_match
=
min
((
offset
+
cutoff
-
1
),
(
self
.
attrs
[
'
size
'
]
-
1
))
match_boundaries
=
\
match_boundaries
=
zip
(
self
.
dump
(
self
.
attrs
[
'
fields
'
][
'
match
'
],
zip
(
self
.
dump
(
self
.
attrs
[
'
fields
'
][
'
match
'
],
first_match
,
last_match
),
# noqa
first_match
,
last_match
),
self
.
dump
(
self
.
attrs
[
'
fields
'
][
'
matchend
'
],
first_match
,
last_match
))
# noqa
self
.
dump
(
self
.
attrs
[
'
fields
'
][
'
matchend
'
],
first_match
,
last_match
))
cpos_list
=
[]
cpos_list
=
[]
matches
=
[]
matches
=
[]
for
match_start
,
match_end
in
match_boundaries
:
for
match_start
,
match_end
in
match_boundaries
:
...
@@ -50,7 +51,7 @@ class Subcorpus(Model):
...
@@ -50,7 +51,7 @@ class Subcorpus(Model):
else
:
else
:
lc_rbound
=
max
(
0
,
(
match_start
-
1
))
lc_rbound
=
max
(
0
,
(
match_start
-
1
))
if
lc_rbound
!=
match_start
:
if
lc_rbound
!=
match_start
:
lc_lbound
=
max
(
0
,
(
match_start
-
1
-
context
))
lc_lbound
=
max
(
0
,
(
match_start
-
context
))
lc
=
(
lc_lbound
,
lc_rbound
)
lc
=
(
lc_lbound
,
lc_rbound
)
cpos_list_lbound
=
lc_lbound
cpos_list_lbound
=
lc_lbound
else
:
else
:
...
@@ -58,7 +59,7 @@ class Subcorpus(Model):
...
@@ -58,7 +59,7 @@ class Subcorpus(Model):
rc_lbound
=
min
((
match_end
+
1
),
rc_lbound
=
min
((
match_end
+
1
),
(
self
.
collection
.
corpus
.
attrs
[
'
size
'
]
-
1
))
(
self
.
collection
.
corpus
.
attrs
[
'
size
'
]
-
1
))
if
rc_lbound
!=
match_end
:
if
rc_lbound
!=
match_end
:
rc_rbound
=
min
((
match_end
+
1
+
context
),
rc_rbound
=
min
((
match_end
+
context
),
(
self
.
collection
.
corpus
.
attrs
[
'
size
'
]
-
1
))
(
self
.
collection
.
corpus
.
attrs
[
'
size
'
]
-
1
))
rc
=
(
rc_lbound
,
rc_rbound
)
rc
=
(
rc_lbound
,
rc_rbound
)
cpos_list_rbound
=
rc_rbound
cpos_list_rbound
=
rc_rbound
...
...
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