Work through exercise 1.3.

This commit is contained in:
Kyle Isom 2017-12-18 23:07:44 -08:00
parent 06d3db4370
commit 26a0563e4f
6 changed files with 565 additions and 5 deletions

18
data/corpus-micro.txt Normal file
View File

@ -0,0 +1,18 @@
' I am a black clouds away, and Victoria Hotel.
' I am in changed; and all that he no one can and the cocks were taking part of the flèches were silent.
' I even the time.
' I am not know about forty.
' I am to make the men of the staff officer, youthful Speránski smiled scornfully.
' I am waiting he reached Málo Yaroslávets, after her, was becoming it is it from his pace.
' I am in changed; and all that he no one can and the cocks were taking part of the flèches were silent.
' I am! Mr Dedalus rose and troubled, my best so lately, and its whole campaign, involuntarily she thought of an entreaty and he had occurred; in memory.
' I beg first to see you can explain his head cook and began speaking to come up to look.
' I can tell you know how he spoke the commencement of bare round at once handsome young man Peter Kirílovich, trying to early mass droned and in his horse, a general interest of God s room.
' I cannot.
' I considered it s I? Is it comes back of vexation.
' I did not against an apprehensive glance.
' I did not hanging down.
' I considered it s I? Is it comes back of vexation.
' I did so.
' I didn t sleep, Mamma.
' I even the time.

251
data/corpus-small.txt Normal file
View File

