コード例 #1
0
def _clean_string(s):
    if re.search(r'[A-Z]', s) and not re.search(r'[a-z]', s):
        # WE'RE IN UPPERCASE
        from boundaries.titlecase import titlecase
        s = titlecase(s)
    s = re.sub(r'(?u)\s', ' ', s)
    s = re.sub(r'( ?-- ?| - )', '—', s)
    return s
コード例 #2
0
def _clean_string(s):
    if re.search(r'[A-Z]', s) and not re.search(r'[a-z]', s):
        # WE'RE IN UPPERCASE
        from boundaries.titlecase import titlecase
        s = titlecase(s)
    s = re.sub(r'(?u)\s', ' ', s)
    s = re.sub(r'( ?-- ?| - )', '—', s)
    return s
コード例 #3
0
 def test_uc_initials(self):
     self.assertEqual(titlecase('X.Y.Z. INC.'), 'X.Y.Z. Inc.')
コード例 #4
0
 def test_slash(self):
     self.assertEqual(titlecase('foo/bar/baz'), 'Foo/Bar/Baz')
コード例 #5
0
 def test_mac_mc(self):
     self.assertEqual(titlecase('MACDONALD'), 'MacDonald')
コード例 #6
0
 def test_small_words(self):
     self.assertEqual(titlecase('FOR WHOM THE BELL TOLLS'), 'For Whom the Bell Tolls')
コード例 #7
0
 def test_inline_period(self):
     self.assertEqual(titlecase('example.com'), 'example.com')
コード例 #8
0
 def test_apos_second(self):
     self.assertEqual(titlecase("duck à l'orange"), "Duck à L'Orange")
コード例 #9
0
 def test_uc_initials(self):
     self.assertEqual(titlecase('X.Y.Z. INC.'), 'X.Y.Z. Inc.')
コード例 #10
0
 def test_slash(self):
     self.assertEqual(titlecase('foo/bar/baz'), 'Foo/Bar/Baz')
コード例 #11
0
 def test_mac_mc(self):
     self.assertEqual(titlecase('MACDONALD'), 'MacDonald')
コード例 #12
0
 def test_small_words(self):
     self.assertEqual(titlecase('FOR WHOM THE BELL TOLLS'),
                      'For Whom the Bell Tolls')
コード例 #13
0
 def test_inline_period(self):
     self.assertEqual(titlecase('example.com'), 'example.com')
コード例 #14
0
 def test_apos_second(self):
     self.assertEqual(titlecase("duck à l'orange"), "Duck à L'Orange")