コード例 #1
0
ファイル: api.py プロジェクト: IgorWang/IgorNLP
 def parse(self, sent, *args, **kwargs):
     '''
     :param sent: list(str)
     :param args:
     :param kwargs:
     :return:An iterator that generates parse for the sentence.
     '''
     if overridden(self.parse_sents):
         return next(self.parse_sents([sent], *args, **kwargs))
     elif overridden(self.parse_one):
         return (tree for tree in [self.parse_one(sent, *args, **kwargs)] if tree is not None)
     elif overridden(self.parse_all):
         return iter(self.parse_all(sent, *args, **kwargs))
     else:
         raise NotImplementedError()
コード例 #2
0
    def parse(self, sent, *args, **kwargs):
        """
        :return: An iterator that generates parse trees for the sentence.
        When possible this list is sorted from most likely to least likely.

        :param sent: The sentence to be parsed
        :type sent: list(str)
        :rtype: iter(Tree)
        """
        if overridden(self.parse_sents):
            return next(self.parse_sents([sent], *args, **kwargs))
        elif overridden(self.parse_one):
            return (tree for tree in [self.parse_one(sent, *args, **kwargs)] if tree is not None)
        elif overridden(self.parse_all):
            return iter(self.parse_all(sent, *args, **kwargs))
        else:
            raise NotImplementedError()
コード例 #3
0
ファイル: api.py プロジェクト: Aman020/Big-Data-Analytics
    def tokenize(self, s):
        """
        Return a tokenized copy of *s*.

        :rtype: list of str
        """
        if overridden(self.tokenize_sents):
            return self.tokenize_sents([s])[0]
コード例 #4
0
    def tokenize(self, s: str) -> List[str]:
        """
        Return a tokenized copy of *s*.

        :rtype: List[str]
        """
        if overridden(self.tokenize_sents):
            return self.tokenize_sents([s])[0]
コード例 #5
0
ファイル: api.py プロジェクト: DrDub/nltk
    def parse(self, sent, *args, **kwargs):
        """
        :return: An iterator that generates parse trees for the sentence.
        When possible this list is sorted from most likely to least likely.

        :param sent: The sentence to be parsed
        :type sent: list(str)
        :rtype: iter(Tree)
        """
        if overridden(self.parse_sents):
            return next(self.parse_sents([sent], *args, **kwargs))
        elif overridden(self.parse_one):
            return (tree for tree in [self.parse_one(sent, *args, **kwargs)] if tree is not None)
        elif overridden(self.parse_all):
            return iter(self.parse_all(sent, *args, **kwargs))
        else:
            raise NotImplementedError()
コード例 #6
0
ファイル: api.py プロジェクト: DrDub/nltk
 def classify(self, featureset):
     """
     :return: the most appropriate set of labels for the given featureset.
     :rtype: set(label)
     """
     if overridden(self.classify_many):
         return self.classify_many([featureset])[0]
     else:
         raise NotImplementedError()
コード例 #7
0
ファイル: api.py プロジェクト: CPHB-FKMP/book-extractor
 def classify(self, featureset):
     """
     :return: the most appropriate set of labels for the given featureset.
     :rtype: set(label)
     """
     if overridden(self.classify_many):
         return self.classify_many([featureset])[0]
     else:
         raise NotImplementedError()
コード例 #8
0
ファイル: api.py プロジェクト: wrand/tweater
 def classify(self, featureset):
     """
     @return: the most appropriate set of labels for the given featureset.
     @rtype: C{set} of I{label}
     """
     if overridden(self.batch_classify):
         return self.batch_classify([featureset])[0]
     else:
         raise NotImplementedError()
コード例 #9
0
ファイル: api.py プロジェクト: VinodhSubramanian1193/NLP
 def classify(self, featureset):
     """
     :return: the most appropriate label for the given featureset.
     :rtype: label
     """
     if overridden(self.batch_classify):
         return self.batch_classify([featureset])[0]
     else:
         raise NotImplementedError()
コード例 #10
0
ファイル: api.py プロジェクト: B-Rich/Fem-Coding-Challenge
 def classify(self, featureset):
     """
     @return: the most appropriate label for the given featureset.
     @rtype: label
     """
     if overridden(self.batch_classify):
         return self.batch_classify([featureset])[0]
     else:
         raise NotImplementedError()
