本文整理汇总了Python中wordcount.word_count函数的典型用法代码示例。如果您正苦于以下问题:Python word_count函数的具体用法?Python word_count怎么用?Python word_count使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了word_count函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_non_alphanumeric
def test_non_alphanumeric(self):
self.assertEqual(
{'hey': 1,
'my': 1,
'spacebar': 1,
'is': 1,
'broken': 1}, word_count('hey,my_spacebar_is_broken.'))
开发者ID:StevenACoffman,项目名称:exercism,代码行数:7,代码来源:word_count_test.py
示例2: test_newlines
def test_newlines(self):
self.assertEqual(
{'rah': 2, 'ah': 3, 'roma': 2, 'ma': 1, 'ga': 2, 'oh': 1, 'la': 2,
'want': 1, 'your': 1, 'bad': 1, 'romance': 1},
word_count('rah rah ah ah ah\nroma roma ma\n'
'ga ga oh la la\nwant your bad romance')
)
开发者ID:NSteinhoff,项目名称:exercism,代码行数:7,代码来源:word_count_test.py
示例3: test_count_multiple_occurences
def test_count_multiple_occurences(self):
self.assertEqual(
{'one': 1,
'fish': 4,
'two': 1,
'red': 1,
'blue': 1}, word_count('one fish two fish red fish blue fish'))
开发者ID:StevenACoffman,项目名称:exercism,代码行数:7,代码来源:word_count_test.py
示例4: test_tabs
def test_tabs(self):
self.assertEqual(
{'rah': 2, 'ah': 3, 'roma': 2, 'ma': 1, 'ga': 2, 'oh': 1, 'la': 2,
'want': 1, 'your': 1, 'bad': 1, 'romance': 1},
word_count('rah rah ah ah ah\troma roma ma\tga ga oh la la\t'
'want your bad romance')
)
开发者ID:NSteinhoff,项目名称:exercism,代码行数:7,代码来源:word_count_test.py
示例5: test_preserves_punctuation
def test_preserves_punctuation(self):
self.assertEqual(
{'car': 1,
'carpet': 1,
'as': 1,
'java': 1,
'javascript': 1},
word_count('car : carpet as java : javascript!!&@$%^&'))
开发者ID:StevenACoffman,项目名称:exercism,代码行数:8,代码来源:word_count_test.py
示例6: test_newlines
def test_newlines(self):
self.assertEqual(
{
"rah": 2,
"ah": 3,
"roma": 2,
"ma": 1,
"ga": 2,
"oh": 1,
"la": 2,
"want": 1,
"your": 1,
"bad": 1,
"romance": 1,
},
word_count("rah rah ah ah ah\nroma roma ma\n" "ga ga oh la la\nwant your bad romance"),
)
开发者ID:LaryMiranda,项目名称:Python,代码行数:17,代码来源:WordCountTests.py
示例7: test_mixed_case
def test_mixed_case(self):
self.assertEqual(
{'go': 1, 'Go': 1, 'GO': 1},
word_count('go Go GO')
)
开发者ID:ahmadhasankhan,项目名称:exercism,代码行数:5,代码来源:word_count_test.py
示例8: test_counts_one_word
def test_counts_one_word(self):
self.assertEqual(
{u'word': 1},
word_count(u'word')
)
开发者ID:colinmorris,项目名称:testify,代码行数:5,代码来源:test_wordcount.py
示例9: test_splits_on_newlines
def test_splits_on_newlines(self):
self.assertEqual(
{u'ma': 1, u'want': 1, u'oh': 1, u'ah': 3, u'la': 2, u'rah': 2, u'romance': 1, u'bad': 1, u'ga': 2, u'roma': 2, u'your': 1},
word_count(u'rah rah ah ah ah\nroma roma ma\nga ga oh la la\nwant your bad romance')
)
开发者ID:colinmorris,项目名称:testify,代码行数:5,代码来源:test_wordcount.py
示例10: test_preserves_mixed_case
def test_preserves_mixed_case(self):
self.assertEqual(
{u'go': 1, u'Go': 1, u'GO': 1},
word_count(u'Go go GO')
)
开发者ID:colinmorris,项目名称:testify,代码行数:5,代码来源:test_wordcount.py
示例11: test_includes_numbers
def test_includes_numbers(self):
self.assertEqual(
{u'1': 1, u'2': 1, u'testing': 2},
word_count(u'testing 1 2 testing')
)
开发者ID:colinmorris,项目名称:testify,代码行数:5,代码来源:test_wordcount.py
示例12: test_preserves_punctuation
def test_preserves_punctuation(self):
self.assertEqual(
{"car": 1, "carpet": 1, "as": 1, "java": 1, "javascript": 1},
word_count("car : carpet as java : javascript!!&@$%^&"),
)
开发者ID:LaryMiranda,项目名称:Python,代码行数:5,代码来源:WordCountTests.py
示例13: test_include_numbers
def test_include_numbers(self):
self.assertEqual(
{'testing': 2, '1': 1, '2': 1},
word_count('testing 1 2 testing')
)
开发者ID:NSteinhoff,项目名称:exercism,代码行数:5,代码来源:word_count_test.py
示例14: test_mixed_case
def test_mixed_case(self):
self.assertEqual(
[3],
list(word_count('go Go GO').values())
)
开发者ID:TFarla,项目名称:xpython,代码行数:5,代码来源:word_count_test.py
示例15: test_count_one_word
def test_count_one_word(self):
self.assertEqual({"word": 1}, word_count("word"))
开发者ID:LaryMiranda,项目名称:Python,代码行数:2,代码来源:WordCountTests.py
示例16: test_non_alphanumeric
def test_non_alphanumeric(self):
self.assertEqual(
{"hey": 1, "my": 1, "spacebar": 1, "is": 1, "broken": 1}, word_count("hey,my_spacebar_is_broken.")
)
开发者ID:LaryMiranda,项目名称:Python,代码行数:4,代码来源:WordCountTests.py
示例17: test_multiple_spaces
def test_multiple_spaces(self):
self.assertEqual({"wait": 1, "for": 1, "it": 1}, word_count("wait for it"))
开发者ID:LaryMiranda,项目名称:Python,代码行数:2,代码来源:WordCountTests.py
示例18: test_include_numbers
def test_include_numbers(self):
self.assertEqual({"testing": 2, "1": 1, "2": 1}, word_count("testing 1 2 testing"))
开发者ID:LaryMiranda,项目名称:Python,代码行数:2,代码来源:WordCountTests.py
示例19: test_count_one_word
def test_count_one_word(self):
self.assertEqual(
{'word': 1},
word_count('word')
)
开发者ID:NSteinhoff,项目名称:exercism,代码行数:5,代码来源:word_count_test.py
示例20: test_multiple_spaces
def test_multiple_spaces(self):
self.assertEqual(
{'wait': 1, 'for': 1, 'it': 1},
word_count('wait for it')
)
开发者ID:NSteinhoff,项目名称:exercism,代码行数:5,代码来源:word_count_test.py
注:本文中的wordcount.word_count函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论