Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F84647144
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
Tue, Sep 24, 02:59
Size
1 KB
Mime Type
text/x-python
Expires
Thu, Sep 26, 02:59 (2 d)
Engine
blob
Format
Raw Data
Handle
21016687
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.page
import
Page
import
process_footnotes
from
process_footnotes
import
categorize_footnotes
,
main
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
word
.
editor_comment
is
not
None
]
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
word
.
editor_comment
is
not
None
]
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