コード例 #11
0
ファイル: ltp.py プロジェクト: IgorWang/IgorNLP
 def tag(self, tokens):
     '''
     标注单个句子
     :param tokens:list
     :return:list(tuple(str,str))
     '''
     if overridden(self.tag_sents):
         return self.tag_sents([tokens])[0]
     else:
         raise NotImplementedError()
コード例 #12
0
ファイル: api.py プロジェクト: VinodhSubramanian1193/NLP
 def prob_classify(self, featureset):
     """
     :return: a probability distribution over labels for the given
         featureset.
     :rtype: ProbDistI
     """
     if overridden(self.batch_prob_classify):
         return self.batch_prob_classify([featureset])[0]
     else:
         raise NotImplementedError()
コード例 #13
0
ファイル: api.py プロジェクト: wrand/tweater
 def prob_classify(self, featureset):
     """
     @return: a probability distribution over sets of labels for the
         given featureset.
     @rtype: L{ProbDistI <nltk.probability.ProbDistI>}
     """
     if overridden(self.batch_prob_classify):
         return self.batch_prob_classify([featureset])[0]
     else:
         raise NotImplementedError()
コード例 #14
0
ファイル: ltp.py プロジェクト: IgorWang/IgorNLP
 def parse(self, sent, *args, **kwargs):
     '''
     解析单个句子
     :param tokens:list
     :return:list(tuple(str,str))
     '''
     if overridden(self.parse_sents):
         return self.parse_sents([sent])[0]
     else:
         raise NotImplementedError()
コード例 #15
0
ファイル: api.py プロジェクト: DrDub/icsisumm
 def tokenize(self, s):
     """
     Divide the given string into a list of substrings.
     
     @return: C{list} of C{str}
     """
     if overridden(self.batch_tokenize):
         return self.batch_tokenize([s])[0]
     else:
         raise NotImplementedError()
コード例 #16
0
 def tokenize(self, s):
     """
     Divide the given string into a list of substrings.
     
     @return: C{list} of C{str}
     """
     if overridden(self.batch_tokenize):
         return self.batch_tokenize([s])[0]
     else:
         raise NotImplementedError()
コード例 #17
0
    def tag(self, tokens):
        """
        Determine the most appropriate tag sequence for the given
        token sequence, and return a corresponding list of tagged
        tokens.  A tagged token is encoded as a tuple ``(token, tag)``.

        :rtype: list(tuple(str, str))
        """
        if overridden(self.tag_sents):
            return self.tag_sents([tokens])[0]
コード例 #18
0
ファイル: api.py プロジェクト: 0day1day/golismero
    def tokenize(self, s):
        """
        Return a tokenized copy of *s*.

        :rtype: list of str
        """
        if overridden(self.batch_tokenize):
            return self.batch_tokenize([s])[0]
        else:
            raise NotImplementedError()
コード例 #19
0
ファイル: api.py プロジェクト: Aman020/Big-Data-Analytics
    def tag(self, tokens):
        """
        Determine the most appropriate tag sequence for the given
        token sequence, and return a corresponding list of tagged
        tokens.  A tagged token is encoded as a tuple ``(token, tag)``.

        :rtype: list(tuple(str, str))
        """
        if overridden(self.tag_sents):
            return self.tag_sents([tokens])[0]
コード例 #20
0
ファイル: api.py プロジェクト: B-Rich/Fem-Coding-Challenge
 def prob_classify(self, featureset):
     """
     @return: a probability distribution over labels for the given
         featureset.
     @rtype: L{ProbDistI <nltk.probability.ProbDistI>}
     """
     if overridden(self.batch_prob_classify):
         return self.batch_prob_classify([featureset])[0]
     else:
         raise NotImplementedError()
コード例 #21
0
ファイル: api.py プロジェクト: 52nlp/Text-Summarization
    def tokenize(self, s):
        """
        Return a tokenized copy of *s*.

        :rtype: list of str
        """
        if overridden(self.tokenize_sents):
            return self.tokenize_sents([s])[0]
        else:
            raise NotImplementedError()
