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
Beispiel #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
 def test_uc_initials(self):
     self.assertEqual(titlecase('X.Y.Z. INC.'), 'X.Y.Z. Inc.')
 def test_slash(self):
     self.assertEqual(titlecase('foo/bar/baz'), 'Foo/Bar/Baz')
 def test_mac_mc(self):
     self.assertEqual(titlecase('MACDONALD'), 'MacDonald')
 def test_small_words(self):
     self.assertEqual(titlecase('FOR WHOM THE BELL TOLLS'), 'For Whom the Bell Tolls')
 def test_inline_period(self):
     self.assertEqual(titlecase('example.com'), 'example.com')
 def test_apos_second(self):
     self.assertEqual(titlecase("duck à l'orange"), "Duck à L'Orange")
Beispiel #9
0
 def test_uc_initials(self):
     self.assertEqual(titlecase('X.Y.Z. INC.'), 'X.Y.Z. Inc.')
Beispiel #10
0
 def test_slash(self):
     self.assertEqual(titlecase('foo/bar/baz'), 'Foo/Bar/Baz')
Beispiel #11
0
 def test_mac_mc(self):
     self.assertEqual(titlecase('MACDONALD'), 'MacDonald')
Beispiel #12
0
 def test_small_words(self):
     self.assertEqual(titlecase('FOR WHOM THE BELL TOLLS'),
                      'For Whom the Bell Tolls')
Beispiel #13
0
 def test_inline_period(self):
     self.assertEqual(titlecase('example.com'), 'example.com')
Beispiel #14
0
 def test_apos_second(self):
     self.assertEqual(titlecase("duck à l'orange"), "Duck à L'Orange")