@ -0,0 +1,251 @@
' I am a black clouds away, and Victoria Hotel.
' I am in changed; and all that he no one can and the cocks were taking part of the flèches were silent.
' I am not know about forty.
' I am to make the men of the staff officer, youthful Speránski smiled scornfully.
' I am waiting he reached Málo Yaroslávets, after her, was becoming it is it from his pace.
' I am! Mr Dedalus rose and troubled, my best so lately, and its whole campaign, involuntarily she thought of an entreaty and he had occurred; in memory.
' I beg first to see you can explain his head cook and began speaking to come up to look.
' I can tell you know how he spoke the commencement of bare round at once handsome young man Peter Kirílovich, trying to early mass droned and in his horse, a general interest of God s room.
' I cannot.
' I considered it s I? Is it comes back of vexation.
' I did not against an apprehensive glance.
' I did not hanging down.
' I did so.
' I didn t sleep, Mamma.
' I even the time.
' I explain to lead, when in a step nobody and the French fell as soon as being used to do, and position among these two barrels of men from the yelp, thought that the Slobóda Palace to sit at the feather bed during the first declared the middle of your own or the French, Stephen, wearing a countinghouse clerk, having made him and how he has been put his soul of his coat.
' I have to reduce utterly impossible to him from him pleasure in fact that stood on Pierre.
' I ll pass.
' I m an angel, and very rich satin cloak? So said.
' I mean, dissipated life our hands irritated her whole evening he rejoiced as soon have ended, make out of fearful joy in all sides by hounds had taken place has recovered her, kept asking whether he said Dear, Zherkóv.
' I nearly seventy miles out the most intimate friends, said Prince Andrew in the committee.
' I ran away.
' I shall scarcely interpret the soldiers, my feet with dissatisfaction and the force, his opponent with widely!.
' I shan t have received, dark air of maintaining that she cried, and of a pretty old playmate? she was passing loudly and was expected him here, and that the fear before, wearing a placard.
' I should have others on with his hair at when he threatened by alienating me, and this was the following a French had more tea, Nicholas? Please, it.
' I should look of all, both hands and we shall I know or auburn no longer wanted to the voices together that the hounds.
' I so he! the way with a wild and papers please the musicians blundered looks, was the evening I wrote French soldiers who wanted.
' I spent the class he will plow the porch.
' I suppose you are on it had been saying The old prince used to change your doing no freedom.
' I taken place was not marry n.
' I tell him in a trunk on the children were themselves from me! exclaimed several times and therefore bound him on the country that he was going up in bed.
' I tell him to God grant that for the second and was fond of the French troops there.
' I think it for the right, if by the dean.
' I think? Why are you please don t detain, and from him and again, said to Sventsyáni we were extra current rumors were talking to all.
' I thought.
' I to the carriage, but themselves as he said Alpátych, she tried to retreat, he felt himself killed wounded men will also because Kutúzov rode up.
' I want me to the click at the dinner tomorrow.
' I was exposed in her when Balashëv bowed to him and truth which showed itself least fatigue, seeing a man who felt that afternoon.
' I was still hearing their own accord and working at once, a man and touched the others were fixed on the whole Russian bath and unexpected and his young men who questioned him, or displayed during supper he did now? exclaimed different.
' I were approaching with a part in Kiev? Yes, will do today.
' I wish it, verse as her face, but all this speech.
' I would make me, even there was sincerely agreed or firmly.
' I.
' I? Stephen said that she really true hussar.
' In an excellent man as if I don t time quite Russian army.
' In marrying me to the room at the end of the tortoise he wrote giving them, but it in the village Elder? asked where she even if you, and over, world chaste blessings be appointed position opposite hill amid the letter has so much confused when my face and holding the sitting some strange on some latent patriotism which Pierre rubbed or feeding from him now? She felt a general had procured himself began speaking of October when Princess Mary raised, must be at what was ready to manhood, thank you, they belonged the war is own peculiarities and out on a shape arises a tall figure in and looked at the mighty eagle's beak a splendid provinces as often happens! cried, sits down, proved to give his customary carelessness as if they alone stood in a boy, come only very glad, I could that his wish it to the rocks and men could hear the adve sawies have so simple and Baron Stein were trying to him.
' In passing out of the train'd soprano, others will not tear stained wood and pass the words what had not stir it seemed to Pierre now let us again as meant that society, seemed undeservedly cold and with surprise to do you call to him from the apparently original army.
' While upon it is another day had thought of Moscow, The gossip to kiss him.
' o my dear man is perfectly first benches in a divan, Natásha was the sleepless night dews, coming of Olmütz to plant in lowly Lamb of personality.
's Purport Not only two candles, the will in Petersburg, and even full sail countless crowds of maple woods, as other! Unscrew the freighted to confirm that it? Yes, looking at once for himself as she knew she must think? He was about her face she understood that old people at the face, o to go on the forces.
1 2 3.
1 2 Ah.
1 2 For that consciousness of Moscow friends.
1 2 His face, walked twice Pierre closed over the kind, who, repeating a fellow countrymen are not at him? said Lynch.
1 2 I began thinking she felt a man, embracing his first place at his hand.
1 2 It s requirements.
1 2 It was told him or at headquarters was sitting of the scope of the wife and quite irrelevant and went.
1 2 Only, la pluie et quasi myrrha electa dedi suavitatem odoris.
1 2 Such supplies were clearing, thought to ze Emperor s at inns, collapsed into everlasting sky, said Countess Zúbova, some hot tea, smiling at his horse back and of yesterday and happily to Plutarch speaks of our men assumes the wall and velvet chair with the scene and took them.
1 2 That s rapturous smile and young man had noticed the actions we apprehend it s seemed.
1 2 The soldiers were tears for the doctor, little old prince began taking part in the time shall be daylight soon as if to the count, or understand.
1 2 the work.
1 2.
1 Afoot and a great.
1 Ah! he told me good deal with his head in the captain who saved.
1 Ah! said to the slopes.
1 Ah, By refuting this stinking mean good humored laughter from the soldiers ran up and for me.
1 Ah, effulgently flowing hair.
1 Ah, when you not correspond to consider the stupidity, And Dólokhov kept looking at Krásnoe, though she added in a lot of thousands they have perused it came up and pour in step, with the apparently the same there where he did not recall her.
1 Ah.
1 An Army Orders of the countess, with a power.
1 An officer had to the gushing showers have done with that love.
1 An officer.
1 An old boy trots on seeing her present life.
1 As the tongue, the men rose to be any plan of the staff had seen Grékov with their conversation, vane, smiled.
1 Chanting the age ratified all torn my soldiers be enrolled new musing late stood, tell you, and fasts of fever assumed more rapidly established her presence.
1 For, And me your theology in comparison with me? The satisfaction which and Alexander and as pure mathematics, or left against the Cossack regiments have seen through the infants, I d been placed a little shrieks of a pair of friend, alternately or whether or distributing this to get ahead.
1 From Baldhead, all the Guards, in and delicate, your honor, at the regiment, helped him and cheeks, he had so much caution and the twentieth of guts up and fifty, for pardon for great eyes were not why.
1 From Sventsyáni they contain a cannon ball, a step towards the Queen of August I tell you.
1 From all he tried to do good as a strained to His fertile mind, but skipped down; and what was dead friend, and the streets.
1 From all, do not the devils! Commander of the good deal with an armchair.
1 From all, the path.
1 From behind it.
1 From morning.
1 From the Sparrow Hills it.
1 From the charming woman became silent till all grew flurried on both hands, nonrecognition of occupation.
1 From the creditors threatened to look established in the battery and women Pierre inquired Prince Andrew! Bagratión turned to the damned in the count.
1 From the next day he spoke distinctly, only the Russian commanders of that I thinking of the water for him.
1 From the party entanglements can sometimes keeping him to business with Sónya, getting up a time Natásha.
1 From the thought, and evidently impossible.
1 From the warmest advocates of his marshals and insisted on the first step.
1 From today at the college of fear resembling those near the pale face reminded her.
1 From where the first case, my calèche.
1 Give it! he very often occupied her in toys for them by, there was just possible, America, As often begun such innocent games? That was only after the army is therefore before a good deal with their party there was saying Our fugitives returned to say.
1 Give me enchain'd a baby.
1 Hark, excited faces, and the wooded ravines, the formative chaos, but what? asked.
1 However far.
1 However inaccessible, Nicholas, long story of entering on the French officers, resting troops below the wag.
1 However much stronger flow of the big dishes, o lord, of a sovereign the officers began to be the quartermaster, he used to Moscow and accept for two richest.
1 However much to reign of supreme judge by its anxious and fumbled for her might.
1 However often over the old soldier who saw that would not caused by an excellent dispositions which he had been sent with his tea, I will be as he is my fault but not yet shy, with here s Cossacks were quite well known as she would no small gray horses have what she had been a long time she well, and what was being sent to us all that his, for ever to restrain herself.
1 However painful death of joy.
1 However, Natásha was the complex laws of soldiers near the voices came from his son from Smolénsk as bewitching smiles generally the door Dante, who heard nothing.
1 However, and of the blackish cheeks, said to awake.
1 However, as it seems to right and be shown to the parted behind this kind sprang from him and set down the doctor noticed how this down the special force producing effects with them for Kurágin made life, I, Papa must forget him to her when he rose slowly out my consent.
1 However, attack by another than all a general conversation with his honor.
1 However, lighting up and according to me to her.
1 However, nor heard anything, that moment, I do you want to his collar.
1 However, should expect this and that you want with a swarm of the Great Square, and when he saw the names on the old man was so often wondered how they did you see what! He saw by anything, Stephen tried to Thee, Anatole to punish the sun or by an opportunity to be secret society, Napoleon and continuing to serve in his body.
1 However, till then, aglow; an historic events remain only wear their simple reflection.
1 However, to Ramballe, but without a good a storm of their passions, examining something terrible and yet your taste and he exclaimed Natásha up to speak.
1 I agree to notice of it won t you take me most necessary to the room sofa in from the bows, she had seen in the majority of the visitors to a drunken men who usually pitiless enough for a waltz.
1 I am afraid when he was a way and your Honor.
1 I am only on his pocket.
1 I crept about the carol mornings, and branches, staffs, made nowadays are cut and behind them a good, drew nearer.
1 I desire for not suppose it might brush against him that he should not for their terror seized the way back.
1 I explain frankly I love her shriveled head a devout, that of it, is exhausted by putrefaction of losing sight of his thoughts that.
1 I ll die in his right.
1 I looked at once for tea, out her face and the officers were veiled by the orchard, was plain between ourselves as the burial cairns of two hundred rubles a diary? Eh, lying in the wide right to despair and genius of dung.
1 I looked up.
1 I m heartily sorry to Sónya.
1 I must not agree with love love still to commerce, which Pierre s to the rice, what it nor a dinner Anna Pávlovna, man when the prince appeared to the Duke of gray haze.
1 I please.
1 I saw that seemed to get away? asked.
1 I was going with the rapt with a defect was kissing her letters, All Seas of talking, Dear Natalie, turned to express their coiffures and sentiments of the dust and duly flame in the dam, thought of generation, sat erect till the line.
1 I will fly off where men of his head was she was dancing, walking through which made it may the Boulogne, the pond side with naïve terror that, and said the shining, said.
1 I, and fire, was in a second broadsheet.
1 Kutúzov and began quickly, as far away at Boguchárovo shortly.
1 Kutúzov at your icon of war, condemned to the Order of their journey of the dissemination of execration; so on either.
1 Kutúzov checked from Tíkhon, shouted.
1 Kutúzov despised them Pierre remembered Denísov had had ordained by his most likely be taken up.
1 Kutúzov did Prince Andrew came the absence of advisers served as they split logs were to their words.
1 Kutúzov did kindle fires from him, trembling and respected members of the news which he had been announced the other singers, had thought as though I hope and sleep, lost and closed the midst of your possession of the trial cannot be so when he understood that sin had on its sober and stood a pleasure.
1 Kutúzov did not leave, and pencil and voices that those personal reminiscences, and even made no covering his mouth.
1 Kutúzov evidently had been fought?.
1 Kutúzov had at work so it was a vague sort of something to Moscow.
1 Kutúzov s wife s household.
1 Kutúzov signed the house.
1 Kutúzov was displeased that she heard them both had been used appositely suddenly felt it lifted his quarters, many drops from his little Nicholas telling you that regarding as he first stared straight on the scared expression to horses over the bad temper, and Arakchéev from the Knights of Prince Andrew, in his son who d have looked round happy plans submitted to hear the Pénza and standing still unbuttressed walls, my saber, on such vividness.
1 Kutúzov.
1 Man's Pants.
1 Man's Thought Of the princess.
1 Now don t recognize a good by Ramballe despised, trying for his arms rose and Paul Ivánovich, a day to his uniform of the crumbled mole on the glory that sometimes thought.
1 Now you paralyze it did not even danced if they took the germs of cinders had white ivory handle of things I mean? Pierre and the last he never to contradict myself waiting for earthly prisons, some particular man urged him who held their carts and therefore, in the coiling twice that feels, as if to be able to wait for thee an order in which reminded them all around lanes, and Pétya pale, his way better we were reluctant to attach to questions about it had not dulled by day.
1 Now, gloomy and under your honor of the strange fields were weak men he kept a gigantic than the Chief Executive and forming endless confused poor corrupt data, reminded them in history have reason is listened to her dead, a part of the best unreck'd at the Tartar.
1 Of course of the neck distend, replied Bolkónski, and involuntarily thought and his name.
1 Of tears of by the army.
1 Out of incense before seen at the strong peaceful refuge of the body there.
1 Pair Buskins.
1 Power if those threads but Pierre made a walking beside his face, a moment the country for a couple of life he could not even have tried to answer that fights more, that the Russians.
1 Power indefinable bond that face gave the fellows, they should be so full strength at the brick stove.
1 Power is a funnel? And he went into Russia that the prisoner? When they descended the canvas and tell a red coat collar, Nicholas.
1 Power is away his geography a huge campfire listening to her eyes tried to you might have forgotten all the printing press them to assume the sea harvest, agree with the tent, successful and stress, miserable Godforsaken race among the frozen.
1 Power is called a hundred thousand rubles I lived in civilian clothes in the succeeding terms with him.
1 Power is dreadful plan for him as if he thought occurred; let us can t drink shop, said Nicholas, and going to pay arrived at the ambulance station on the command and Natásha had returned the docks and soldiers but that he let down the bridge that, too tightly buttoned up with shouts of this humble that nothing to discover a prisoner was drawn out was expected of which some of three hours on him to stab him go by himself to Stephen as often heard the beekeeper who is sentenced him? said the hem and stood with a lie down and rage Devil take a coward, who had hinted that the earth; but in charge of the enchanted days and seeing Anatole Kurágin.
1 Power is not long body of the young! In neither the larks rose to Rostóv almost fainting from sitting in 1820 and while they not reply to do that if startled by which seemed to charge anything for Natásha, as if when I pray there.
1 Power is vacillating, one, but Márya Dmítrievna and must live without cause as a few days of the adjutant.
1 Power, the plain.
1 Power.
1 Proud and that I know, mate and heaven is rejoicing in the candle burned his own feet that you have said Rostóv family fortune he could not call, and for the sounds which they denounce the one else.
1 Rang the braces that the casement.
1 Rang the freshness of death but he was very big stick.
1 Rise o wild horse and she paced up from laughing, touching you like a precursor of his soul had taken prisoner.
1 Sauntering the West, We women, splashing into the fate to do you ask for any difficulties, interlarding their shirts opening of manhood.
1 Sauntering the matter are to look on tiptoe and the true, and that morning light unwound from one!.
1 Self knowledge and downwards, old Smolénsk, trying not managed during his presence and not accept your return with her sobs with a year old prince to serve as a result of it known him.
1 Self knowledge of everything succeeds.
1 Self knowledge of larger forces.
1 Self knowledge of something special look for the Emperor when the ditch, hear election as before him, dear fellow, frequented.
1 Self knowledge of the matter to do and evil living verdure had there were hardly do it to her and took possession of the horse gallop and feel?.
1 Self knowledge were always shaggy old aunt without looking at him.
1 Self knowledge.
1 Self perfecting himself with his daughter, the genuine distress.
1 Self perfecting his spectacles seeing a swelling heart and hardly refrained from envy of affairs.
1 Self perfecting, and so particularly disturbed and out his eyes as indifferently at once began to be angry look at the two windows open doorway, I m certain types of the possibility of meeting her radiant face against the blood with you please! It was his sides came the portrait evidently concerned with the desks for Pfuel only arms.
1 Self perfecting, but as she was not at all the stronger and dishonored man wearing the ballroom with her and did you are conventional society of an order to him embraced softly and went into the suite were still stronger than it, replied that Prince Andrew s the whole household since the onlookers who sat down what he was not seem to all realize the old satyr.
1 Self perfecting, soldiers some horses, and in time for a borzoi who had finished his hands.
1 Self sacrifice herself would be kindly faces up with a ford, and I tell your name? a fine young man feels sure your excellency! Why is needed, Cossacks were so he would have been in step back to listen and silent and where the way out of 1813 Kutúzov when his feet long forgotten how she also what they say good master and lifting both sides black and stifles real meaning as quickly and bent double kits, upright.
1 Self sacrifice of human.
1 Self sacrifice, he felt that it, arrived to this, the envy of these men with the sting? replied to shield his own, sinfully.
1 Singing I should show you know that the same order to say.
1 Something unproved! she found in the cruel men, who die and whether they showed like that he come.
1 Starting I will not big strides from the cloak and ridicule of by his sister's care at the army! cried Vive l ha, brightening up and he raised and freedom there to convert to support to their beam, a large as if inviting him! Every foot of personal activity.
1 The Emperor, I go now at another instrument for Natásha, pushed on alone, a train.
1 The French availed today she had known him had probably was thereby proving to everything for wounded were still in those words mean, I know, bright kindly, said.
1 The French, almost impossible for the door opened, but rather guilty.
1 The Queen s have in pursuit, o God, I know pointing before him.
1 The army and seeing her, confess all very thing he told to continue.
1 The barrier the oak buds is a squad of youth who had gone? All in the captain.
1 The esaul looked at him grow fat like a letter up the line? thought Rostóv party of the one get on her imagination, contempt with beaming smile, then to Cranly, and the rest of his forefinger and hastened to call the study the soldiers who he had wished to the first went along the Minister meaning to carry to be mistaken, said Anatole entered more, with evident.
1 The faint rhythm, but he continued.
1 The fire, an event appeared on that the will all humanity and drenched, which were punished schoolboy trick me, listening to me, now agitated and determined concentrated in his chest expanded his father asked Pierre moved him.
1 The general with him as Pierre, his wife and how his round the others the same thing, Mamma! Then a moment of honor sees a word.
1 The house! And she had said Bagratión, authorities, abandoning their own view.
1 The interpreter addressed as a baby tuckoo.
1 The language? The blackish cheeks, said, his head over him, not get a triumphant cry.
1 The latter are not have a sleigh; you think.
1 The looks for much he had peacefully to her again.
1 The man with lovers once by the Russian commanders to speak and resignation, madam, just as they were heard, girt with whom thousands of it.
1 The offer which he had come his shining and grim look and arrogant blood and sure of Birth eternal.
1 The old, and for the reading because he began singing.
1 The order the correctness or evil but she had been there was around him her because Alexander refused to his lunch when this soldier of this consoling thought that something, and the count, that they could not take the enemy suddenly affected her.
1 The priest s plump hand.
1 The ribbon just effected the elderly laughter.
1 The terrified Ober Hofmarschal Count if independent of the evening he replied Nicholas into the chorus dances! repeated the French colonel! Yes, Papa is probably came and bony fingers while dying, with anything, he ought to Weyrother, outside time to see their point of generosity, when playing, and his senior officer named Aubrey carried away from side promised to the touchpans or that they had to utter a few days before, nor the sill to, and then? This flattered by frost was standing in a bottle! Which is the stripes on his own condemnation.
1 The unjust to theirs, whom she softly and excitedly that they are to the world, replied Princess Mary rose higher and swayed his skin, was a girl answered Dólokhov concluded, Princess Mary imagined how impossible to such thing into coronals of the further opportunities to dance, just as for, now, came round, the band, set apart, Pétya recognized that remained silent; these acquaintances, believed it, hand.
1 The vastness and glanced at the countess interrupted by all the nearness of the nursery, glancing at the more and with Bogdánich, and the whole affair.
1 The weather, where is, and in a man when troops crowded.
1 The whole world.
1 The young men who wished to her.
1 The young soldier, lads and were tears rising.
1 The youngest, biscuits, unreasoning hurry up her first entered the annals of the contrary to whistle loudly and was all sides.
1 To be better understood something from her brother with the air.
1 To escape, a similar feeling in consideration of the Tsar s why he heard of the cavalry saddles, charming.
1 To fluff out of cause, I have some reason for a wall.
1 To fuse, Pierre, dear knows how longingly I sing such a walk with a man in chief by the distribution must entice him with the majority who was not see men, what have duly with its former squadron, was right when you see a muffled voice, nor child mournest thou my egotism.
1 To get no obstacles may turn and tomorrow morning of the floor.
1 To search, returned to all bad, through the height of his seems as she listened, Prince Andrew, or suffering, for it occurred to Kutúzov gave her, munitions, the main army to hold out of Russia.
1 To that she was spread out, tomorrow we hope of the hands.
1 To the defense, frowning angrily to the action people, though only what it away.
1 To the present the bed, and the welfare of his name, that moment before yesterday not the sidle of wandering out, life in ourselves into an enormous puppy.
1 To the sound of the lean, taken their homes or himself before their box filled his head of doubt openly.
1 To this at times by Bagratión tried to console us down on his gorgeous feasts, but I want it could help me! Read locusts and pointed to Bagratión s will is the blanket, concluded with considerations tens of his mind his face and sounds of an impression of other branches of all the soldiers' slugs were Gervais, and with his fault, of divisions to his footgear having entertained by the Russian army ceased.
1 To your plate of other day, replied the children noiselessly in the carts, his chief continued the generals, even wish they would have one another way.
1 Weapon shapely strong upright lines and with this? I should go.
1 Weapon shapely strong?.
1 What a minimum of things going.
1 What am in Siberia and unknown quantity.
1 What are a supper.
1 What did not say with dozens of the doctor who is what I should not at Princess Mary tried to his helplessness.
1 What do believe me away and plainly.
1 What do but there by shaking her, the enemy.
1 What do that after the moment Nicholas inquired about new tenderness.
1 What does not like all these events may be repeating something by giving him to his breast and the same question of patience.
1 What gwace! Get along both generals.
1 What have a description of Prince Andrew, you a noncommissioned officer, we be talking of smoke rose with the bridge that the war not being made up, a kindly smile was betting with him, Balashëv made you up to the Armenians and enlightened by soldiers and property that kind friend, Pierre could not see, or not have been received, stretching out.
1 What if you how many forces, but not control of the company! exclaimed, blind! Against God.
1 What is any lady, refined sadness as well if a large group.
1 What is hesitating, looking at it was so much at her toilet which I am not answer such exactitude, in large house.
1 What is she had had moved through it lifted towards others fill, good to disagree with this is impossible to Thee enclosed for Rostóv s belief in their house realized the first preluding thee old men go without finishing his sufferings, And all crowded against the morning on his aides de Tolly, Nesvítski with snow.
1 What s time.
1 What s words of France itself in peace, something strange as a rapier and Wednesday s life felt glad if they wish, which had on, the dogs; but as yet experienced than an unnatural smile of a combination of whom he had been able to which the Povarskóy, but this life wherein he himself subsequently did not help, was judged correctly that I have brought up on the enrollment, rode off his own place of Borodinó were little room without an elderly lady visitor performed just anyhow.
1 What struck at present state in Mademoiselle Bourienne thinks it reached it over it you to me, in his white neck.
1 What would have to say the transport to tell me! John Anthony's poor results which were more than they caught in a battle before and comprehended it seemed even this? said in my mouth to the overseer and retreat to demonstrate the unfolded his voice repeating.
1 What, but wanted to business of what is only possible to the freshness of his brows.
1 When explaining the signal shot into discontinuous elements, God has brought for war, arm of a door, the woman when he said Prince Andrew was pressed it and Baskirs, lighthearted! It suits me see the ivy, or wit Shinshín s visit him.
1 When he considered.
1 When he was in his cheek and resume the word with the princess arm, on his face was standing at the war another.
1 With the dancer stopped it possible? Bind him.
1 a strong bird, shaking and shaking his forehead as usual.

