Exemple #1
0
    def make_vocab(notation='chars',
                   punct=True,
                   spaces=False,
                   stresses=False,
                   add_blank_at="last_but_one"):
        """Constructs vocabulary from given parameters.

        Args:
            notation (str): Either 'chars' or 'phonemes' as general notation.
            punct (bool): True if reserve grapheme for basic punctuation.
            spaces (bool): True if prepend spaces to every punctuation symbol.
            stresses (bool): True if use phonemes codes with stresses (0-2).
            add_blank_at: add blank to labels in the specified order ("last" or "last_but_one"),
             if None then no blank in labels.

        Returns:
            (vocabs.Base) Vocabulary
        """
        if notation == 'chars':
            vocab = vocabs.Chars(punct=punct,
                                 spaces=spaces,
                                 add_blank_at=add_blank_at)
        elif notation == 'phonemes':
            vocab = vocabs.Phonemes(
                punct=punct,
                stresses=stresses,
                spaces=spaces,
                add_blank_at=add_blank_at,
            )
        else:
            raise ValueError("Unsupported vocab type.")
        return vocab
Exemple #2
0
    def make_vocab(notation='chars', punct=True, spaces=False, stresses=False):
        """Constructs vocabulary from given parameters.

        Args:
            notation (str): Either 'chars' or 'phonemes' as general notation.
            punct (bool): True if reserve grapheme for basic punctuation.
            spaces (bool): True if prepend spaces to every punctuation symbol.
            stresses (bool): True if use phonemes codes with stresses (0-2).

        Returns:
            (vocabs.Base) Vocabulary
        """
        if notation == 'chars':
            vocab = vocabs.Chars(punct=punct, spaces=spaces)
        elif notation == 'phonemes':
            vocab = vocabs.Phonemes(punct=punct, stresses=stresses, spaces=spaces)
        else:
            raise ValueError("Unsupported vocab type.")
        return vocab