File size: 835 Bytes
2f044c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from typing import List, Union


class BlankSentenceSplitter:
    """
    A `BlankSentenceSplitter` splits strings into sentences.
    """

    def __call__(self, *args, **kwargs):
        """
        Calls :meth:`split_sentences`.
        """
        return self.split_sentences(*args, **kwargs)

    def split_sentences(
        self, text: str, max_len: int = 0, *args, **kwargs
    ) -> List[str]:
        """
        Splits a `text` :class:`str` paragraph into a list of :class:`str`, where each is a sentence.
        """
        return [text]

    def split_sentences_batch(
        self, texts: List[str], *args, **kwargs
    ) -> List[List[str]]:
        """
        Default implementation is to just iterate over the texts and call `split_sentences`.
        """
        return [self.split_sentences(text) for text in texts]