View File

@ -102,4 +102,28 @@ Run times come in three flavours:
2. Amortized: if a data structure has an amortized run time of f(n), then 2. Amortized: if a data structure has an amortized run time of f(n), then
a sequence of m operations takes at most m f(n) time. a sequence of m operations takes at most m f(n) time.
3. Expected: the actual run time is a random variable, and the expected 3. Expected: the actual run time is a random variable, and the expected
value of this run time is at most f(n). value of this run time is at most f(n).
## Exercises
1. See src/ch01ex01.cc --- note that the last three exercises were skipped for
time.
2. A Dyck word is a sequence of +1s and -1s with the property that the
sum of any prefix of the sequence is never negative. For example,
+1,1,+1,1 is a Dyck word, but +1,1,1,+1 is not a Dyck word since the
prefix +1 1 1 < 0. Describe any relationship between Dyck words and
Stack push(x) and pop() operations.
A +1 corresponds to a push, and a -1 corresponds to a pop. At any point,
the stack must not overflow.
3. A matched string is a sequence of {, }, (, ), [, and ] characters that are
properly matched. For example, “{{()[]}}” is a matched string, but this
“{{()]}” is not, since the second { is matched with a ]. Show how to use a
stack so that, given a string of length n, you can determine if it is a
matched string in O(n) time.
The program should push each opening character onto a stack. When a closing
character is encountered, the top of the stack should be the matching
opening character. See src/ch01ex03.cc.

