示例#1
0
class Punctuation(Enum):
    COMMA = ','
    PERIOD = '.'
    EXCLAMATION = '!'
    QUESTION = '?'

    BOLD_COMMA = bold(',')
    BOLD_PERIOD = bold('.')
    BOLD_EXCLAMATION = bold('!')
    BOLD_QUESTION = bold('?')

    def bold(self):
        try:
            return getattr(Punctuation, 'BOLD_{}'.format(self.name))
        except AttributeError:
            return self

    @staticmethod
    def has_tags(*tags):
        return False

    def capitalize(self):
        return self

    def de_capitalize(self):
        return self
示例#2
0
 def bold(self):
     return BasicWord(bold(self.value), self.tags)
示例#3
0
 def test_bold_full_tag(self):
     self.assertEqual(bold('<bold>x</bold>'), '<bold>x</bold>')
示例#4
0
 def test_bold_half_tag(self):
     self.assertEqual(bold('<bold>x'), '<bold><bold>x</bold>')
     self.assertEqual(bold('x</bold>'), '<bold>x</bold></bold>')
示例#5
0
 def test_bold_regular(self):
     self.assertEqual(bold('x'), '<bold>x</bold>')
示例#6
0
 def bold(self) -> 'Noun':
     return Noun(bold(self.value), self.irregular_plural, self.base_noun,
                 self.tags)
示例#7
0
 def bold(self) -> 'Verb':
     return Verb(bold(self.value), self.irregular_past, self.infinitive, self.tags)
示例#8
0
 def bold(self) -> AbstractWord:
     return BasicWord(bold(self.value))