Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given an input file, determine how many lines in the file contain a clause (delinated by two commas followed by a space, i.e. ', ').

Given an input file, determine how many lines in the file contain a clause (delinated by two commas followed by a space, i.e. ', '). Note the full clause must be contained on a single line to be considered a match. If the clause is split across two lines, do not count it.

# countClauses(filename) takes an input filename, and returns the number of lines # containing a clause separated by commas.

def countClauses(filename): ## your code here

# Example Test Q1f countClauses('raven-poem_demo.txt') # output: 8

raven-poem_demo.txt = '

Once upon a midnight dreary, while I pondered weak and weary, Over many a quaint and curious volume of forgotten lore, While I nodded, nearly napping, suddenly there came a tapping, As of some one gently rapping, rapping at my chamber door. `'Tis some visitor,' I muttered, `tapping at my chamber door - Only this, and nothing more.'

Ah, distinctly I remember it was in the bleak December, And each separate dying ember wrought its ghost upon the floor. Eagerly I wished the morrow; - vainly I had sought to borrow From my books surcease of sorrow - sorrow for the lost Lenore - For the rare and radiant maiden whom the angels name Lenore - Nameless here for evermore.

And the silken sad uncertain rustling of each purple curtain Thrilled me - filled me with fantastic terrors never felt before; So that now, to still the beating of my heart, I stood repeating `'Tis some visitor entreating entrance at my chamber door - Some late visitor entreating entrance at my chamber door; - This it is, and nothing more,'

Presently my soul grew stronger; hesitating then no longer, `Sir,' said I, `or Madam, truly your forgiveness I implore; But the fact is I was napping, and so gently you came rapping, And so faintly you came tapping, tapping at my chamber door, That I scarce was sure I heard you' - here I opened wide the door; - Darkness there, and nothing more.

Deep into that darkness peering, long I stood there wondering, fearing, Doubting, dreaming dreams no mortal ever dared to dream before; But the silence was unbroken, and the darkness gave no token, And the only word there spoken was the whispered word, `Lenore!' This I whispered, and an echo murmured back the word, `Lenore!' Merely this and nothing more.

But the raven, sitting lonely on the placid bust, spoke only, That one word, as if his soul in that one word he did outpour. Nothing further then he uttered - not a feather then he fluttered - Till I scarcely more than muttered `Other friends have flown before - On the morrow he will leave me, as my hopes have flown before.' Then the bird said, `Nevermore.'

Startled at the stillness broken by reply so aptly spoken, `Doubtless,' said I, `what it utters is its only stock and store, Caught from some unhappy master whom unmerciful disaster Followed fast and followed faster till his songs one burden bore - Till the dirges of his hope that melancholy burden bore Of "Never-nevermore."'

But the raven still beguiling all my sad soul into smiling, Straight I wheeled a cushioned seat in front of bird and bust and door; Then, upon the velvet sinking, I betook myself to linking Fancy unto fancy, thinking what this ominous bird of yore - What this grim, ungainly, ghastly, gaunt, and ominous bird of yore Meant in croaking `Nevermore.'

This I sat engaged in guessing, but no syllable expressing To the fowl whose fiery eyes now burned into my bosom's core; This and more I sat divining, with my head at ease reclining On the cushion's velvet lining that the lamp-light gloated o'er, But whose velvet violet lining with the lamp-light gloating o'er, She shall press, ah, nevermore!

'

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genetic Databases

Authors: Martin J. Bishop

1st Edition

ISBN: 0121016250, 978-0121016258

More Books

Students also viewed these Databases questions

Question

Explain the difference between opportunities and ideas.

Answered: 1 week ago

Question

7. Where Do We Begin?

Answered: 1 week ago

Question

a. What is the purpose of the team?

Answered: 1 week ago

Question

b. What are its goals and objectives?

Answered: 1 week ago