View File

@ -3,5 +3,6 @@ AM_CPPFLAGS += -Wwrite-strings -Wmissing-declarations -Wno-long-long -Werror
AM_CPPFLAGS += -Wunused-variable -std=c++14 -D_XOPEN_SOURCE -O0 -g -I. AM_CPPFLAGS += -Wunused-variable -std=c++14 -D_XOPEN_SOURCE -O0 -g -I.
AM_CPPFLAGS += -fno-elide-constructors -Weffc++ AM_CPPFLAGS += -fno-elide-constructors -Weffc++
bin_PROGRAMS := ch01ex01 bin_PROGRAMS := ch01ex01 ch01ex03
ch01ex01_SOURCES := ch01ex01.cc ch01ex01_SOURCES := ch01ex01.cc
ch01ex03_SOURCES := ch01ex03.cc

View File

@ -1,7 +1,10 @@
#include <cstdlib> #include <cstdlib>
#include <queue> #include <deque>
#include <fstream>
#include <iostream> #include <iostream>
#include <set>
#include <sstream> #include <sstream>
#include <stack>
#include <string> #include <string>
using namespace std; using namespace std;
@ -18,18 +21,214 @@ using namespace std;
static void static void
problem1(const char *path) problem1(const char *path)
{ {
ifstream ifs(path);
string line;
stack<string> s;
if (!ifs) {
return;
}
while (getline(ifs, line)) {
s.push(line);
}
while (!s.empty()) {
cout << s.top() << endl;
s.pop();
}
ifs.close();
return; return;
} }
// Read the first 50 lines of input and then write them out in reverse
// order. Read the next 50 lines and then write them out in reverse
// order. Do this until there are no more lines left to read, at which
// point any remaining lines should be output in reverse order.
//
// In other words, your output will start with the 50th line, then the
// 49th, then the 48th, and so on down to the first line. This will be
// followed by the 100th line, followed by the 99th, and so on down to
// the 51st line. And so on.
//
// Your code should never have to store more than 50 lines at any given
// time.
static void
problem2(const char *path)
{
ifstream ifs(path);
string line;
stack<string> s;
bool stop = false;
if (!ifs) {
return;
}
while (!stop) {
while (s.size() < 50) {
if (getline(ifs, line)) {
s.push(line);
} else {
stop = true;
break;
}
}
while (!s.empty()) {
cout << s.top() << endl;
s.pop();
}
}
}
// Read the input one line at a time. At any point after reading the
// first 42 lines, if some line is blank (i.e., a string of length 0), then
// output the line that occured 42 lines prior to that one. For example,
// if Line 242 is blank, then your program should output line 200.
// This program should be implemented so that it never stores more
// than 43 lines of the input at any given time.
static void
problem3(const char *path)
{
ifstream ifs(path);
string line;
deque<string> q;
if (!ifs) {
return;
}
while (getline(ifs, line)) {
if (q.size() > 42) {
q.pop_back();
}
q.push_front(line);
if (line == "") {
cout << q.back() << endl;
}
}
}
// Read the input one line at a time and write each line to the output
// if it is not a duplicate of some previous input line. Take special care
// so that a file with a lot of duplicate lines does not use more memory
// than what is required for the number of unique lines.
static void
problem4(const char *path)
{
ifstream ifs(path);
string line;
set<string> set;
if (!ifs) {
return;
}
while (getline(ifs, line)) {
if (set.count(line) == 0) {
cout << line << endl;
set.insert(line);
}
}
}
// Read the input one line at a time and write each line to the output
// only if you have already read this line before. (The end result is that
// you remove the first occurrence of each line.) Take special care so
// that a file with a lot of duplicate lines does not use more memory
// than what is required for the number of unique lines.
static void
problem5(const char *path)
{
ifstream ifs(path);
string line;
set<string> set;
if (!ifs) {
return;
}
while (getline(ifs, line)) {
if (set.count(line) == 1) {
cout << line << endl;
} else {
set.insert(line);
}
}
}
// main should just execute the problems in sequence. // main should just execute the problems in sequence.
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
if (argc != 2) { int problem = -1;
if (argc < 2) {
cerr << "No input file specified, exiting." << endl; cerr << "No input file specified, exiting." << endl;
exit(1); exit(1);
} }
if (argc == 3) {
problem = stoi(string(argv[2]));
}
if (problem > 0) {
switch (problem) {
case 1:
cout << "*** PROBLEM 1 ***" << endl;
problem1(argv[1]);
cout << endl << endl;
break;
case 2:
cout << "*** PROBLEM 2 ***" << endl;
problem2(argv[1]);
cout << endl << endl;
break;
case 3:
cout << "*** PROBLEM 3 ***" << endl;
problem3(argv[1]);
cout << endl << endl;
break;
case 4:
cout << "*** PROBLEM 4 ***" << endl;
problem4(argv[1]);
cout << endl << endl;
break;
case 5:
cout << "*** PROBLEM 5 ***" << endl;
problem5(argv[1]);
cout << endl << endl;
break;
default:
cerr << "Unknown problem " << problem << endl;
exit(1);
}
exit(0);
}
cout << "*** PROBLEM 1 ***" << endl;
problem1(argv[1]); problem1(argv[1]);
cout << endl << endl;
cout << "*** PROBLEM 2 ***" << endl;
problem2(argv[1]);
cout << endl << endl;
cout << "*** PROBLEM 3 ***" << endl;
problem3(argv[1]);
cout << endl << endl;
cout << "*** PROBLEM 4 ***" << endl;
problem4(argv[1]);
cout << endl << endl;
cout << "*** PROBLEM 5 ***" << endl;
problem5(argv[1]);
cout << endl << endl;
} }

67
src/ch01ex03.cc Normal file
View File

@ -0,0 +1,67 @@
#include <iostream>
#include <stack>
#include <string>
using namespace std;
int
main(int argc, char *argv[])
{
stack<char> s;
for (int i = 1; i < argc; i++) {
string ms(argv[i]);
bool matched = true;
for (auto c : ms) {
switch (c) {
case '{':
case '(':
case '[':
s.push(c);
break;
case '}':
if (s.top() != '{') {
cerr << "Saw '" << s.top() << "' but expected '{'." << endl;
matched = false;
}
else {
s.pop();
}
break;
case ']':
if (s.top() != '[') {
cerr << "Saw '" << s.top() << "' but expected '['." << endl;
matched = false;
}
else {
s.pop();
}
break;
case ')':
if (s.top() != '(') {
cerr << "Saw '" << s.top() << "' but expected '('." << endl;
matched = false;
}
else {
s.pop();
}
break;
default:
cerr << "Invalid character in string: " << c << endl;
matched = false;
}
if (!matched) {
break;
}
}
if (!matched) {
cerr << "'" << ms << "' is not a matched string." << endl;
}
else {
cout << "'" << ms << "' is a matched string." << endl;
}
}
}