コード例 #1
0
def test_bad_url_regex():
    for item in BAD_URLS:
        assert URL_REGEX.search(item) is None
コード例 #2
0
def test_partial_url_regex():
    for item in PARTIAL_URLS:
        assert item != URL_REGEX.search(item)
コード例 #3
0
ファイル: reprocessing.py プロジェクト: dpton/tf-rnn
def replace_urls(text, replace_with='<url>'):
    """Replace all URLs in ``text`` str with ``replace_with`` str."""
    return URL_REGEX.sub(replace_with, SHORT_URL_REGEX.sub(replace_with, text))
コード例 #4
0
def test_good_url_regex():
    for item in GOOD_URLS:
        assert item == URL_REGEX.search(item).group()
コード例 #5
0
 def test_partial_url_regex(self):
     for item in PARTIAL_URLS:
         self.assertNotEqual(item, URL_REGEX.search(item))
コード例 #6
0
ファイル: preprocess.py プロジェクト: chartbeat-labs/textacy
def replace_urls(text, replace_with='*URL*'):
    """Replace all URLs in ``text`` str with ``replace_with`` str."""
    return URL_REGEX.sub(replace_with, SHORT_URL_REGEX.sub(replace_with, text))
コード例 #7
0
 def test_bad_url_regex(self):
     for item in BAD_URLS:
         self.assertIsNone(URL_REGEX.search(item))
コード例 #8
0
 def test_good_url_regex(self):
     for item in GOOD_URLS:
         self.assertEqual(item, URL_REGEX.search(item).group())
コード例 #9
0
 def test_partial_url_regex(self):
     for item in PARTIAL_URLS:
         self.assertNotEqual(item, URL_REGEX.search(item))
コード例 #10
0
 def test_bad_url_regex(self):
     for item in BAD_URLS:
         self.assertIsNone(URL_REGEX.search(item))
コード例 #11
0
 def test_good_url_regex(self):
     for item in GOOD_URLS:
         self.assertEqual(item, URL_REGEX.search(item).group())