Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F86467906
test_extract_line_continuation.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Oct 6, 16:21
Size
2 KB
Mime Type
text/x-python
Expires
Tue, Oct 8, 16:21 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
21426541
Attached To
rNIETZSCHEPYTHON nietzsche-python
test_extract_line_continuation.py
View Options
import
unittest
from
os
import
sep
,
path
,
remove
from
os.path
import
isfile
import
lxml.etree
as
ET
import
warnings
import
sys
sys
.
path
.
append
(
'svgscripts'
)
import
extract_line_continuation
from
datatypes.page
import
Page
from
datatypes.transkriptionField
import
TranskriptionField
class
TestExtractLineContinuation
(
unittest
.
TestCase
):
def
setUp
(
self
):
extract_line_continuation
.
UNITTESTING
=
True
DATADIR
=
path
.
dirname
(
__file__
)
+
sep
+
'test_data'
self
.
w_I_8_125_svg
=
DATADIR
+
sep
+
'W_I_8_neu_125-01.svg'
self
.
w_I_8_125_xml
=
DATADIR
+
sep
+
'W_I_8_new_page125.xml'
def
test_get_arrow_y
(
self
):
arrow
=
ET
.
Element
(
'text'
)
arrow
.
set
(
'transform'
,
'matrix(1 0 0 1 10 20)'
)
self
.
assertEqual
(
extract_line_continuation
.
_get_arrow_y
(
arrow
),
20.0
)
tspan
=
ET
.
SubElement
(
arrow
,
'tspan'
)
tspan
.
set
(
'y'
,
'10.0'
)
self
.
assertEqual
(
extract_line_continuation
.
_get_arrow_y
(
tspan
),
30.0
)
def
test_get_line_of_arrow
(
self
):
svg_tree
=
ET
.
parse
(
self
.
w_I_8_125_svg
)
page
=
Page
(
self
.
w_I_8_125_xml
)
transkription_field
=
TranskriptionField
(
self
.
w_I_8_125_svg
)
arrows
=
extract_line_continuation
.
_extract_arrow_nodes
(
svg_tree
,
'st7'
)
line
=
extract_line_continuation
.
_get_line_of_arrow
(
arrows
[
0
],
page
,
transkription_field
.
ymin
)
self
.
assertEqual
(
line
.
id
,
15
)
def
test_extract_line_continuations
(
self
):
page
=
Page
(
self
.
w_I_8_125_xml
)
extract_line_continuation
.
extract_line_continuations
(
page
,
svg_file
=
self
.
w_I_8_125_svg
)
lines_with_continuations
=
[
line
for
line
in
page
.
lines
if
len
(
line
.
editor_comments
)
>
0
]
self
.
assertEqual
(
len
(
lines_with_continuations
),
2
)
page
=
Page
(
'xml/N_VII_1_page029.xml'
)
extract_line_continuation
.
extract_line_continuations
(
page
)
lines_with_continuations
=
[
line
for
line
in
page
.
lines
if
len
(
line
.
editor_comments
)
>
0
]
#print(lines_with_continuations)
self
.
assertEqual
(
len
(
lines_with_continuations
),
1
)
page
=
Page
(
'xml/Mp_XV_page75v.xml'
)
extract_line_continuation
.
extract_line_continuations
(
page
)
lines_with_continuations
=
[
line
for
line
in
page
.
lines
if
len
(
line
.
editor_comments
)
>
0
]
self
.
assertTrue
(
len
(
lines_with_continuations
)
>
0
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Event Timeline
Log In to Comment