Exemplo n.º 1
0
    def generate_search_data(self):
        seen = set()
        out = []
        for sutta in self.suttas.values():
            if isinstance(sutta, GroupedSutta):
                if sutta.name in seen:
                    continue
                seen.add(sutta.name)
            name = sutta.name
            plain_name = textfunctions.codely(name)
            coded_name = textfunctions.plainly(name)
            simple_name = textfunctions.simplify(sutta.name, sutta.lang.iso_code)

            searchdata = {'uid': sutta.uid,
                'lang_code': sutta.lang.iso_code,
                'acronym': sutta.acronym,
                'name': name,
                'plain_name': plain_name,
                'coded_name': coded_name,
                'simple_name': simple_name,
                'volpage': sutta.volpage,
                'languages': " ".join(t.lang.iso_code for t in sutta.translations)}

            if sutta.alt_volpage_info:
                searchdata['volpage'] += '  ' + sutta.alt_volpage_info

            if sutta.alt_acronym:
                searchdata['acronym'] += '  ' + sutta.alt_acronym

            for k in list(searchdata.keys()):
                if searchdata[k] is None:
                    del searchdata[k]
            searchdata['md5'] = hashlib.md5(str(searchdata).encode()).hexdigest()[0:5]
            yield searchdata
Exemplo n.º 2
0
    def generate_search_data(self):
        seen = set()
        out = []
        for sutta in self.suttas.values():
            if isinstance(sutta, GroupedSutta):
                if sutta.name in seen:
                    continue
                seen.add(sutta.name)
            name = sutta.name
            plain_name = textfunctions.codely(name)
            coded_name = textfunctions.plainly(name)
            simple_name = textfunctions.simplify(sutta.name, sutta.lang.iso_code)

            searchdata = {'uid': sutta.uid,
                'lang_code': sutta.lang.iso_code,
                'acronym': sutta.acronym,
                'name': name,
                'plain_name': plain_name,
                'coded_name': coded_name,
                'simple_name': simple_name,
                'volpage': sutta.volpage,
                'languages': " ".join(t.lang.iso_code for t in sutta.translations)}

            if sutta.alt_volpage_info:
                searchdata['volpage'] += '  ' + sutta.alt_volpage_info

            if sutta.alt_acronym:
                searchdata['acronym'] += '  ' + sutta.alt_acronym

            for k in list(searchdata.keys()):
                if searchdata[k] is None:
                    del searchdata[k]
            searchdata['md5'] = hashlib.md5(str(searchdata).encode()).hexdigest()[0:5]
            yield searchdata
Exemplo n.º 3
0
    def build_search_data(self):
        """ Build useful search data.

        Note that the size of the data is somewhat less than 2mb """
        
        suttastringsU = []
        seen = set()
        for sutta in self.suttas.values():
            if isinstance(sutta, GroupedSutta):
                if sutta.name in seen:
                    continue
                seen.add(sutta.name)
            name = sutta.name.lower()
            suttastringsU.append("  {}  ".format("  ".join(
                                [sutta.uid,
                                sutta.lang.iso_code,
                                sutta.acronym,
                                sutta.alt_acronym or '',
                                name,
                                textfunctions.codely(name),
                                textfunctions.plainly(name),
                                sutta.volpage_info,
                                sutta.alt_volpage_info or '',
                                "  ".join( t.lang.iso_code
                                    for t in sutta.translations,) or '',]))
                                )
        suttastrings = [s.lower() for s in suttastringsU]
        # Only simplify the name.
        suttanamesimplified = (["  {}  ".format(
            textfunctions.simplify(sutta.name, sutta.lang.iso_code))
            for sutta in self.suttas.values()])

        self.searchstrings = list(zip(self.suttas.values(), suttastrings, suttastringsU, suttanamesimplified))
Exemplo n.º 4
0
    def build_search_data(self):
        """ Build useful search data.

        Note that the size of the data is somewhat less than 2mb """
        
        suttastringsU = []
        seen = set()
        for sutta in self.suttas.values():
            if isinstance(sutta, GroupedSutta):
                if sutta.name in seen:
                    continue
                seen.add(sutta.name)
            name = sutta.name.lower()
            suttastringsU.append("  {}  ".format("  ".join(
                                [sutta.uid,
                                sutta.lang.iso_code,
                                sutta.acronym,
                                sutta.alt_acronym or '',
                                name,
                                textfunctions.codely(name),
                                textfunctions.plainly(name),
                                sutta.volpage_info,
                                sutta.alt_volpage_info or '',
                                "  ".join( t.lang.iso_code
                                    for t in sutta.translations,) or '',]))
                                )
        suttastrings = [s.lower() for s in suttastringsU]
        # Only simplify the name.
        suttanamesimplified = (["  {}  ".format(
            textfunctions.simplify(sutta.name, sutta.lang.iso_code))
            for sutta in self.suttas.values()])

        self.searchstrings = list(zip(self.suttas.values(), suttastrings, suttastringsU, suttanamesimplified))