コード例 #22
0
ファイル: api.py プロジェクト: DrDub/nltk
 def prob_classify(self, featureset):
     """
     :return: a probability distribution over labels for the given
         featureset.
     :rtype: ProbDistI
     """
     if overridden(self.prob_classify_many):
         return self.prob_classify_many([featureset])[0]
     else:
         raise NotImplementedError()
コード例 #23
0
 def iter_parse(self, sent):
     """
     @return: An iterator that generates parse trees that represent
     possible structures for the given sentence.  When possible,
     this list is sorted from most likely to least likely.
     
     @param sent: The sentence to be parsed
     @type sent: L{list} of L{string}
     @rtype: C{iterator} of L{Tree}
     """
     if overridden(self.batch_iter_parse):
         return self.batch_iter_parse([sent])[0]
     elif overridden(self.nbest_parse) or overridden(self.batch_nbest_parse):
         return iter(self.nbest_parse(sent))
     elif overridden(self.parse) or overridden(self.batch_parse):
         tree = self.parse(sent)
         if tree: return iter([tree])
         else: return iter([])
     else:
         raise NotImplementedError()
コード例 #24
0
ファイル: api.py プロジェクト: BohanHsu/developer
    def iter_parse(self, sent):
        """
        :return: An iterator that generates parse trees that represent
        possible structures for the given sentence.  When possible,
        this list is sorted from most likely to least likely.

        :param sent: The sentence to be parsed
        :type sent: list(str)
        :rtype: iter(Tree)
        """
        if overridden(self.batch_iter_parse):
            return self.batch_iter_parse([sent])[0]
        elif overridden(self.nbest_parse) or overridden(self.batch_nbest_parse):
            return iter(self.nbest_parse(sent))
        elif overridden(self.parse) or overridden(self.batch_parse):
            tree = self.parse(sent)
            if tree: return iter([tree])
            else: return iter([])
        else:
            raise NotImplementedError()
コード例 #25
0
ファイル: api.py プロジェクト: IgorWang/IgorNLP
 def tag(self, tokens):
     '''
     Determine the most appropriate tag sequence for the given token sequence,
     and return a corresponding list of tagged tokens
     :param tokens: list of tokens ['我','爱','北京','天安门']
     :return: list(tuple(str,str)
     '''
     if overridden(self.tag_sents):
         return self.tag_sents([tokens])[0]
     else:
         raise NotImplementedError()
コード例 #26
0
ファイル: api.py プロジェクト: skythe/nltk
    def iter_parse(self, sent):
        """
        :return: An iterator that generates parse trees that represent
        possible structures for the given sentence.  When possible,
        this list is sorted from most likely to least likely.

        :param sent: The sentence to be parsed
        :type sent: list(str)
        :rtype: iter(Tree)
        """
        if overridden(self.iter_parse_sents):
            return self.iter_parse_sents([sent])[0]
        elif overridden(self.nbest_parse) or overridden(self.nbest_parse_sents):
            return iter(self.nbest_parse(sent))
        elif overridden(self.parse) or overridden(self.parse_sents):
            tree = self.parse(sent)
            if tree: return iter([tree])
            else: return iter([])
        else:
            raise NotImplementedError()
コード例 #27
0
ファイル: api.py プロジェクト: ciju/yql_hash
    def tag(self, tokens):
        """
        Determine the most appropriate tag sequence for the given
        token sequence, and return a corresponding list of tagged
        tokens.  A tagged token is encoded as a tuple C{(token, tag)}.

        @rtype: C{list} of C{(token, tag)}
        """
        if overridden(self.batch_tag):
            return self.batch_tag([tokens])[0]
        else:
            raise NotImplementedError()
コード例 #28
0
ファイル: api.py プロジェクト: willowjar/scratchNLP
    def tag(self, tokens):
        """
        Determine the most appropriate tag sequence for the given
        token sequence, and return a corresponding list of tagged
        tokens.  A tagged token is encoded as a tuple C{(token, tag)}.

        @rtype: C{list} of C{(token, tag)}
        """
        if overridden(self.batch_tag):
            return self.batch_tag([tokens])[0]
        else:
            raise NotImplementedError()
