Beispiel #1
0
def words(text):
    '''
    It is an interface to call the public method of the TextPy Class.
    It returns list of all the words in a text.
    '''
    T = textpy.TextPy()
    return T.words(text)
Beispiel #2
0
def misspelled_words(text):
    '''
    Retuns all the dates from the text in the form of list.
    '''
    T = textpy.TextPy()
    return T.misspelled_words(text)
Beispiel #3
0
def telephone(text):
    '''
    Retuns all the dates from the text in the form of list.
    '''
    T = textpy.TextPy()
    return T.telephone(text)
Beispiel #4
0
def urls(text):
    '''
    Returns all the urls from the text in the form of list.
    '''
    T = textpy.TextPy()
    return T.urls(text)
Beispiel #5
0
def sentences(text):
    '''
    Returns all the sentences from the text in the form of list.
    '''
    T = textpy.TextPy()
    return T.sentences(text)
Beispiel #6
0
def numbers(text):
    '''
    Retuns all the dates from the text in the form of list.
    '''
    T = textpy.TextPy()
    return T.numbers(text)
Beispiel #7
0
 def test_telephone(self):
     T = tp.TextPy()
     result = T.telephone("Hello World My number is 319-378-8183")
     self.assertEqual(result[0], '319-378-8183')
Beispiel #8
0
 def test_words(self):
     T = tp.TextPy()
     result = T.words('Hello World, It was the best of the times3')
     self.assertEqual(result[0], "Hello")
     self.assertEqual(len(result), 9)
     self.assertEqual(1, 1)
Beispiel #9
0
 def test_urls(self):
     T = tp.TextPy()
     result = T.urls("The CNN url is https://www.cnn.com/")
     self.assertEqual(result[0], 'https://www.cnn.com/')
Beispiel #10
0
 def test_misspelled_words(self):
     T = tp.TextPy()
     result = T.misspelled_words("Hellow World. Porgraming in Python.")
     self.assertEqual(result[0], 'Hellow')
Beispiel #11
0
 def test_numbers(self):
     T = tp.TextPy()
     result = T.numbers("Hello World. 2015-01-30")
     self.assertEqual(result[0], '2015')
Beispiel #12
0
 def test_dates(self):
     T = tp.TextPy()
     result = T.dates("My name is John Doe. Today's date is 05/20/2019")
     self.assertEqual(result[0], '05/20/2019')
Beispiel #13
0
 def test_sentences(self):
     T = tp.TextPy()
     result = T.sentences("Hello World.My name is Pablo.")
     self.assertEqual(result[0], "Hello World.")
     self.assertEqual(result[1], "My name is Pablo.")
     self.assertRaises(TypeError, T.words(12345))