Question

Help with Data Science python notebook, Question 1 Create a function called vowel_parse() that takes a...

Help with Data Science python notebook,

  • Question 1
    • Create a function called vowel_parse() that takes a single string as input. This string is the name of the input directory. It returns a dictionary.
    • This dictionary has keys that are the names of the individual input files.
    • The dictionary values are the number of words in that file that have adjacent vowels ('aa', 'ae', 'oo', 'ia', etc.). Use a regular expression to find these, do not hard code every possible combination of two vowels.

text to analize

The Buffalo Public Library in 1983.
By C. A. Cutter, Librarian of the Boston Athenaeum.

In the year 1983 I had come to Buffalo from Niagara, where I had been admiring the magnificent canal works by which the enormous power of the Falls was collected to be transmitted by wire, not merely to the great manufacturing city that had grown up upon each bank of the river, but also to Buffalo, here every machine, from a hundred-ton trip-hammer to an egg-beater, was driven by the water that had formerly only furnished a livelihood to hack-drivers and toll-takers. The Falls were as beautiful as ever, though their volume was slightly diminished. Along the bank ran the park; for all the factories, which were generally owned and managed in Buffalo, were kept at a distance from the water and hidden by trees. These great industrial towns, which furnished Buffalo its wealth, both directly and by nourishing its commerce, contained several well-used collections of books of moderate size, but no great library such as I was told I should see at Buffalo.

That city was not then one of the largest of the United States, having about two millions of inhabitants; but it yielded to none in the attention it gave to popular education, part of the remarkable commercial energy which distinguished the first century of its existence, having naturally, with the acquisition of wealth, been turned into the channels of literature, art, and science. The library, therefore, as being the very culmination of the educational system, had a high reputation both for its excellent management, for the extent to which it was used, and for the pride and affection with which it was regarded by the citizens. The library building was near the centre of the city. A whole block some 200 feet square had been secured for it. Part was already built upon, and part, reserved for the inevitable extension of a growing collection, was occupied by stores and houses, whose rents were allowed to accumulate for a building fund. Wide avenues gave it air and light, and protected it against fire on three sides; on the fourth there was space enough between the library and the shops. The situation, as I have said, was central, and yet it was a little retired from the noisiest streets. All the neighboring paving was of a kind to minimize the clatter of passing vehicles, and particular attention was paid to keeping the ways scrupulously clean, to prevent, as far as might be, the evil of dust.

The building, when complete, was to consist of two parts, the first a central store, 150 feet square, a compact mass of shelves and passageways, lighted from the ends, but neither from sides nor top; the second an outer rim of rooms 20 feet wide, lighted from the four streets. In front and rear the rim was to contain special libraries, reading-rooms, and work-rooms; on the sides, the art-galleries. The central portion was a gridiron of stacks, running from front to rear, each stack 2 feet wide, and separated from its neighbor by a passage of 3 feet. Horizontally, the stack was divided by floors into 8 stories, each 8 feet high, giving a little over 7 feet of shelf-room, the highest shelf being so low that no book was beyond the reach of the hand. Each reading-room, 16 feet high, corresponded to two stories of the stack, from which it was separated in winter by glass doors. When I first entered a reading-room, which was in summer, when the doors were off, I was much amused by the appearance of the two tiers of passages running off from one side like so many bird holes in a sandy river-bank, sixty of them leading off into darkness. They were, in fact, sixty short tunnels, with floors for top and bottom and books for sides, 8 feet high, 3 feet wide, and now 75 feet long. When the library should occupy the whole lot, they were to be 150 feet long. “Their length might equally well,” said my guide, “be 300 feet, for they do not depend upon the sun for light. In the night, or in a dark day the runner, on going in, touches a knob, which lights an electric glow-lamp in the middle; that shows him his way. There are other lamps in the tunnel at suitable distances. If his central lamp does not give him light enough to read the titles or the books themselves at the shelf where he is, he has only to touch the button of the nearest lamp to get all the light he wants. In the first experiments in stack-building, which were made a century ago, if the light came from the sides, either the stack could not exceed 20 feet in width, or the middle was dark; if one wanted to use a wide lot of ground, it was necessary to have light-wells about as wide as the stack, which sacrificed valuable space and neutralized the sole advantage of a stack, which is compact storage of the books. If an attempt was made to let the light from the top filter down through perforated, or through glass floors, the lower passages were still dark, and in summer the upper floors under a glass roof were intolerably hot. With electric illumination we are both light and cool. We can store the greatest number of books in the closest proximity to the reading-room, and extend our storage-room indefinitely. There is no way in which books can be packed in closer nearness to the place where they are used. We have now room for over 500,000 volumes in connection with each of the four reading-rooms, or 4,000,000 for the whole building when completed. In the present reading-room there are 9,000 square feet on the front of the building, without counting the special rooms under the art-galleries on the side. We have, of course, book-lifts, noiseless and swift, to take the books from floor to floor. For horizontal transmission we tried various little railroads, but came to the conclusion that a smart boy was the best and the quickest railroad in a library. For carrying many books at a time, of course, we use trucks; and, as the attendants in each room have two stories of shelves to go to, to save the fatigue of climbing even the small height of 8 feet, each room has several little lifts just large enough for one person, driven, like everything else in the library, by Falls-power.”“The books,” he told me, “are arranged in groups of subjects on the different stories, those most called for lowest. On the groundfloor is a selection from all classes of books that are in most active circulation, many of them duplicated in their proper places on higher floors. On the same floor is the class literature, because it is, on the whole, the most sought for. We have not yet escaped the preponderant use of fiction though we have diminished it since your day. It used to be 75 per cent. Thanks to our training the school children in good ways it has fallen to forty. I doubt if it goes much lower. The next two stories are given to the historical, geografical, and social sciences; the fourth to the natural sciences, the industrial arts, the fine arts and sports, and finally to filosofy and theology. When several classes correspond to a single reading-room, one of them is put on one side of the stack opposite one end of the reading-room, another opposite the middle, and a third, if there are three, opposite the other end. This arrangement greatly facilitates procuring books. Every one goes to that reading-room, and to that part of the room whose adjacent shelves contain the subject he is going to work on, — if art, to the fourth story, middle; if European history, to the second story, west end. If he happens to need books from another class, of course he can have them sent up or down to him.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Code with Output
Code

import os, re

def vowel_parse(path):

    #Dictionary to hold the data

    vowel_dict = {}

    #Get all file names and loop through them

    for filename in os.listdir(path):

        #Open, read and close the file

        file = open(path+"/"+filename, mode='r')

        file_content = file.read()

        file.close()

        #Using Regex to find all occurance of the vowel pair and counting them

        vowel_dict[filename] = len(re.findall("[aAeEiIoOuU]{2}", file_content))

    return vowel_dict

#Driver Code

directory = input("Directory name: ")

print(vowel_parse(directory))

Sample Output
Directory name: data
{'FullText.txt': 255, 'Sample1.txt': 73, 'Sample2.txt': 182}

[I have splitted the text to be analyzed into 2 files Sample1 and Sample 2 and also placed the entire content in one file Fulltext inside a folder called 'data' for testing. Please refer to the folder structure on the left to get the idea.]

Add a comment
Know the answer?
Add Answer to:
Help with Data Science python notebook, Question 1 Create a function called vowel_parse() that takes a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT