def __create_caluse__(self, index, item_contents): items = [item.strip() for item in item_contents if len(item.strip()) > 0] comeFrom = {u'category': u'Book', u'name': u'伤寒论'} content = '' if len(items) > 0: content = '\n'.join(items) parser = PrescriptionParser(content, u'方', QuantityAdjustor()) prescriptions = parser.get_prescriptions() for prescription in prescriptions: prescription.update({'comeFrom' : comeFrom}) return {'index':index, 'content':content, 'prescriptions':prescriptions, 'comeFrom' : comeFrom}
def __createClause__(self, index, item_contents): items = [item.strip() for item in item_contents if len(item.strip()) > 0] comeFrom = {u'bookTitle': u'伤寒论'} content = '' if len(items) > 0: content = '\n'.join(items) parser = PrescriptionParser(content, u'方', QuantityAdjustor()) content, prescriptions = parser.extractPrescriptions() for prescription in prescriptions: prescription.update({'comeFrom' : comeFrom}) return {'index':index, 'content':content, 'prescriptions':prescriptions, 'comeFrom' : comeFrom}
def __create_clause__(self, item_contents, category): content = '\n'.join(item_contents) matches = re.findall(ur"\s*(\d{1,3})\u3001", content) index = int(matches[0]) clause = {'index':index, 'content' : content, 'category':category} clause.update(self._come_from) parser = PrescriptionParser(content, u"方:", QuantityAdjustor()) prescriptions = parser.get_prescriptions() for prescription in prescriptions: prescription.update(self._come_from) clause['prescriptions'] = prescriptions return clause