How to use the paperwork-backend.paperwork_backend.util.strip_accents function in paperwork-backend

To help you get started, we’ve selected a few paperwork-backend examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openpaperwork / paperwork / paperwork-backend / paperwork_backend / labels.py View on Github external
def __label_cmp(self, other):
        """
        Comparaison function. Can be used to sort labels alphabetically.
        """
        if other is None:
            return -1

        label_name = strip_accents(self.name).lower()
        other_name = strip_accents(other.name).lower()
        if label_name < other_name:
            return -1
        elif label_name == other_name:
            return 0
        else:
            return 1

        if self.get_color_str() < other.get_color_str():
            return -1
        elif self.get_color_str() == other.get_color_str():
            return 0
        else:
            return 1
github openpaperwork / paperwork / paperwork-backend / paperwork_backend / index.py View on Github external
dochash = doc.get_docfilehash()
        dochash = (u"%X" % dochash)

        doc_txt = self.get_doc_content(doc)
        labels_txt = doc.get_index_labels()
        assert(isinstance(labels_txt, str))

        query = whoosh.query.Term("docid", docid)
        index_writer.delete_by_query(query)

        index_writer.update_document(
            docid=docid,
            doctype=doc.doctype,
            docfilehash=dochash,
            content=doc_txt,
            label=strip_accents(labels_txt),
            date=doc.date,
            last_read=last_mod
        )
        return True
github openpaperwork / paperwork / paperwork-backend / paperwork_backend / labels.py View on Github external
def __label_cmp(self, other):
        """
        Comparaison function. Can be used to sort labels alphabetically.
        """
        if other is None:
            return -1

        label_name = strip_accents(self.name).lower()
        other_name = strip_accents(other.name).lower()
        if label_name < other_name:
            return -1
        elif label_name == other_name:
            return 0
        else:
            return 1

        if self.get_color_str() < other.get_color_str():
            return -1
        elif self.get_color_str() == other.get_color_str():
            return 0
        else:
            return 1
github openpaperwork / paperwork / paperwork-backend / paperwork_backend / labels.py View on Github external
def _del_doc(self, docid):
        doc = self.index.get_raw_doc_from_index(docid)
        doc_txt = doc['content']
        doc_labels = doc['labels']
        if doc_txt == "":
            logger.warning("Label guessing (del): Doc {} has no text".format(
                doc
            ))
            return

        for (label, guesser) in self.guesser._bayes.items():
            label = strip_accents(label)
            value = "yes" if label in doc_labels else "no"
            guesser.untrain(value, doc_txt)
github openpaperwork / paperwork / paperwork-backend / paperwork_backend / labels.py View on Github external
def _add_doc(self, doc):
        doc_txt = self.index.get_doc_content(doc)
        if doc_txt == "":
            logger.warning("Label guessing (add): Doc {} has no text".format(
                doc.docid
            ))
            return

        labels = {label.name for label in doc.labels}

        # just in case, make sure all the labels are loaded
        for label in labels:
            self.guesser.load(label)

        for (label, guesser) in self.guesser._bayes.items():
            label = strip_accents(label)
            value = "yes" if label in labels else "no"
            guesser.train(value, doc_txt)
github openpaperwork / paperwork / paperwork-backend / paperwork_backend / index.py View on Github external
def find_documents(self, sentence, limit=None, must_sort=True,
                       search_type='fuzzy'):
        """
        Returns all the documents matching the given keywords

        Arguments:
            sentence --- a sentenced query
        Returns:
            An array of document (doc objects)
        """
        sentence = sentence.strip()
        sentence = strip_accents(sentence)

        if sentence == u"":
            return self.get_all_docs()

        result_list_list = []
        total_results = 0

        for query_parser in self.search_param_list[search_type]:
            query = query_parser["query_parser"].parse(sentence)

            sortedby = None
            if must_sort and "sortedby" in query_parser:
                sortedby = query_parser['sortedby']
            if sortedby:
                results = self.__searcher.search(
                    query, limit=limit, sortedby=sortedby