Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F77956709
test_process_footnotes.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
Sat, Aug 17, 11:31
Size
2 KB
Mime Type
text/x-python
Expires
Mon, Aug 19, 11:31 (2 d)
Engine
blob
Format
Raw Data
Handle
19956034
Attached To
rNIETZSCHEPYTHON nietzsche-python
test_process_footnotes.py
View Options
import
unittest
from
os
import
sep
,
path
,
remove
from
os.path
import
isdir
,
isfile
,
dirname
import
shutil
import
sys
import
lxml.etree
as
ET
import
warnings
import
sys
sys
.
path
.
append
(
'svgscripts'
)
from
datatypes.footnotes
import
extract_footnotes
from
datatypes.imprint
import
Imprint
from
datatypes.page
import
Page
import
process_footnotes
from
process_footnotes
import
categorize_footnotes
,
main
,
save_imprints
class
TestExtractFootnotes
(
unittest
.
TestCase
):
def
setUp
(
self
):
process_footnotes
.
UNITTESTING
=
True
DATADIR
=
path
.
dirname
(
__file__
)
+
sep
+
'test_data'
self
.
test_footnote
=
DATADIR
+
sep
+
'W_I_8_neu_125-01.svg'
self
.
test_footnote_verso
=
DATADIR
+
sep
+
'N_VII_1_xp5_4_page5.svg'
self
.
test_footnote_recto
=
DATADIR
+
sep
+
'N_VII_1_xp5_4_page6.svg'
self
.
test_footnote_multi
=
DATADIR
+
sep
+
'N_VII_1_xp5_4_page13.svg'
self
.
test_footnote_multi_xml
=
DATADIR
+
sep
+
'N_VII_1_page013.xml'
self
.
test_categorize_footnote
=
DATADIR
+
sep
+
'N_VII_1_page006.xml'
def
test_categorize_footnotes
(
self
):
page
=
Page
(
self
.
test_categorize_footnote
)
footnotes
=
extract_footnotes
(
page
,
svg_file
=
self
.
test_footnote_recto
)
categorize_footnotes
(
page
,
footnotes
)
words_with_comments
=
[
word
for
word
in
page
.
words
if
len
(
word
.
editor_comments
)
>
0
]
self
.
assertEqual
(
len
(
words_with_comments
),
4
)
lines_with_comments
=
[
line
for
line
in
page
.
lines
if
len
(
line
.
editor_comments
)
>
0
]
self
.
assertEqual
(
len
(
lines_with_comments
),
1
)
page
=
Page
(
'xml/W_II_1_page141.xml'
)
footnotes
=
extract_footnotes
(
page
)
categorize_footnotes
(
page
,
footnotes
,
debug
=
True
)
words_with_comments
=
[
word
for
word
in
page
.
words
if
len
(
word
.
editor_comments
)
>
0
]
def
test_save_imprints
(
self
):
page
=
Page
(
self
.
test_categorize_footnote
)
save_imprints
(
page
)
self
.
assertEqual
(
len
(
page
.
page_tree
.
xpath
(
'//'
+
Imprint
.
XML_TAG
)),
2
)
#print(ET.dump(page.page_tree.getroot()))
def
test_main
(
self
):
self
.
assertEqual
(
main
([
'xml/N_VII_1_page005.xml'
]),
0
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Event Timeline
Log In to Comment