예제 #1
0
파일: chat.py 프로젝트: codyatx/parse_chat
from parse_chat import parse_chat

print('This program uses the parse_chat function to parse your input.')
print('You may quit by typing "quit".\n')

message = ''

while message != 'quit':
    message = input('Chat: ')

    if message != 'quit':
        print(parse_chat(message))
예제 #2
0
 def test_bad_link(self):
     result = parse_chat("httpfoo")
     self.assertEqual(
         result,
         '{"words": 0, "links": [{"url": "httpfoo", "title": null}]}')
예제 #3
0
 def test_word_count_no_features_no_words(self):
     result = parse_chat("")
     self.assertEqual(result, '{"words": 0}')
예제 #4
0
 def test_emoticon_too_short(self):
     result = parse_chat("()")
     self.assertEqual(result, '{"words": 1}')
예제 #5
0
 def test_link(self):
     result = parse_chat("http://www.google.com")
     self.assertEqual(
         result,
         '{"words": 0, "links": [{"url": "http://www.google.com", "title": "Google"}]}'
     )
예제 #6
0
 def test_word_count_no_features(self):
     result = parse_chat("Hello world")
     self.assertEqual(result, '{"words": 2}')
예제 #7
0
 def test_emoticon_min_length(self):
     result = parse_chat("(1)")
     self.assertEqual(result, '{"words": 0, "emoticons": ["1"]}')
예제 #8
0
 def test_emoticon_max_length(self):
     result = parse_chat("(123456789012345)")
     self.assertEqual(result,
                      '{"words": 0, "emoticons": ["123456789012345"]}')
예제 #9
0
 def test_emoticon_too_long(self):
     result = parse_chat("(1234567890123456)")
     self.assertEqual(result, '{"words": 1}')
예제 #10
0
 def test_emoticon_with_space(self):
     result = parse_chat("(foo bar)")
     self.assertEqual(result, '{"words": 2}')
예제 #11
0
 def test_emoticon_with_link(self):
     result = parse_chat("(http)")
     self.assertEqual(result, '{"words": 0, "emoticons": ["http"]}')
예제 #12
0
 def test_emoticon(self):
     result = parse_chat("(foo)")
     self.assertEqual(result, '{"words": 0, "emoticons": ["foo"]}')
예제 #13
0
 def test_mention_with_link(self):
     result = parse_chat("@http")
     self.assertEqual(result, '{"words": 0, "mentions": ["http"]}')
예제 #14
0
 def test_mention_in_parentheses(self):
     result = parse_chat("(@foo)")
     self.assertEqual(result, '{"words": 2, "mentions": ["foo"]}')
예제 #15
0
 def test_mention_with_word(self):
     result = parse_chat("foo@bar")
     self.assertEqual(result, '{"words": 1, "mentions": ["bar"]}')
예제 #16
0
 def test_mention(self):
     result = parse_chat("@mention1")
     self.assertEqual(result, '{"words": 0, "mentions": ["mention1"]}')