コード例 #29
0
 def nbest_parse(self, sent, n=None):
     """
     @return: A list of parse trees that represent possible
     structures for the given sentence.  When possible, this list is
     sorted from most likely to least likely.  If C{n} is
     specified, then the returned list will contain at most C{n}
     parse trees.
     
     @param sent: The sentence to be parsed
     @type sent: L{list} of L{string}
     @param n: The maximum number of trees to return.
     @type n: C{int}
     @rtype: C{list} of L{Tree}
     """
     if overridden(self.batch_nbest_parse):
         return self.batch_nbest_parse([sent],n)[0]
     elif overridden(self.parse) or overridden(self.batch_parse):
         tree = self.parse(sent)
         if tree: return [tree]
         else: return []
     else:
         return list(itertools.islice(self.iter_parse(sent), n))
コード例 #30
0
ファイル: api.py プロジェクト: BohanHsu/developer
    def nbest_parse(self, sent, n=None):
        """
        :return: A list of parse trees that represent possible
        structures for the given sentence.  When possible, this list is
        sorted from most likely to least likely.  If ``n`` is
        specified, then the returned list will contain at most ``n``
        parse trees.

        :param sent: The sentence to be parsed
        :type sent: list(str)
        :param n: The maximum number of trees to return.
        :type n: int
        :rtype: list(Tree)
        """
        if overridden(self.batch_nbest_parse):
            return self.batch_nbest_parse([sent],n)[0]
        elif overridden(self.parse) or overridden(self.batch_parse):
            tree = self.parse(sent)
            if tree: return [tree]
            else: return []
        else:
            return list(itertools.islice(self.iter_parse(sent), n))
コード例 #31
0
ファイル: api.py プロジェクト: jparise/haitwu-appengine
 def nbest_parse(self, sent, n=None):
     """
     @return: A list of parse trees that represent possible
     structures for the given sentence.  When possible, this list is
     sorted from most likely to least likely.  If C{n} is
     specified, then the returned list will contain at most C{n}
     parse trees.
     
     @param sent: The sentence to be parsed
     @type sent: L{list} of L{string}
     @param n: The maximum number of trees to return.
     @type n: C{int}
     @rtype: C{list} of L{Tree}
     """
     if overridden(self.batch_nbest_parse):
         return self.batch_nbest_parse([sent],n)[0]
     elif overridden(self.parse) or overridden(self.batch_parse):
         tree = self.parse(sent)
         if tree: return [tree]
         else: return []
     else:
         return list(itertools.islice(self.iter_parse(sent), n))
コード例 #32
0
    def nbest_parse(self, sent, n=None):
        """
        :return: A list of parse trees that represent possible
        structures for the given sentence.  When possible, this list is
        sorted from most likely to least likely.  If ``n`` is
        specified, then the returned list will contain at most ``n``
        parse trees.

        :param sent: The sentence to be parsed
        :type sent: list(str)
        :param n: The maximum number of trees to return.
        :type n: int
        :rtype: list(Tree)
        """
        if overridden(self.batch_nbest_parse):
            return self.batch_nbest_parse([sent], n)[0]
        elif overridden(self.parse) or overridden(self.batch_parse):
            tree = self.parse(sent)
            if tree: return [tree]
            else: return []
        else:
            return list(itertools.islice(self.iter_parse(sent), n))
コード例 #33
0
    def prob_parse(self, sent):
        """
        :return: A probability distribution over the possible parse
        trees for the given sentence.  If there are no possible parse
        trees for the given sentence, return a probability distribution
        that assigns a probability of 1.0 to None.

        :param sent: The sentence to be parsed
        :type sent: list(str)
        :rtype: ProbDistI(Tree)
        """
        if overridden(self.batch_prob_parse):
            return self.batch_prob_parse([sent])[0]
        else:
            raise NotImplementedError
コード例 #34
0
ファイル: api.py プロジェクト: BohanHsu/developer
    def prob_parse(self, sent):
        """
        :return: A probability distribution over the possible parse
        trees for the given sentence.  If there are no possible parse
        trees for the given sentence, return a probability distribution
        that assigns a probability of 1.0 to None.

        :param sent: The sentence to be parsed
        :type sent: list(str)
        :rtype: ProbDistI(Tree)
        """
        if overridden(self.batch_prob_parse):
            return self.batch_prob_parse([sent])[0]
        else:
            raise NotImplementedError
コード例 #35
0
 def prob_parse(self, sent):
     """
     @return: A probability distribution over the possible parse
     trees for the given sentence.  If there are no possible parse
     trees for the given sentence, return a probability distribution
     that assigns a probability of 1.0 to C{None}.
     
     @param sent: The sentence to be parsed
     @type sent: L{list} of L{string}
     @rtype: L{ProbDistI} of L{Tree}
     """
     if overridden(self.batch_prob_parse):
         return self.batch_prob_parse([sent])[0]
     else:
         raise NotImplementedError
コード例 #36
0
ファイル: api.py プロジェクト: jparise/haitwu-appengine
 def prob_parse(self, sent):
     """
     @return: A probability distribution over the possible parse
     trees for the given sentence.  If there are no possible parse
     trees for the given sentence, return a probability distribution
     that assigns a probability of 1.0 to C{None}.
     
     @param sent: The sentence to be parsed
     @type sent: L{list} of L{string}
     @rtype: L{ProbDistI} of L{Tree}
     """
     if overridden(self.batch_prob_parse):
         return self.batch_prob_parse([sent])[0]
     else:
         raise NotImplementedError
コード例 #37
0
ファイル: api.py プロジェクト: BohanHsu/developer
    def parse(self, sent):
        """
        :return: A parse tree that represents the structure of the
        given sentence, or None if no parse tree is found.  If
        multiple parses are found, then return the best parse.

        :param sent: The sentence to be parsed
        :type sent: list(str)
        :rtype: Tree
        """
        if overridden(self.batch_parse):
            return self.batch_parse([sent])[0]
        else:
            trees = self.nbest_parse(sent, 1)
            if trees: return trees[0]
            else: return None
コード例 #38
0
    def parse(self, sent):
        """
        :return: A parse tree that represents the structure of the
        given sentence, or None if no parse tree is found.  If
        multiple parses are found, then return the best parse.

        :param sent: The sentence to be parsed
        :type sent: list(str)
        :rtype: Tree
        """
        if overridden(self.batch_parse):
            return self.batch_parse([sent])[0]
        else:
            trees = self.nbest_parse(sent, 1)
            if trees: return trees[0]
            else: return None
コード例 #39
0
ファイル: api.py プロジェクト: jparise/haitwu-appengine
 def parse(self, sent):
     """
     @return: A parse tree that represents the structure of the
     given sentence, or C{None} if no parse tree is found.  If
     multiple parses are found, then return the best parse.
     
     @param sent: The sentence to be parsed
     @type sent: L{list} of L{string}
     @rtype: L{Tree}
     """
     if overridden(self.batch_parse):
         return self.batch_parse([sent])[0]
     else:
         trees = self.nbest_parse(sent, 1)
         if trees: return trees[0]
         else: return None
コード例 #40
0
 def parse(self, sent):
     """
     @return: A parse tree that represents the structure of the
     given sentence, or C{None} if no parse tree is found.  If
     multiple parses are found, then return the best parse.
     
     @param sent: The sentence to be parsed
     @type sent: L{list} of L{string}
     @rtype: L{Tree}
     """
     if overridden(self.batch_parse):
         return self.batch_parse([sent])[0]
     else:
         trees = self.nbest_parse(sent, 1)
         if trees: return trees[0]
         else: return None
コード例 #41
0
ファイル: api.py プロジェクト: antonfait/SerchEngine
 def align(self, source_text_sections, target_text_sections):
     """
     @return: the alignment of the two texts.
     @rtype: a C{list} of C{tuple} pairs where 
     1. the first element is a section of source text 
     2. the second element is the aligned section(s) of target text
        or 
     1. the first element is an identifier of a section of source text 
     2. the second element is identifier(s) of aligned section(s) of target text
     The second option is necessary for cases where crossing alignments are permitted, as
     in word alignment implementations.
     
     Both elements of the returned tuples are lists - either empty lists, 
     (in the case of ommitted/deleted text) or single or multiple element lists
     """
     if overridden(self.batch_align):
         return self.batch_align([source_text_sections], [target_text_sections])
     else:
         raise NotImplementedError()
コード例 #42
0
 def tag(self, tokens):
     if overridden(self.tag_sents):
         return self.tag_sents([tokens])[0]