예제 #1
0
    def codify_issue(self, filename):
        """Codify certain issue (legacy)
        :params filename : Issue filename
        """

        trees = {}
        issue = parser.IssueParser(filename)
        sorted_articles = sorted(issue.articles.keys())

        for article in sorted_articles:

            for i, extract in enumerate(issue.get_non_extracts(article)):
                trees[i] = syntax.ActionTreeGenerator.generate_action_tree(
                    extract, issue, article)
                for j, t in enumerate(trees[i]):
                    print(t['root'])
                    print(t['what'])
                    law_id = t['law']['_id']
                    print('Law id is ', law_id)

                    try:

                        if law_id not in self.laws.keys():
                            print('Not in keys')
                            self.laws[law_id] = parser.LawParser(law_id)

                        self.db.query_from_tree(self.laws[law_id], t)

                        print('Pushed to Database')
                    except Exception as e:
                        print(str(e))
                        continue

                    print('\nPress any key to continue')
                    input()
예제 #2
0
    def codify_law(self, identifier):
        """
        Codify certain law. Search all issues within self.issues
        :param identifier : The law identifier e.g. ν. 1234/5678
        """
        trees = {}

        for issue in self.issues:
            for article in issue.find_statute(identifier):
                print(article, issue.name)
                print('Codifying')

                for i, non_extract in enumerate(
                        issue.get_non_extracts(article)):
                    trees[i] = syntax.ActionTreeGenerator.generate_action_tree(
                        non_extract, issue, article)
                    for j, t in enumerate(trees[i]):
                        print(t['root'])
                        print(t['what'])
                        law_id = t['law']['_id']
                        print('Law id is ', law_id)

                        try:

                            if law_id not in self.laws.keys():
                                print('Not in keys')
                                self.laws[law_id] = parser.LawParser(law_id)

                            print('Ammendee, ', issue.name)
                            self.db.query_from_tree(
                                self.laws[law_id], t, issue.name)

                            print('Pushed to Database')
                        except Exception as e:
                            print(str(e))
                            continue

                        print('\nPress any key to continue')
                        input()