Skip to content

A simple code that generates Pangrams (what are is written in the readme file :) )

License

Notifications You must be signed in to change notification settings

FrancescoPaoloL/Pangrams

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pangrams

A Pangram is essentially a sentence that uses all the letters of the alphabet. According to Wikipedia the best-known English pangram is "The quick brown fox jumps over the lazy dog". This script makes a pangram every time it be executed. The idea is simple:

  • a pangram contains words which begins with all the letters of the alphabet;
  • so we make a list with the all alphabet letters
  • we shuffle them and
  • we constrict a sentenceusing every letter in the alphabet list.

Ex. Given:
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

we make this:
['b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a']

and, finally, we construct a sentence like
'brave cats dart effortlessly for good-hearted individuals juggling keenly like mindful nannies openly promoting quick reactions swiftly to unitedly visualize x-rayed zebras androgynously.'

To do that we've used a Spacy NLP library that offers pre-trained language models for various languages; specifically,we've used 'en_core_web_sm' language model which provides various functionalities for processing and analyzing English text, including features like tokenization (that is splitting text into individual words or tokens), part-of-speech tagging, named entity recognition, syntactic parsing, and more. So, we iterate over each letter, and create meaningful sentences while respecting the constraints mentioned above.

Python

Languages and Tools

python

Requirements

spacy==3.3.0

Test coverage

Name Stmts Miss Branch BrPart Cover
pangram.py 9 1 2 1 82%
pangram_generator_test.py 20 1 4 1 92%
random_pangram.py 7 0 2 0 100%
sentence_constructor.py 11 0 2 0 100%
TOTAL 47 2 10 2 95.74%

License

This project is licensed under the MIT License - see the LICENSE.md file for details


Connect with me

francescopaololezza francescopaololezza

About

A simple code that generates Pangrams (what are is written in the readme file :) )

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages