예제 #1
0
    def __call__(self, sentence: List[str]) -> List[str]:
        """Adapted code from BPE.segment """

        output = []
        for word in sentence:

            # Hack. TODO: inspect why there are empty sentences
            if len(word) == 0:
                output.append(word)
                continue

            new_word = encode(word, self.bpe.bpe_codes)

            for item in new_word[:-1]:
                output.append(item + self.bpe.separator)
            output.append(new_word[-1])

        return output
예제 #2
0
파일: bpe.py 프로젝트: ufal/neuralmonkey
    def __call__(self, sentence: List[str]) -> List[str]:
        """Adapted code from BPE.segment."""

        output = []
        for word in sentence:

            # Hack. TODO: inspect why there are empty sentences
            if not word:
                output.append(word)
                continue

            new_word = encode(word, self.bpe.bpe_codes)

            for item in new_word[:-1]:
                output.append(item + self.bpe.separator)
            output.append(new_word[-1])

        return output