Skip to content

Commit

Permalink
Minor tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
mcs07 committed Feb 2, 2017
1 parent e5dab19 commit 3ad045c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
10 changes: 3 additions & 7 deletions chemdataextractor/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,13 +469,9 @@ def merge_contextual(self, other):
for item in self[k]:
# print('item: %s' % item)
for other_item in other.get(k, []):
#RBT Problem with doi: ma301230y. Had to add following check
if (isinstance(other_item,unicode) == True):
continue
# if k in {'names', 'labels'}:
# # TODO: Warn attempting to merge a contextual other that contains names/labels
# continue
# print('other_item: %s' % other_item)
# Skip text properties (don't merge names, labels, roles)
if isinstance(other_item, six.text_type):
continue
for otherk in other_item.keys():
if isinstance(other_item[otherk], list):
if len(other_item[otherk]) > 0 and len(item[otherk]) > 0:
Expand Down
2 changes: 0 additions & 2 deletions chemdataextractor/parse/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ def interpret(self, result, start, end):
'temperature': first(result.xpath('./value/text()')),
'temperature_units': first(result.xpath('./units/text()'))
}
# RBT Same problem as before missing **?
c.quantum_yields = [QuantumYield(**context)]
c.fluorescence_lifetimes = [FluorescenceLifetime(**context)]
c.electrochemical_potentials = [ElectrochemicalPotential(**context)]
Expand All @@ -286,7 +285,6 @@ def interpret(self, result, start, end):
solvent = first(result.xpath('./name/text()'))
if solvent is not None:
context = {'solvent': solvent}
# RBT (Added ** to context)
c.melting_points = [MeltingPoint(**context)]
c.glass_transitions = [GlassTransition(**context)]
c.quantum_yields = [QuantumYield(**context)]
Expand Down
6 changes: 3 additions & 3 deletions chemdataextractor/parse/tg.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
"""
chemdataextractor.parse.nmr
~~~~~~~~~~~~~~~~~~~~~~~~~~~
chemdataextractor.parse.tg
~~~~~~~~~~~~~~~~~~~~~~~~~~
NMR text parser.
Glass transition temperature parser.
:copyright: Copyright 2016 by Matt Swain.
:license: MIT, see LICENSE file for more details.
Expand Down
8 changes: 5 additions & 3 deletions tests/test_parse_tg.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# -*- coding: utf-8 -*-
"""
test_parsetg_
test_parse_tg
~~~~~~~~~~~~~
Test glass transition parser.
:copyright: Copyright 2016 by Matt Swain.
:license: MIT, see LICENSE file for more details.
"""
Expand All @@ -16,7 +18,7 @@

from lxml import etree

from chemdataextractor.doc.text import Sentence, Paragraph
from chemdataextractor.doc.text import Sentence
from chemdataextractor.parse.tg import tg_phrase


Expand Down Expand Up @@ -81,7 +83,7 @@ def test_tg7(self):
self.do_parse(s, expected)

def test_tg8(self):
s= 'DSC experiments revealed that PGFDTDPP has a high glass-transition temperature at 150 °C compared with 90 °C for PGFDTDPP.'
s= 'DSC experiments revealed that PGFDTDPP has a high glass-transition temperature at 150 °C compared with 90 °C for PGFDTDPP.'
expected = '<tg_phrase><tg><value>150</value><units>\xb0C</units></tg></tg_phrase>'
self.do_parse(s, expected)

Expand Down

0 comments on commit 3ad045c

Please sign in to comment.