How to use the reynir.fastparser.Fast_Parser.num_combinations function in reynir

To help you get started, we’ve selected a few reynir 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 mideind / Greynir / incparser.py View on Github external
def parse(self):
            """ Parse the sentence """
            num = 0
            score = 0
            try:
                forest = self._ip._parser.go(self._s)
                if forest is not None:
                    num = Fast_Parser.num_combinations(forest)
                    if num > 1:
                        forest, score = self._ip._reducer.go_with_score(forest)
            except ParseError as e:
                forest = None
                self._err_index = e.token_index
            self._tree = forest
            self._score = score
            self._ip._add_sentence(self, num)
            return num > 0
github mideind / Greynir / query.py View on Github external
for t in toklist:
            if t[0] == TOK.S_BEGIN:
                sent = []
            elif t[0] == TOK.S_END:
                slen = len(sent)
                if not slen:
                    continue
                num_sent += 1
                # Parse the accumulated sentence
                num = 0
                try:
                    # Parse the sentence
                    forest = bp.go(sent)
                    if forest is not None:
                        num = Fast_Parser.num_combinations(forest)
                        if num > 1:
                            # Reduce the resulting forest
                            forest = rdc.go(forest)
                except ParseError:
                    forest = None
                if num > 0:
                    num_parsed_sent += 1
                    # Obtain a text representation of the parse tree
                    trees[num_sent] = ParseForestDumper.dump_forest(forest)

            elif t[0] == TOK.P_BEGIN:
                pass
            elif t[0] == TOK.P_END:
                pass
            else:
                sent.append(t)