Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chemdataextractor/parse/cem.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

label_blacklist = R('^(31P|[12]H|[23]D|15N|14C|[4567890]\d+)$')

prefixed_label = R('^(cis|trans)-((d-)?(\d{1,2}[A-Za-z]{0,2}[′″‴‶‷⁗]?)(-d)?|[LS]\d\d?)$')
prefixed_label = R('^(trans|[A-Za-z]{,3})-((d-)?(\d{1,2}[A-Za-z]{0,2}[′″‴‶‷⁗]?)(-d)?|[LS]\d\d?)$')

#: Chemical label. Very permissive - must be used in context to avoid false positives.
strict_chemical_label = Not(label_blacklist) + (alphanumeric | roman_numeral | letter_number | prefixed_label)('label')
Expand Down
12 changes: 12 additions & 0 deletions tests/test_parse_cem.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,18 @@ def test_to_yield_phrase(self):
]
self.do_parse(s, expected)

def test_label_start(self):
s = ['1,3,5-Tricyano-2,4,6-tris(2-dimethylaminovinyl)benzene (Leu-07)',
'1,3,5-Tricyano-2,4,6-tris(2-dimethylaminovinyl)benzene (hi-07)',
'1,3,5-Tricyano-2,4,6-tris(2-dimethylaminovinyl)benzene (hife-07)']
expected = [
['<cem_phrase><cem><name>1,3,5-Tricyano-2,4,6-tris(2-dimethylaminovinyl)benzene</name><label>Leu-07</label></cem></cem_phrase>'],
['<cem_phrase><cem><name>1,3,5-Tricyano-2,4,6-tris(2-dimethylaminovinyl)benzene</name><label>hi-07</label></cem></cem_phrase>'],
['<cem_phrase><cem><name>1,3,5-Tricyano-2,4,6-tris(2-dimethylaminovinyl)benzene</name></cem></cem_phrase>']
]
for s_elem, expected_elem in zip(s, expected):
self.do_parse(s_elem, expected_elem)


class TestParseCemHeading(unittest.TestCase):

Expand Down