# Path: chemdataextractor/text/chem.py
# SOLVENT_RE = re.compile(r'(?:^|\b)(?:(?:%s|d\d?\d?|[\dn](?:,[\dn]){0,3}|[imnoptDLRS])-?)?(?:%s)(?:-d\d?\d?)?(?=$|\b)'
#                         % ('|'.join(re.escape(s) for s in PREFIXES),
#                            '|'.join(re.escape(s).replace(r'\ ', r'[\s\-]?') for s in SOLVENTS)), re.I)
# 
# INCHI_RE = re.compile(r'^(InChI=)?1S?\/(p\+1|\d*[a-ik-z][a-ik-z\d\.]*(\/c[\d\-*(),;]+)?(\/h[\d\-*h(),;]+)?)(\/[bmpqst][\d\-\.+*,;?m]*|\/i[hdt\d\-+*,;]*(\/h[hdt\d]+)?|\/r[a-ik-z\d]+(\/c[\d\-*(),;]+)?(\/h[\d\-*h(),;]+)?|\/f[a-ik-z\d\.]*(\/h[\d\-*h(),;]+)?)*$', re.I)
# 
# SMILES_RE = re.compile(r'^([BCNOPSFIbcnosp*]|Cl|Br|\[\d*(%(e)s|se|as|\*)(@+([THALSPBO]\d+)?)?(H\d?)?([\-+]+\d*)?(:\d+)?\])'
#                        r'([BCNOPSFIbcnosp*]|Cl|Br|\[\d*(%(e)s|se|as|\*)(@+([THALSPBO]\d+)?)?(H\d?)?([\-+]+\d*)?(:\d+)?\]|'
#                        r'[\-=#$:\\/\(\)%%\.+\d])*$' % {'e': '|'.join(ELEMENT_SYMBOLS)})


import logging
import unittest
from chemdataextractor.text.chem import SOLVENT_RE, INCHI_RE, SMILES_RE
test_text_chem
~~~~~~~~~~~~~~

Test the text chem package.

"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals



logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__)


class TestRegex(unittest.TestCase):

    def test_solvent(self):
        """Test solvent regex."""
        self.assertEqual([u'CH2Cl2'], SOLVENT_RE.findall(u'λmax(CH2Cl2)/nm'))
        self.assertEqual([u'acetonitrile', u'C6H6'], SOLVENT_RE.findall(u'Measured in acetonitrile and C6H6'))
        self.assertEqual([u'd2-dichloromethane'], SOLVENT_RE.findall(u'Spectra in d2-dichloromethane'))
        self.assertEqual([u'isopropanol'], SOLVENT_RE.findall(u'The solvent was isopropanol'))
        self.assertEqual([u'1,2-dichlorobenzene'], SOLVENT_RE.findall(u'Mixed with 1,2-dichlorobenzene.'))
        self.assertEqual([u'CHCl3', u'HCl'], SOLVENT_RE.findall(u'The mixture CHCl3/HCl was added.'))
        self.assertEqual([u'Ethyl acetate', u'Diethyl ether'], SOLVENT_RE.findall(u'Ethyl acetate. Diethyl ether.'))
        self.assertEqual([u'Ethylacetate', u'Diethylether'], SOLVENT_RE.findall(u'Ethylacetate. Diethylether.'))

# Path: chemdataextractor/text/chem.py
# SOLVENT_RE = re.compile(r'(?:^|\b)(?:(?:%s|d\d?\d?|[\dn](?:,[\dn]){0,3}|[imnoptDLRS])-?)?(?:%s)(?:-d\d?\d?)?(?=$|\b)'
#                         % ('|'.join(re.escape(s) for s in PREFIXES),
#                            '|'.join(re.escape(s).replace(r'\ ', r'[\s\-]?') for s in SOLVENTS)), re.I)
# 
# INCHI_RE = re.compile(r'^(InChI=)?1S?\/(p\+1|\d*[a-ik-z][a-ik-z\d\.]*(\/c[\d\-*(),;]+)?(\/h[\d\-*h(),;]+)?)(\/[bmpqst][\d\-\.+*,;?m]*|\/i[hdt\d\-+*,;]*(\/h[hdt\d]+)?|\/r[a-ik-z\d]+(\/c[\d\-*(),;]+)?(\/h[\d\-*h(),;]+)?|\/f[a-ik-z\d\.]*(\/h[\d\-*h(),;]+)?)*$', re.I)
# 
# SMILES_RE = re.compile(r'^([BCNOPSFIbcnosp*]|Cl|Br|\[\d*(%(e)s|se|as|\*)(@+([THALSPBO]\d+)?)?(H\d?)?([\-+]+\d*)?(:\d+)?\])'
#                        r'([BCNOPSFIbcnosp*]|Cl|Br|\[\d*(%(e)s|se|as|\*)(@+([THALSPBO]\d+)?)?(H\d?)?([\-+]+\d*)?(:\d+)?\]|'
#                        r'[\-=#$:\\/\(\)%%\.+\d])*$' % {'e': '|'.join(ELEMENT_SYMBOLS)})


# Path: tests/test_text_chem.py
import logging
import unittest
from chemdataextractor.text.chem import SOLVENT_RE, INCHI_RE, SMILES_RE

test_text_chem
~~~~~~~~~~~~~~

Test the text chem package.

"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals



logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__)


class TestRegex(unittest.TestCase):

    def test_solvent(self):
        """Test solvent regex."""
        self.assertEqual([u'CH2Cl2'], SOLVENT_RE.findall(u'λmax(CH2Cl2)/nm'))
        self.assertEqual([u'acetonitrile', u'C6H6'], SOLVENT_RE.findall(u'Measured in acetonitrile and C6H6'))
        self.assertEqual([u'd2-dichloromethane'], SOLVENT_RE.findall(u'Spectra in d2-dichloromethane'))
        self.assertEqual([u'isopropanol'], SOLVENT_RE.findall(u'The solvent was isopropanol'))
        self.assertEqual([u'1,2-dichlorobenzene'], SOLVENT_RE.findall(u'Mixed with 1,2-dichlorobenzene.'))
        self.assertEqual([u'CHCl3', u'HCl'], SOLVENT_RE.findall(u'The mixture CHCl3/HCl was added.'))
        self.assertEqual([u'Ethyl acetate', u'Diethyl ether'], SOLVENT_RE.findall(u'Ethyl acetate. Diethyl ether.'))
        self.assertEqual([u'Ethylacetate', u'Diethylether'], SOLVENT_RE.findall(u'Ethylacetate. Diethylether.'))

        self.assertEqual([], SOLVENT_RE.findall(u'[Rh2(dihex)4]2+'))