Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F80566927
test_standoff_tag.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, Sep 1, 10:25
Size
2 KB
Mime Type
text/x-python
Expires
Tue, Sep 3, 10:25 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20396209
Attached To
rNIETZSCHEPYTHON nietzsche-python
test_standoff_tag.py
View Options
import
unittest
from
os
import
sep
,
path
from
os.path
import
dirname
,
basename
,
isfile
,
isdir
import
lxml.etree
as
ET
import
sys
sys
.
path
.
append
(
'svgscripts'
)
from
datatypes.page
import
Page
from
datatypes.standoff_tag
import
StandoffTag
class
TestStandoffTag
(
unittest
.
TestCase
):
def
setUp
(
self
):
DATADIR
=
dirname
(
__file__
)
+
sep
+
'test_data'
if
not
isdir
(
DATADIR
):
DATADIR
=
dirname
(
dirname
(
__file__
))
+
sep
+
'test_data'
self
.
test_file
=
DATADIR
+
sep
+
'test.xml'
self
.
test_svg_file
=
DATADIR
+
sep
+
'test421.svg'
self
.
pdf_xml
=
DATADIR
+
sep
+
'W_I_8_page125.xml'
self
.
xml_file
=
DATADIR
+
sep
+
'N_VII_1_page005.xml'
self
.
xml_fileB
=
DATADIR
+
sep
+
'N_VII_1_page006.xml'
self
.
pdf_xml_source
=
DATADIR
+
sep
+
'W_I_8_neu_125-01.svg'
self
.
test_page
=
DATADIR
+
sep
+
'N_VII_1_page001.xml'
self
.
test_manuscript
=
DATADIR
+
sep
+
'N_VII_1.xml'
def
test_attach_to_tree
(
self
):
empty_tree
=
ET
.
ElementTree
(
ET
.
Element
(
'page'
))
standoff_tag
=
StandoffTag
(
'bold'
,
0
,
10
)
standoff_tag
.
attach_object_to_tree
(
empty_tree
)
standoff_tag
=
StandoffTag
(
'bold'
,
0
,
10
,
id
=
1
)
standoff_tag
.
attach_object_to_tree
(
empty_tree
)
node
=
empty_tree
.
xpath
(
'//bold[@id="0"]'
)[
0
]
standoff_tag
=
StandoffTag
.
create_cls_from_node
(
node
)
self
.
assertEqual
(
standoff_tag
.
markup
,
'bold'
)
self
.
assertEqual
(
standoff_tag
.
id
,
'0'
)
self
.
assertEqual
(
standoff_tag
.
startIndex
,
0
)
self
.
assertEqual
(
standoff_tag
.
endIndex
,
10
)
def
test_create_cls
(
self
):
page
=
Page
(
self
.
test_page
)
style_string
=
"st2 st6"
standoff_tags
=
StandoffTag
.
create_cls
(
0
,
0
,
style_string
,
page
=
page
)
self
.
assertEqual
(
len
(
standoff_tags
),
1
)
self
.
assertEqual
(
standoff_tags
[
0
]
.
markup
,
'italic'
)
style_string
=
"st8 st6"
standoff_tags
=
StandoffTag
.
create_cls
(
0
,
0
,
style_string
,
page
=
page
)
self
.
assertEqual
(
len
(
standoff_tags
),
1
)
self
.
assertEqual
(
standoff_tags
[
0
]
.
markup
,
'bold'
)
def
test_create_relevant_dict
(
self
):
page
=
Page
(
self
.
test_page
)
relevant_dict
=
StandoffTag
.
create_relevant_style_dictionary
(
page
)
self
.
assertEqual
(
len
(
relevant_dict
),
4
)
def
test_semantic
(
self
):
pass
#print(StandoffTag.get_semantic_dictionary())
if
__name__
==
"__main__"
:
unittest
.
main
()
Event Timeline
Log In to Comment