@@ -0,0 +1,1898 @@
+u%22%22%22text.%0A%0AUsage:%0A  text clean-purpose %3Cpurpose%3E%0A%0AExample:%0A  $ python -m cvrminer.text clean-purpose %22Selskabets form%C3%A5l er handel%22%0A  handel%0A%0A%22%22%22%0A%0Aimport re%0A%0Afrom six import u%0A%0A%0Aclass PurposeProcessor(object):%0A    %22%22%22Text processor for company purpose.%22%22%22%0A%0A    def __init__(self):%0A        %22%22%22Setup pattern.%22%22%22%0A        self.ignore_pattern = re.compile(%0A            u%22%22%22%0A            Selskabets%5Csform%5Cxe5l%5Cser%5Csat%5Csdrive%7C%0A            Selskabets%5Csform%5Cxe5l%5Cser%7C%0A            og%5Csdermed%5Csbesl%5Cxe6gtet%5Csvirksomhed%7C%0A            %5C.$%0A            %22%22%22,%0A            flags=re.UNICODE %7C re.VERBOSE)%0A%0A        self.stop_words = set(re.split('%5Cs+', u(%22%22%22%0A            af anden at%0A            besl%5Cxe6gtet%0A            dermed efter forbindelse herunder i inden og om%0A            samt til virksomhed%0A        %22%22%22).strip(), flags=re.UNICODE %7C re.DOTALL))%0A%0A        regex = '%7C'.join(self.stop_words)%0A        regex = r'%5Cb(?:' + regex + r')%5Cb'%0A        self.stop_words_pattern = re.compile(regex, flags=re.UNICODE)%0A%0A    def clean(self, text):%0A        u%22%22%22Clean purpose text.%0A%0A        Parameters%0A        ----------%0A        text : str%0A           String with purpose%0A%0A        Description%0A        -----------%0A        Remove the following fragments:%0A%0A        %22Selskabets formal er at drive%22%0A        %22Selskabets form%C3%A5l er%22%0A        %22og anden dermed besl%C3%A6gtet virksomhed%22%0A        %22dermed besl%C3%A6gtet virksomhed%22%0A        %22hermed besl%C3%A6gtet virksomhed%22%0A%0A        %22%22%22%0A        return self.stop_words_pattern.sub(%0A            '', self.ignore_pattern.sub('', text)).strip()%0A%0A%0Adef main():%0A    %22%22%22Handle command-line interface.%22%22%22%0A    from docopt import docopt%0A%0A    arguments = docopt(__doc__)%0A%0A    if arguments%5B'clean-purpose'%5D:%0A        purpose = arguments%5B'%3Cpurpose%3E'%5D.decode('utf-8')%0A        processor = PurposeProcessor()%0A        cleaned_purpose = processor.clean(purpose)%0A        print(cleaned_purpose)%0A%0A%0Aif __name__ == '__main__':%0A    main()%0A

Create text.py