Pangram Checker
检查文本是否包含英文字母表的所有26个字母。
示例:
关于此工具
全字母句(pangram)是指包含英语字母表全部26个字母的文本。全字母句检查器能够立即判断您的文本是否构成真正的全字母句,这对于排版设计师、字体设计师、键盘布局测试者以及希望验证字母覆盖范围完整性的作家都非常有用。无论您是在创建测试句子、验证字符集,还是仅出于语言兴趣,此工具都能提供即时反馈。
要使用全字母句检查器,只需将文本粘贴或输入到输入框中,工具就会立即显示存在哪些字母以及缺少哪些字母。界面清晰地显示任何字母表缺口,因此您可以快速编辑文本以填补空白。这种方法远比手动数遍26个字母要高效得多。
常见问题
代码实现
def is_pangram(text: str) -> bool:
"""Check if text contains all 26 letters of the English alphabet."""
letters = set(text.lower())
return set('abcdefghijklmnopqrstuvwxyz').issubset(letters)
def missing_letters(text: str) -> list[str]:
"""Return letters missing from the text."""
present = set(text.lower())
return [c for c in 'abcdefghijklmnopqrstuvwxyz' if c not in present]
def pangram_stats(text: str) -> dict:
present = set(c for c in text.lower() if c.isalpha())
missing = [c for c in 'abcdefghijklmnopqrstuvwxyz' if c not in present]
return {
'is_pangram': len(missing) == 0,
'present_count': len(present),
'missing': missing,
'unique_letters': sorted(present),
}
examples = [
"The quick brown fox jumps over the lazy dog",
"Hello World",
"Pack my box with five dozen liquor jugs",
]
for text in examples:
stats = pangram_stats(text)
print(f"'{text[:30]}...' -> pangram={stats['is_pangram']}, missing={stats['missing']}")Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.