From 53954e2eba9e3d8a078e43e429c2af7ff988ee49 Mon Sep 17 00:00:00 2001 From: CWinarski Date: Tue, 13 Mar 2018 00:21:26 -0400 Subject: [PATCH 1/5] Finished Part 1 --- src/main/java/io/zipcoder/ParenChecker.java | 25 ++++++- .../java/io/zipcoder/ParenCheckerTest.java | 73 +++++++++++++++++++ 2 files changed, 97 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/zipcoder/ParenChecker.java b/src/main/java/io/zipcoder/ParenChecker.java index caee675..b852777 100644 --- a/src/main/java/io/zipcoder/ParenChecker.java +++ b/src/main/java/io/zipcoder/ParenChecker.java @@ -1,4 +1,27 @@ package io.zipcoder; -public class ParenChecker { + +import java.util.Stack; + +public class ParenChecker{ + + Stack parensStack = new Stack(); + + public boolean verifyParensArePaired(String input){ + for(int i = 0; i < input.length(); i++){ + char inputCharacter = input.charAt(i); + if (inputCharacter == '('){ + parensStack.push(inputCharacter); + }else if (inputCharacter == ')' && parensStack.isEmpty() || parensStack.peek() != '('){ + return false; + } else if (inputCharacter == ')' && parensStack.peek() == '('){ + parensStack.pop(); + } + } + return parensStack.isEmpty(); + } + + public boolean verifyOpeningCharactersHaveAClosingOne(String input){ + return false; + } } diff --git a/src/test/java/io/zipcoder/ParenCheckerTest.java b/src/test/java/io/zipcoder/ParenCheckerTest.java index 76aa3b6..8c808fc 100644 --- a/src/test/java/io/zipcoder/ParenCheckerTest.java +++ b/src/test/java/io/zipcoder/ParenCheckerTest.java @@ -4,5 +4,78 @@ import org.junit.Test; public class ParenCheckerTest { + ParenChecker parenCheckerTest = new ParenChecker(); + @Test + public void verifyParensArePairedTest(){ + //Given + String test = "()"; + boolean expected = true; + //When + boolean actual = parenCheckerTest.verifyParensArePaired(test); + Assert.assertEquals(expected,actual); + } + @Test + public void verifyParensArePairedTest2(){ + //Given + String test = "(("; + boolean expected = false; + //When + boolean actual = parenCheckerTest.verifyParensArePaired(test); + Assert.assertEquals(expected,actual); + } + + @Test + public void verifyParensArePairedTest3(){ + //Given + String test = ")("; + boolean expected = false; + //When + boolean actual = parenCheckerTest.verifyParensArePaired(test); + Assert.assertEquals(expected,actual); + } + + @Test + public void verifyParensArePairedTest4(){ + //Given + String test = "("; + boolean expected = false; + //When + boolean actual = parenCheckerTest.verifyParensArePaired(test); + Assert.assertEquals(expected,actual); + } + + @Test + public void verifyOpeningCharactersHaveAClosingOneTest(){ + + } + @Test + public void verifyOpeningCharactersHaveAClosingOneTest2(){ + //Given + String test = "()"; + boolean expected = true; + //When + boolean actual = parenCheckerTest.verifyParensArePaired(test); + Assert.assertEquals(expected,actual); + } + + @Test + public void verifyOpeningCharactersHaveAClosingOneTest3(){ + //Given + String test = "(("; + boolean expected = false; + //When + boolean actual = parenCheckerTest.verifyParensArePaired(test); + Assert.assertEquals(expected,actual); + } + + @Test + public void verifyOpeningCharactersHaveAClosingOneTest4(){ + //Given + String test = ")("; + boolean expected = false; + //When + boolean actual = parenCheckerTest.verifyParensArePaired(test); + Assert.assertEquals(expected,actual); + } } \ No newline at end of file From 83948a16e76759c430c513d862c9a599d5fb3410 Mon Sep 17 00:00:00 2001 From: CWinarski Date: Tue, 13 Mar 2018 00:56:09 -0400 Subject: [PATCH 2/5] Working on Part 2 --- src/main/java/io/zipcoder/ParenChecker.java | 20 ++++++++- .../java/io/zipcoder/ParenCheckerTest.java | 41 +++++++++++++------ 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/src/main/java/io/zipcoder/ParenChecker.java b/src/main/java/io/zipcoder/ParenChecker.java index b852777..b9fd9aa 100644 --- a/src/main/java/io/zipcoder/ParenChecker.java +++ b/src/main/java/io/zipcoder/ParenChecker.java @@ -1,11 +1,13 @@ package io.zipcoder; +import java.util.HashMap; import java.util.Stack; public class ParenChecker{ Stack parensStack = new Stack(); + HashMap openClosingPairs = new HashMap(); public boolean verifyParensArePaired(String input){ for(int i = 0; i < input.length(); i++){ @@ -22,6 +24,22 @@ public boolean verifyParensArePaired(String input){ } public boolean verifyOpeningCharactersHaveAClosingOne(String input){ - return false; + openClosingPairs.put('(', ')'); + openClosingPairs.put('{', '}'); + openClosingPairs.put('[', ']'); + openClosingPairs.put('<', '>'); + openClosingPairs.put('"', '"'); + openClosingPairs.put('\'', '\''); + + for(int i = 0; i < input.length(); i++){ + char inputCharacter = input.charAt(i); + + if(openClosingPairs.containsKey(inputCharacter)){ + parensStack.push(inputCharacter); + } else if (parensStack.isEmpty() || parensStack.peek() != openClosingPairs.get(inputCharacter)){ + return false; + } + } + return parensStack.isEmpty(); } } diff --git a/src/test/java/io/zipcoder/ParenCheckerTest.java b/src/test/java/io/zipcoder/ParenCheckerTest.java index 8c808fc..f1f1e45 100644 --- a/src/test/java/io/zipcoder/ParenCheckerTest.java +++ b/src/test/java/io/zipcoder/ParenCheckerTest.java @@ -46,36 +46,51 @@ public void verifyParensArePairedTest4(){ } @Test - public void verifyOpeningCharactersHaveAClosingOneTest(){ - + public void verifyParenthesesHaveOpenAndClosingOneTest(){ + //Given + String test = "()"; + boolean expected = true; + //When + boolean actual = parenCheckerTest.verifyOpeningCharactersHaveAClosingOne(test); + Assert.assertEquals(expected,actual); } @Test - public void verifyOpeningCharactersHaveAClosingOneTest2(){ + public void verifyBracketsHaveOpenAndClosingOneTest(){ //Given - String test = "()"; + String test = "{}"; boolean expected = true; //When - boolean actual = parenCheckerTest.verifyParensArePaired(test); + boolean actual = parenCheckerTest.verifyOpeningCharactersHaveAClosingOne(test); Assert.assertEquals(expected,actual); } @Test - public void verifyOpeningCharactersHaveAClosingOneTest3(){ + public void verifyDiamondsHaveOpenAndClosingOneTest(){ //Given - String test = "(("; - boolean expected = false; + String test = "[]"; + boolean expected = true; //When - boolean actual = parenCheckerTest.verifyParensArePaired(test); + boolean actual = parenCheckerTest.verifyOpeningCharactersHaveAClosingOne(test); Assert.assertEquals(expected,actual); } @Test - public void verifyOpeningCharactersHaveAClosingOneTest4(){ + public void verifyDoubleQuotesHaveOpenAndClosingOneTest(){ //Given - String test = ")("; - boolean expected = false; + String test = " \"Hi\" "; + boolean expected = true; //When - boolean actual = parenCheckerTest.verifyParensArePaired(test); + boolean actual = parenCheckerTest.verifyOpeningCharactersHaveAClosingOne(test); + Assert.assertEquals(expected,actual); + } + + @Test + public void verifySingleQuotesHaveOpenAndClosingOneTest(){ + //Given + String test = " \'Merp\' "; + boolean expected = true; + //When + boolean actual = parenCheckerTest.verifyOpeningCharactersHaveAClosingOne(test); Assert.assertEquals(expected,actual); } } \ No newline at end of file From 4af8e29c07da80d9dcae5135e962e0693bd05f6b Mon Sep 17 00:00:00 2001 From: CWinarski Date: Tue, 13 Mar 2018 13:16:40 -0400 Subject: [PATCH 3/5] All but two test cases pass on Part 2 --- src/main/java/io/zipcoder/ParenChecker.java | 6 ++++-- src/test/java/io/zipcoder/ParenCheckerTest.java | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/zipcoder/ParenChecker.java b/src/main/java/io/zipcoder/ParenChecker.java index b9fd9aa..fba90be 100644 --- a/src/main/java/io/zipcoder/ParenChecker.java +++ b/src/main/java/io/zipcoder/ParenChecker.java @@ -32,12 +32,14 @@ public boolean verifyOpeningCharactersHaveAClosingOne(String input){ openClosingPairs.put('\'', '\''); for(int i = 0; i < input.length(); i++){ - char inputCharacter = input.charAt(i); + Character inputCharacter = input.charAt(i); if(openClosingPairs.containsKey(inputCharacter)){ parensStack.push(inputCharacter); - } else if (parensStack.isEmpty() || parensStack.peek() != openClosingPairs.get(inputCharacter)){ + } else if (openClosingPairs.containsValue(parensStack.peek()) && parensStack.isEmpty()){ return false; + }else if (inputCharacter == openClosingPairs.get(parensStack.peek())){ + parensStack.pop(); } } return parensStack.isEmpty(); diff --git a/src/test/java/io/zipcoder/ParenCheckerTest.java b/src/test/java/io/zipcoder/ParenCheckerTest.java index f1f1e45..b6cd6e9 100644 --- a/src/test/java/io/zipcoder/ParenCheckerTest.java +++ b/src/test/java/io/zipcoder/ParenCheckerTest.java @@ -74,10 +74,20 @@ public void verifyDiamondsHaveOpenAndClosingOneTest(){ Assert.assertEquals(expected,actual); } + @Test + public void verifyDiamondsHaveOpenAndClosingOneTestFail(){ + //Given + String test = "["; + boolean expected = false; + //When + boolean actual = parenCheckerTest.verifyOpeningCharactersHaveAClosingOne(test); + Assert.assertEquals(expected,actual); + } + @Test public void verifyDoubleQuotesHaveOpenAndClosingOneTest(){ //Given - String test = " \"Hi\" "; + String test = "\"Hi\""; boolean expected = true; //When boolean actual = parenCheckerTest.verifyOpeningCharactersHaveAClosingOne(test); @@ -87,7 +97,7 @@ public void verifyDoubleQuotesHaveOpenAndClosingOneTest(){ @Test public void verifySingleQuotesHaveOpenAndClosingOneTest(){ //Given - String test = " \'Merp\' "; + String test = "'Merp'"; boolean expected = true; //When boolean actual = parenCheckerTest.verifyOpeningCharactersHaveAClosingOne(test); From 2500744d480e83598aecce9d95fa80ff296a5e57 Mon Sep 17 00:00:00 2001 From: CWinarski Date: Tue, 13 Mar 2018 19:37:19 -0400 Subject: [PATCH 4/5] Finished Lab --- pom.xml | 13 + src/main/java/io/zipcoder/WC.java | 56 +- src/main/resources/someTextFile.txt | 1481 +++++++++++++++++++++++++ src/main/resources/testFile.txt | 1 + src/test/java/io/zipcoder/WCTest.java | 17 +- 5 files changed, 1563 insertions(+), 5 deletions(-) create mode 100644 src/main/resources/testFile.txt diff --git a/pom.xml b/pom.xml index e66b725..ee4eec4 100644 --- a/pom.xml +++ b/pom.xml @@ -8,6 +8,19 @@ collections 1.0-SNAPSHOT + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + junit diff --git a/src/main/java/io/zipcoder/WC.java b/src/main/java/io/zipcoder/WC.java index babb68c..f2c021c 100644 --- a/src/main/java/io/zipcoder/WC.java +++ b/src/main/java/io/zipcoder/WC.java @@ -2,10 +2,13 @@ import java.io.FileNotFoundException; import java.io.FileReader; -import java.util.Iterator; -import java.util.Scanner; +import java.util.*; + +import static java.util.stream.Collectors.toMap; public class WC { + + Map wordsAndTheirCounts = new LinkedHashMap(); private Iterator si; public WC(String fileName) { @@ -20,4 +23,53 @@ public WC(String fileName) { public WC(Iterator si) { this.si = si; } + + //Sort values into map method + public Map countNumberOfTimesWordsOccur(){ + Integer wordCount = 0; + while(si.hasNext()){ + wordCount++; + String word = si.next().toLowerCase().replaceAll("[^a-z]", ""); + if(wordsAndTheirCounts.containsKey(word)){ + wordsAndTheirCounts.put(word, wordsAndTheirCounts.get(word) +1); + } else{ + wordsAndTheirCounts.put(word, 1); + } + } + wordsAndTheirCounts.put("Total Words", wordCount); + return wordsAndTheirCounts; + } + + //Order map in descending order method + public Map sortMapIntoDescendingOrder() { + List> toSort = new ArrayList<>(); + for (Map.Entry stringIntegerEntry : countNumberOfTimesWordsOccur().entrySet()) { + toSort.add(stringIntegerEntry); + } + toSort.sort(Map.Entry. + comparingByValue().reversed().thenComparing(Map.Entry.comparingByKey())); + Map wordsAndTheirCountsDesc = new LinkedHashMap<>(); + for (Map.Entry stringIntegerEntry : toSort) { + wordsAndTheirCountsDesc.putIfAbsent(stringIntegerEntry.getKey(), stringIntegerEntry.getValue()); + } + return wordsAndTheirCountsDesc; + } + + //Print map method + public String printMap(){ + StringBuilder printedList = new StringBuilder(); + for (Map.Entry entry : sortMapIntoDescendingOrder().entrySet()){ + printedList.append(entry.getKey()); + printedList.append(":"); + printedList.append(" appears "); + printedList.append(entry.getValue()); + printedList.append(" times\n"); + } + return printedList.toString(); + } + + +/// ^ reads like does not equal +// :: + } diff --git a/src/main/resources/someTextFile.txt b/src/main/resources/someTextFile.txt index e69de29..dec1218 100644 --- a/src/main/resources/someTextFile.txt +++ b/src/main/resources/someTextFile.txt @@ -0,0 +1,1481 @@ +Project Gutenberg's Animal Sanctuaries in Labrador, by William Wood + +This eBook is for the use of anyone anywhere at no cost and with +almost no restrictions whatsoever. You may copy it, give it away or +re-use it under the terms of the Project Gutenberg License included +with this eBook or online at www.gutenberg.net + + +Title: Animal Sanctuaries in Labrador + An Address Presented by Lt.-Colonel William Wood, F.R.S.C. before + the Second Annual Meeting of the Commission of Conservation at Quebec, + January, 1911 + + +Author: William Wood + +Release Date: February 1, 2005 [EBook #14866] + +Language: English + +Character set encoding: ISO-8859-1 + +*** START OF THIS PROJECT GUTENBERG EBOOK ANIMAL SANCTUARIES IN LABRADOR *** + + + + +Produced by Wallace McLean, Diane Monico and the Online Distributed +Proofreading Team (http://www.pgdp.net). + + + + + + + + + + +Commission of Conservation +Canada + +ANIMAL SANCTUARIES +IN +LABRADOR + +AN ADDRESS PRESENTED +BY +LT.-COLONEL WILLIAM WOOD, F.R.S.C. + +Before the Second Annual Meeting +of the Commission of Conservation +at Quebec, January, 1911 + +OTTAWA: CAPITAL PRESS LIMITED, 1911 + + + + +_Animal Sanctuaries +in Labrador_ + +An Address Presented +BY +LT.-COLONEL WILLIAM WOOD +BEFORE +THE SECOND ANNUAL MEETING +OF THE COMMISSION OF CONSERVATION +HELD AT QUEBEC, JANUARY, 1911 + + + + +An Appeal + +All to whom wild Nature is one of the greatest glories of the Earth, +all who know its higher significance for civilized man to-day, and all +who consequently prize it as an heirloom for posterity, are asked to +help in keeping the animal life of Labrador from being wantonly done +to death. + +There is nothing to cause disagreement among the three main classes of +people most interested in wild life--the men whose business depends in +any way on animal products, the sportsmen, and the Nature-lovers of +every kind. There are very good reasons why the general public should +support the scheme. And there are equally good reasons why it should +be induced to do so by simply telling it the truth about the senseless +extermination that is now going on. + +Every reader can help by spreading some knowledge of the subject in +his or her home circle. Canada, like all free countries, is governed +by public opinion. And sound public opinion, like all other good +things, should always begin at home. + +The Press can help, as it has helped many another good cause, by +giving the subject full publicity. Free use can be made of the present +paper in any way desired. It is left non-copyright for this very +purpose. + +Experts can help by pointing out mistakes, giving information, and +making suggestions of their own. And if any of them will undertake to +lead, the present author will undertake to follow. + +It is proposed to issue a supplement in 1912, containing all the +additional information collected in the mean time. Every such item of +information will be duly credited to the person supplying it. + +All correspondence should be addressed-- + + COLONEL WOOD, + 59, Grande Allée, Quebec. + + + + +Animal Sanctuaries in Labrador +BY +LIEUT.-COLONEL WILLIAM WOOD, F.R.S.C., ETC. + + +MR. CHAIRMAN AND GENTLEMEN:-- + +To be quite honest I must begin by saying that I am not a scientific +expert on either animals, sanctuaries or Labrador. But, by way of +excusing my temerity, I can plead a life-long love of animals, a good +deal of experience and study of them--especially down the Lower St. +Lawrence, and considerable attention to sanctuaries in general and +their suitability to Labrador in particular. Moreover, I can plead +this most pressingly important fact, that a magnificent opportunity is +fast slipping away before our very eyes there, without a single effort +being made to seize it. I have repeatedly discussed the question with +those best qualified to give sound advice--with naturalists, +explorers, missionaries, fishermen, furriers, traders, hunters, +sportsmen, and many who are accustomed to look ahead into the higher +development of our public life. I have also read the books, papers and +reports written from up-to-date and first-hand knowledge. And, though +I have been careful to consult men who regard such questions from very +different points of view, and books showing quite as wide a general +divergence, I have found a remarkable consensus of opinion in favour +of establishing a system of sanctuaries before it is too late. I +should like to add that any information on the subject, or any +correction of what I have written here, will be most welcome. The +simple address, Quebec, will always find me. The only special point I +would ask correspondents to remember is that even the best +recommendations must be adapted to the peculiarities of the Labrador +problem, which is new, strange, immense, and full of complex human +factors. + +Perhaps I might be allowed to explain that I speak simply as a +Canadian. I am not connected with any of the material interests +concerned. I do not even belong to a Fish and Game club. My only +object is to prove, from verifiable facts, that animal life in +Labrador is being recklessly and wantonly squandered, that this is +detrimental to everyone except the get-rich-quickly people who are +ready to destroy any natural resources forever in order to reap an +immediate and selfish advantage, that sanctuaries will better +conditions in every way, and that the ultimate benefit to Canada--both +in a material and a higher sense--will repay the small present expense +required, over and over again. And this repayment need not be long +deferred. I can show that once the public grasps the issues at stake +it will supply enough petitioners to move any government based on +popular support, and that the scheme itself will supply enough money +to make the sanctuaries a national asset of the most paying kind, and +enough higher human interest to make them priceless as a possession +for ourselves and a heritage for all who come after. + +If, Sir, you would allow me to make one more preliminary explanation, +I should like to say that I have purposely left out all the usual +array of statistics. I have, of course, examined them carefully +myself, and based my arguments upon them. But I have excluded them +from my text because they would have made an already long paper unduly +longer, and because they are perfectly accessible to every member of +the Commission which I have the honour of addressing to-night. + + +SANCTUARIES. + +A sanctuary may be defined as a place where Man is passive and the +rest of Nature active. Till quite recently Nature had her own +sanctuaries, where man either did not go at all or only as a +tool-using animal in comparatively small numbers. But now, in this +machinery age, there is no place left where man cannot go with +overwhelming forces at his command. He can strangle to death all the +nobler wild life in the world to-day. To-morrow he certainly will have +done so, unless he exercises due foresight and self-control in the +mean time. There is not the slightest doubt that birds and mammals are +now being killed off much faster than they can breed. And it is always +the largest and noblest forms of life that suffer most. The whales and +elephants, lions and eagles, go. The rats and flies, and all mean +parasites, remain. This is inevitable in certain cases. But it is +wanton killing off that I am speaking of to-night. Civilized man +begins by destroying the very forms of wild life he learns to +appreciate most when he becomes still more civilized. The obvious +remedy is to begin conservation at an earlier stage, when it is +easier and better in every way, by enforcing laws for close seasons, +game preserves, the selective protection of certain species, and +sanctuaries. I have just defined a sanctuary as a place where man is +passive and the rest of Nature active. But this general definition is +too absolute for any special case. The mere fact that man has to +protect a sanctuary does away with his purely passive attitude. Then, +he can be beneficially active by destroying pests and parasites, like +bot-flies or mosquitoes, and by finding antidotes for diseases like +the epidemic which periodically kills off the rabbits and thus starves +many of the carnivora to death. But, except in cases where experiment +has proved his intervention to be beneficial, the less he upsets the +balance of Nature the better, even when he tries to be an earthly +Providence. + +In itself a sanctuary is a kind of wild "zoo," on a gigantic scale and +under ideal conditions. As such, it appeals to everyone interested in +animals, from the greatest zoologist to the mere holiday tourist. +Before concluding I shall give facts to show how well worth while it +would be to establish sanctuaries, even if there were no other people +to enjoy the benefits. Yet the strongest of all arguments is that +sanctuaries, far from conflicting with other interests, actually +further them. But unless we make these sanctuaries soon we shall be +infamous forever, as the one generation which defrauded posterity of +all the preservable wild life that Nature took a million years to +evolve into its present beautiful perfection. Only a certain amount of +animal life can exist in a certain area. The surplus must go outside. +So sanctuaries are more than wild "zoos", they are overflowing +reservoirs, fed by their own springs, and feeding streams of life at +every outlet. They serve not only those interested in animal life, but +those legitimately interested in animal death, for business, sport or +food. I might mention many instances of successful sanctuaries, +permanent or temporary, absolute or modified--the Algonquin, Rocky +Mountains, Yoho, Glacier, Jasper and Laurentides in Canada; the +Yellowstone, Yosemite, Grand Cañon, Olympus and Superior in the United +States; with the sea-lions of California, the wonderful revival of +ibex in Spain and deer in Maine and New Brunswick, the great preserves +in Uganda, India and Ceylon, the selective work of Baron von Berlepsch +in Germany, the curious result of taboo protection up the Nelson +river, and the effects on seafowl in cases as far apart in time and +space as the guano islands under the Incas of Peru, Gardiner island in +the United States or the Bass rock off the coast of Scotland. + +Yet I do not ignore the difficulties. First, there is the universal +difficulty of introducing or enforcing laws where there have been no +operative laws before. Next, there is the difficulty of arousing +public opinion on any subject, however worthy, which requires both +insight and foresight. Then, we must remember that protected species +increasing beyond their special means of subsistence have to seek +other kinds of food, sometimes with unfortunate results. And then +there are the several special difficulties connected with Labrador. +There are three British governments concerned--Newfoundland, the +Dominion and the province of Quebec. There are French and American +fishermen along the shore. The proper protection of some migratory +species will require co-operation with the United States, perhaps with +Mexico and South America for certain birds, and even with Denmark for +the Greenland seal. Then, there are the Indians, the whole trade in +animal products, the necessity of not interfering with any legitimate +development, and the question of immediate expense, however small, for +a deferred benefit, however great and near at hand. And, finally, we +must remember that scientific knowledge is not by any means adequate +to deal with all the factors of the problem at once. + + +LABRADOR + +But in spite of all these and many other difficulties, I firmly +believe that Labrador is by far the best country in the world for the +best kinds of sanctuary. The first time you're on a lee shore there, +in a full gale, you may well be excused for shrinking back from the +wild white line of devouring breakers. But when you actually make for +them you find the coast opening into archipelagoes of islands, to let +you safely through into the snug little "tickles," between island and +mainland, where you can ride out the storm as well as you could in a +landlocked harbour. This is typical of many another pleasant surprise. +Labrador decidedly improves on acquaintance. The fogs have been +grossly exaggerated. The Atlantic seaboard is clearer than the British +Isles, which, by the way, lie in exactly the same latitudes. And the +Gulf is far clearer than New Brunswick, Nova Scotia and the Banks. The +climate is exceptionally healthy, the air a most invigorating tonic, +and the cold no greater than in many a civilized northern land. +Besides, there is a considerable range of temperatures in a country +whose extreme north and south lie 1,000 miles apart, one in the +latitude of Greenland, the other in that of Paris. Taking the Labrador +peninsula geographically, as including the whole area east of a line +run up the Saguenay and on from lake St. John to James bay, it +comprises 560,000 square miles--eleven Englands! The actual residents +hardly number 20,000. About twice as many outsiders appear off the +coasts at certain seasons. So it would take a tenfold increase, afloat +and ashore, to make one human being to each square mile of land. But, +all the same, wild life needs conservation there, and needs it badly, +as we shall presently see. + +Most of Labrador is a rocky tableland, still rising from the depths, +with some old beaches as much as 1,500 feet above the present level of +the sea. The St. Lawrence seaboard is famous for its rivers and +forests. The Atlantic seaboard has the same myriads of islands, is +magnificently bold, is pierced by fiords unexcelled in Norway, and +crowned by mountains higher than any others east of the Rockies. +Hamilton inlet runs in 150 miles. At Ramah the cliffs rise sheer three +thousand five hundred feet and more. The Four peaks, still untrodden +by the foot of man, rise more than twice as high again. And the +colouration, of every splendid hue, adds beauty to the grandeur of the +scene. Inland, there are lakes up to 100 miles long, big rivers by the +score, deep canyons and foaming rapids--to say nothing of the +countless waterfalls, of which the greatest equals two Niagaras. This +vast country is accessible by sea on three sides, and will soon be +accessible by land on the fourth. It lies directly half-way between +Great Britain and our own North West and is 1,000 miles nearer London +than New York is. Its timber, mines and water-power will be +increasingly exploited. It should also become increasingly attractive +to the best type of tourist, naturalist and sportsman. But supposing +all this does happen. The mines, water-powers and lumbering will only +create small towns and villages. There will surely be some +conservation to have the forests used and not abused especially by +fire: and the white man should remember that he is the worst of all in +turning a land from green to black. Except in the southwest and a few +isolated spots, the country cannot be farmed. At the same time, the +urban population must have communications with the outside world, by +which regular supplies can come in. This will make the settlers +independent of wild life for necessary food; and wild life, in any +case, would be too precarious if exploited in the usual way. The +traders in wild-animal products, as well as the naturalists, sportsmen +and tourists, are interested in keeping the rest of the country well +stocked. So that, one way and another, the human and wild-animal life +will not conflict, as they do where farming creates a widespread rural +population, or wanton destruction of forests ruins land and water, and +human and animal life have to suffer for it afterwards. All the +different places required for business spheres of influence in the +near future, added to all the business spheres of the present, can +hardly exceed the area of one whole England, especially if all +suitable areas are not thrown open simultaneously to lumbering, at the +risk of the usual bad results. So there will remain ten other +Englands, admirably fitted, in all respects, to grow wild life in the +most beneficial abundance, and quite able to do so indefinitely, if a +reasonable amount of general protection is combined with well-situated +sanctuaries. + +The fauna is much more richly varied than people who think of +Labrador as nothing but an arctic barren are inclined to suppose. The +fisheries have been known for centuries, especially the cod, which has +a prerogative right to the simple word "fish." There are herring and +lobsters in the Gulf, plenty of salmon and trout in most of the +rivers, winninish in all the tributary waters of the Hamilton, as well +as in lake St. John, whitefish in the lakes, and so forth. Then, the +stone-carrying chub is one of the most interesting creatures in the +world.... But the fish and fisheries have problems of their own too +great for incidental treatment; and I shall pass on to the birds and +mammals. + +Yet I must not forget the "flies"--who that has felt them once can +ever forget them? Labrador is not a very happy hunting-ground for the +entomologist. But all it lacks in variety of kinds it more than makes +up in number of individuals, especially in the detestable trio of +bot-flies, blackflies and mosquitoes. The bot-fly infests the caribou +and will probably infest the reindeer. The blackfly and mosquito +attack both man and beast in maddening millions. The mosquito is not +malarious. But that is the only bad thing he is not. Destruction is +"conservation" so far as "flies," parasites and disease germs are +concerned. + +Labrador has over 200 species of birds, from humming-birds and +sanderlings to eagles, gannets, loons and herons. Among those able to +hold their own, with proper encouragement, are the following: two +loons, two murres, the puffin, guillemot, razor-billed auk, dovekie +and pomarine jæger; six gulls--ivory, kittiwake, glaucous, great +black-back, herring and Bonaparte; two terns--arctic and common; the +fulmar, two shearwaters, two cormorants, the red-breasted merganser +and the gannet; seven ducks--the black, golden-eye, old squaw and +harlequin, with the American, king and Greenland eiders; three +scoters; four geese--snow, blue, brant and Canada; two phalaropes, +several sandpipers, with the Hudsonian godwit and both yellowlegs; two +snipes; five plovers; and the Eskimo and Hudsonian curlews. These two +curlews should be absolutely closed to all shooting everywhere for +several seasons. They are on the verge of extinction; and it may even +now be too late to save them. The great blue heron and American +bittern are not common, but less rare than they are supposed to be. +Except for the willow and rock ptarmigans the land game-birds are not +many in kind or numbers. There are a fair number of ruffed grouse in +the south, and more spruce grouse in the north. The birds of prey are +well represented by a few golden and more bald-headed eagles, the +American rough-legged and other hawks, the black and the white +gyrfalcons, the osprey, and eight owls, including the great horned +owl, the boldest bird of all. The raven is widely distributed all the +year round. Several woodpeckers, kingfishers, jays, bluebird, +kingbird, chickadee, snow bunting; several sparrows, including, +fortunately, the white-crowned, white-throat and song, but now, +unfortunately, the English as well. There are blackbirds, red-polls, a +dozen warblers, the American robin, hermit thrush and ruby-throated +humming-bird. + +Both the land and sea mammals are of great importance. Several whales +are well known. The Right is almost exterminated; but the Greenland, +or Bow-head, is found along the edge of the ice in all Hudsonian +waters. The Pollock is rare, and the Sperm, or Cachalot, as nearly +exterminated as the Right. But the Little-piked, or _rostrata_, is +found inshore along the north and east, the Bottle-nose on the north, +the Humpback on the east and south; and the Finback and Sulphur-bottom +are common and widely distributed, especially on the east. The Little +White whale, or "White porpoise," is fairly common all round; the +Killer is widely distributed, but most numerous on the east, where the +Narwhal is also found. The Harbour and Striped porpoises, and the +Common and Bottle-nosed dolphins, are chiefly on the east and south. +There are six Seals--the Harbour, Ringed, Harp, Bearded, Grey and +Hooded. The Harbour seal is also called the "Common" and the "Wise" +seal, and is the _vitulina_ of zoology. It is common all round the +coasts, and the Indians of the interior assert that many live +permanently in the lakes. Big and Little Seal lakes are more than 100 +miles from the nearest salt water. The Ringed seal is locally called +"floe rat" and "gum seal." It is the smallest and least valuable of +all, and fairly common all round. The Harp seal is "seal," in the same +way as cod is "fish." It has various local names, five among the +French-Canadians alone, but is specifically known as the Greenland +seal. The young, immediately after birth, have a fine white coat, +which makes them valuable. The herds are followed on a large scale at +the end of the winter season, which is also the whelping season, and +hundreds of thousands are killed, females and young preponderating. +They are still common along the east and south, but diminishing +steadily, especially in the St. Lawrence. The Bearded, or +"Square-flipper," seal is rare in the St. Lawrence and on the +Atlantic, but commoner in Hudsonian waters. It is a large seal, eight +feet long, and bulky in proportion. The Grey, or Horse-head, seal +runs up to about the same size occasionally and is one of the gamest +animals that swims. It is rare on the Atlantic and not common anywhere +on the St. Lawrence. The "Hoods" are the largest of all and the lions +of the lot. They run up to 1,000 pounds and over, and sometimes +fourteen feet long. They are rare on the Atlantic and decreasing along +the St. Lawrence, owing to the Newfoundland hunters. The Walrus, +formerly abundant all round, is now rarely seen except in the far +north, where he is fast decreasing. + +Moose may feel their way in by the southwest to an increasing extent, +and might possibly be reinforced by the Alaskan variety. Red deer +might possibly be induced to enter by the same way in fair numbers +over a limited area. The woodland caribou is almost exterminated, but +might be resuscitated. The barren-ground caribou is still plentiful in +the north, where most of the herds appear to migrate in an immense +ellipse, crossing from west to east, over the barrens, in the fall, to +the Atlantic, and then turning south and west through the woods in +winter, till they reach their original starting-point near Hudson bay +in the spring. But this is not to be counted on. The herds divide, +change direction, and linger in different places. Their tame brother, +the reindeer, is being introduced as the chief domestic animal of +Eastern Labrador, with apparently every prospect of success. Beaver +are fairly common and widely distributed in forested areas. Other +rodents are frequent--squirrels, musk-rats, mice, voles, lemmings, +hares and porcupines. There are two bats. Black bears are general; +polars, in the north. Grizzlies have been traded at Fort Chimo in +Ungava, but they are probably all killed out. The lynx is common +wherever there are woods. There are two wolves, arctic and timber, the +latter now rare in the south. The Labrador red fox is very common in +the woods, and the "white," or arctic fox, in the barrens and further +south on both coasts. The "cross," "silver" and "black" variations of +course occur, as they naturally increase towards the northern limits +of range. The "blue" is a seasonal change of the "white." The +wolverine and otter are common. The skunk is only known in the +southwest. The mink ranges through the southern third of the +peninsula. The Labrador marten, or "sable," is a sub-species, +generally distributed in the forested parts, like the weasel. The +"fisher," or Pennant's marten, is much more local, ranging only +between the "North Shore" and Mistassini. + +From the St. Lawrence to the Barren Grounds three-fourths of the land +has been burnt over since the white man came. The resultant loss of +all forms of life may be imagined, especially when we remember that +the fire often burns up the very soil itself, leaving nothing but +rocks and black desolation. Still, there is plenty of fur and feather +worth preserving. But nothing can save it unless conservation replaces +the present reckless destruction. + + +DESTRUCTION + +When rich virgin soil is first farmed it yields a maximum harvest for +a minimum of human care. But presently it begins to fail, and will +fail altogether unless man returns to it in one form some of the +richness he expects to get from it in another. Now, exploited wild +life fails even faster under wasteful treatment; but, on the other +hand, with hardly any of the trouble required for continuous farming, +quickly recovers itself by being simply let alone. So when we consider +how easily it can be preserved in Labrador, and how beneficial its +preservation is to all concerned, we can understand how the wanton +destruction going on there is quite as idiotic as it is wrong. + +Take "egging" as an example. The Indians, Eskimos and other beasts of +prey merely preserved the balance of nature by the toll they used to +take. No beast of prey, not even the white man, will destroy his own +stock supply of food. But with the nineteenth century came the +white-man market "eggers", systematically taking or destroying every +egg in every place they visited. Halifax, Quebec and other towns were +centres of the trade. The "eggers" increased in numbers and +thoroughness till the eggs decreased in the more accessible spots +below paying quantities. But other egging still goes on unchecked. The +game laws of the province of Quebec distinctly state: "It is forbidden +to take nests or eggs of wild birds at any time". But the swarms of +fishermen who come up the north shore of the St. Lawrence egg wherever +they go. If they are only to stay in the same spot for a day or two, +they gather all the eggs they can, put them into water, and throw away +every one that floats. Sometimes three, four, five or even ten times +as many are thrown away as are kept, and all those bird lives lost for +nothing. Worse still, if the men are going to stay long enough they +will often go round the nests and make sure of smashing every single +egg. Then they come back in a few days and gather every single egg, +because they know it has been laid in the mean time and must be +fresh. When we remember how many thousands of men visit the shore, and +that the resident population eggs on its own account, at least as high +up as the Pilgrims, only 100 miles from Quebec, we need not be +prophets to foresee the inevitable end of all bird life when subjected +to such a drain. And this is on the St. Lawrence, where there are laws +and wardens and fewer fishermen. What about the Atlantic Labrador, +where there are no laws, no wardens, many more fishermen, and ruthless +competitive egging between the residents and visitors? Of course, +where people must egg or starve there is nothing more to be said. But +this sort of egging is very limited, not enough to destroy the birds, +and the necessity for it will become less frequent as other sources of +supply become available. It is the utterly wanton destruction that is +the real trouble. + +And it is just as bad with the birds as with the eggs. A schooner +captain says, "Now, boys, here's your butcher shop: help yourselves!" +and this, remember, is in the brooding season. Not long ago the men +from a vessel in Cross harbour landed on an islet full of eiders and +killed every single brooding mother. Such men have grown up to this, +and there is that amount of excuse for them. Besides, they ate the +birds, though they destroyed the broods. Yet, as they always say, "We +don't know no law here," it may be suspected that they do know there +really is one. These men do a partly excusable wrong. But what about +those who ought to know better? In the summer of 1907 an American +millionaire's yacht landed a party who shot as many brooding birds on +St. Mary island as they chose, and then left the bodies to rot and +the broods to perish. That was, presumably, for sport. For the same +kind of sport, motor boats cut circles round diving birds, drown them, +and let the bodies float away. The North Shore people have drowned +myriads of moulting scoters in August; but they use the meat. Bestial +forms of sport are many and vile. "C'est un plaisir superbe" was the +description given by some voyageurs on exploring work, who had spent +the afternoon chasing young birds about the rocks and stamping them to +death. Deer were literally hacked to pieces by construction gangs on +new lines last summer. Dynamiting a stream is quite a common trick +wherever it is safe to play it. Harbour seals are wantonly shot in +deep fresh water where they cannot be recovered, much as seagulls are +shot by blackguards from an ocean liner. + +And the worst of it is that all this wanton destruction is not by any +means confined to the ignorant or those who have been brought up to +it. The men from the American yacht must have known better. So do +those educated men from our own cities, who shoot out of season down +the St. Lawrence and plead, quite falsely, that there is no game law +below the Brandy Pots. It is, of course, well understood that a man +can always shoot for necessary food. But this provision is shamelessly +misused. Last summer, when a great employer of labour down the Gulf +was telling where birds could be shot to the greatest advantage out of +season, and I was objecting that it was not clean sport, he said, "Oh, +but Indians can shoot for food at any time--_and we're all Indians +here!"_ And what are we to think of a rich man who used caribou simply +as targets for his new rifle, and a scientific man who killed 72 in +one morning, only to make a record? We need the true ideal of sport +and an altogether new ideal of conservation, and we need them very +badly and very soon. + +We have had our warnings. The great auk and the Labrador duck have +both become utterly extinct within living memory. The Eskimo curlew is +decreasing to the danger point, and the Yellowlegs is following. The +lobster fishing is being wastefully conducted along the St. Lawrence; +so, indeed, are the other fisheries. Whales are diminishing: the Cape +Charles and Hawke Harbour establishments are running, but those at +L'Anse au Loup and Seven islands are not. The whole whaling industry +is disappearing all over the world before the uncontrolled persecution +of the new steam whalers. The walrus is exterminated everywhere in +Labrador except in the north. The seals are diminishing. Every year +the hunters are better supplied with better implements of butchery. +The catch is numbered by the hundreds of thousands, and this only for +one fleet in one place at one season, when the Newfoundlanders come up +the St. Lawrence at the end of the winter. The woodland caribou has +been killed off to such an extent as to cause both Indians and wolves +to die off with him. The barren-ground caribou is still plentiful, +though decreasing. The dying out of so many Indians before the time of +the Low and Eaton expedition of 1893-4 led to an increase of +fur-bearing animals. But renewed, improved, increased and uncontrolled +trapping has now reduced them below their former level. Hunting for +the market seems to be going round in a vicious circle, always +narrowing in on the quarry, which must ultimately be strangled to +death. The white man comes in with better equipment, more systematic +methods and often a "get-rich-and-get-out" idea that never entered a +native head. The Indian has to go further afield. The white follows. +Their prey shrinks back in diminishing numbers before them both. +Prices go up. The hunt becomes keener, the animals fewer and farther +off. Presently hunters and hunted will reach the far side of the +utmost limits. And then traded, traders and trade will all disappear +together. And it might so well be otherwise. + +There is another point that should never be passed over. In these days +the public conscience is beginning to realize that the objection to +man's cruelty towards his other fellow-beings is something more than a +fad or a fancy. And wanton slaughter is very apt to be accompanied by +shameless cruelty. To kill off parents when the young are helpless.... +But I have already given enough sickening details of this. The +treatment of the adults is almost worse in many typical cases. An +Indian will skin a hare alive and gloat over his quivering +death-agonies. The excuse is, "white man have fun, Indian have fun, +too." And it is a valid excuse, from one point of view. When "there's +nothing in caribou" except the value of the tongue, the tongue has +been cut out of the living deer, whose only other value is considered +to be the amusement afforded by his horrible fate. And, fiendish +cruelty like this is not confined to the outer wilds. When some +civilized English-speaking bird-catchers get a bird they do not want, +they will deliberately wrench its bill apart, so that it must die of +lingering starvation. Sometimes the cruelty is done to man himself. +Not so many years ago some whalers secured a lot of walrus hides and +tusks by having a whole herd of walrus wiped out, in spite of the fact +that these animals were, at that very time, known to be the only food +available for a neighbouring tribe of Eskimos. The Eskimos were +starved to death, every soul among them, as the Government explorers +found out. But Eskimos have no votes and never write to the papers; +while walrus hides were booming in the markets of civilization. + +Things like these are not much spoken of. They very rarely appear in +print. And when they are mentioned at all it is generally with an +apology for introducing unpleasant details. But I am sure I need not +apologize to gentlemen who are anxious to know the full truth of this +great question, who cannot fail to see the connection between wanton +destruction and revolting cruelty, and who must be as ready to rouse +the moral conscience of our people against the cruelty as they are to +rouse its awakening sense of conservation against the destruction. + + +CONSERVATION + +All the sound reasons ever given for conserving other natural +resources apply to the conservation of wild life--and with three-fold +power. When a spend-thrift squanders his capital it is lost to him and +his heirs; yet it goes somewhere else. When a nation allows any one +kind of natural resource to be squandered it must suffer a real, +positive loss; yet substitutes of another kind can generally be found. +But when wild life is squandered it does not go elsewhere, like +squandered money; it cannot possibly be replaced by any substitute, as +some inorganic resources are: it is simply an absolute, dead loss, +gone beyond even the hope of recall. + +Now, we have seen verifiable facts enough to prove that Labrador, out +of its total area of eleven Englands, is not likely to be +advantageously exploitable over much more than the area of one England +for other purposes than the growth and harvesting of wild life by land +and water. How are these ten Englands to be brought under +conservation, before it is too late, in the best interests of the five +chief classes of people who are concerned already or will be soon? Of +course, the same individual may belong to more than one class. I +merely use these divisions to make sure of considering all sides of +the question. The five great interests are those of--1. Food. 2. +Business. 3. The Indians and Eskimos. 4. Sport, and 5. The +Zoophilists, by which I mean all people interested in wild-animal +life, from zoologists to tourists. + +1. FOOD.--The resident population is so sparse that there is not one +person for every 20,000 acres; and most of these people live on the +coast. Consequently, the vast interior could not be used for food +supplies in any case. Besides, ever since the white man occupied the +coast, the immediate hinterland, which used to be full of life, has +become more and more barren. Fish is plentiful enough. A few small +crops of common vegetables could be grown in many places, and outside +supplies are becoming more available. So the toll of birds and mammals +taken by the present genuine residents for necessary food is not a +menace, if taken in reason. In isolated places in the Gulf, like +Harrington, the Provincial law might safely be relaxed, so as to allow +the eggs of ducks and gulls to be taken up to the 5th of June and +those of murres, auks and puffins up to the 15th. Flight birds might +also be shot at any time on the outside capes and islands. There is a +local unwritten law down there--"No guns inside, after the 1st of +June"--and it has been kept for twenty years. Similar relaxations +might be allowed in other places, in genuine cases of necessity. But +the egging and out-of-season slaughter done by people, resident or +not, who are in touch with the outside world, should be stopped +absolutely. And the few walrus now required as food by the few +out-living Eskimos should be strictly protected. Of course, killing +for food under real stress of need at any time or place goes without +saying. The real and spurious cases will soon be discriminated by any +proper system. + +2. BUSINESS.--Business is done in fish, whales, seals, fur, game, +plumage and eggs. The fish are a problem apart. But it is worth noting +that uncontrolled exploitation is beginning to affect even their +countless numbers in certain places. Whales have always been exploited +indiscriminately, and their wide range outside of territorial waters +adds to the difficulties of any regulation. But some seasonal and +sanctuary protection is necessary to prevent their becoming extinct. +The "white porpoise" could have its young protected; and whaling +stations afford means of inspection and consequent control. The only +chance at present is that when whales become too scarce to pay they +are let alone, and may revive a little. The seals can be protected +locally and ought to be. The preponderance of females and young killed +in the whelping season is a drain impossible for them to withstand +under modern conditions of slaughter. The difficulty of policing large +areas simultaneously might be compensated for by special sanctuaries. +The Americans are protecting their seals by restrictions on the +numbers, ages and sex of those killed; and doing so successfully. The +fur trade is open to the same sort of wise restriction, when +necessary, to the protection of wild fur by the breeding of tame, as +in the fox farms, and to the benefits of sanctuaries. Marketable game, +plumage and eggs can be regulated at out ports and markets. And the +extension of suitable laws to non-game animals, coupled with the +establishment of sanctuaries, would soon improve conditions all round, +especially in the interest of business itself. No one wants his +business to be destroyed. But if Labrador is left without control +indefinitely every business dealing with the products of wild life +will be obliged to play the suicidal game of competitive grab till the +last source of supply is exhausted, and capital, income and employment +all go together. + +3. INDIANS AND ESKIMOS.--The Eskimos are few and mostly localized. The +Indians stand to gain by anything that will keep the fur trade in full +vigour, as they are mostly hunters and trappers. Restriction on the +number of skins, if that should prove necessary, and certainly on the +sale of all poisons, could be made operative. Strychnine is said to +kill animals eating the carcases even so far as to the seventh remove. +Close seasons and sanctuaries are difficult to enforce with all +Indians. But the registration of trappers, the enforcement of laws, +the employment of Indians as guides for sportsmen, and other means, +would have a salutary effect. The full-bloods, unfortunately, do not +take kindly to guiding. Indians wishing to change their way of life or +proving persistent lawbreakers might be hived in reserves with their +wives and families. The reserves themselves would cost nothing, the +Indians could find employment as other Indians have, and the expense +of establishing would be a bagatelle. As a matter of fact, in spite of +all the bad bargains having always been on the Indian side when sales +and treaties were made with the whites, there is enough money to the +credit of the Indians in the hands of the Government to establish a +dozen hives and keep the people in them as idle as drones on the mere +interest of it. But good hunting grounds are better than good hives. + +4. SPORT.--Sport should have a great future in Labrador. Inland game +birds, except ptarmigan, are the only kind of which there is never +likely to be a great abundance, owing to the natural scarcity of their +food. But, besides the big game on land and game birds on the coast, +there are some unusual forms of sport appealing to adventurous +natures. Harpooning the little white whale by hand in a North Shore +canoe, or shooting the largest and gamest of all the seals--the great +"hood"--also out of a canoe, requires enough skill and courage to make +success its own reward. The extension and enforcement of proper game +laws would benefit sport directly, while indirectly benefitting all +the other interests. + +5. ZOOPHILISTS.--The zoophilist class seems only in place as an +afterthought. But I am convinced that it will soon become of at least +equal importance with any other. All the people, from zoologists to +tourists, who are drawn to such places by the attraction of seeing +animal life in its own surroundings, already form an immense class in +every community. And it is a rapidly increasing class. Could we do +posterity any greater injury than by destroying the ten Englands of +glorious wild life in Labrador, just at the very time when our own and +other publics are beginning to appreciate the value of the appeal +which such haunts of Nature make to all the highest faculties of +civilized man? + +The way can be made clear by scientific study. The laws can be drawn +up by any intelligent legislators, and enforced quite as efficiently +as other laws have been by the Mounted Police in the North West. The +expense will be small, the benefits great and widely felt. The only +real hitch is the uninformed and therefore apathetic state of public +opinion. If people only knew that Labrador contained a hundred +Saguenays, wild zoos, Thousand Islands, fiords, palisades, sea +mountains, cañons, great lakes and waterfalls, if they only knew that +they could get the enjoyment of it for a song, and make it an heirloom +for no more trouble than letting it live, they might do all that is +needed to-morrow. But they don't know. And the three Governments +cannot do much without the support of public opinion. At present they +do practically nothing. The Ungavan Labrador has neither organization +nor laws. The Newfoundland Labrador has organization but no laws. And +the Quebec Labrador has laws but no observance of them. + +However, Quebec has laws, which are something, legislators who have +made the laws, and leaders who have introduced them. The trouble is +that the public generally has no sense of responsibility in the matter +of enforcement. It still has a hazy idea that Nature has an +overflowing sanctuary of her own, somewhere or other, which will fill +up the gaps automatically. The result is that poaching is commonly +regarded as a venial offence, poachers taken red-handed are rarely +punished, and willing ears are always lent to the cry that rich +sportsmen are trying to take the bread out of the poor settler's +mouth. The poor settler does not reflect that he himself, and all +other classes alike, really have a common interest in the conservation +of any wild life that does not conflict with legitimate human +development. There is some just cause of complaint that the big-game +reserves are hampering the peasants in parts of India and the settlers +and natives in parts of Uganda. But no such complaint can be raised +against the Laurentide National Park, so wisely established by the +Quebec Government. The worst of it is that many of the richer people +set the example in law-breaking. The numbers of big game allowed are +exceeded, out-of-season shooting goes on, and both out-of-season and +forbidden game is sold in the markets and served at the dinner tables +of the very class who should be first in protecting it. + +Partly because Quebec has taken the lead in legislation, and partly +because an ideal site is ready to hand under its jurisdiction, I would +venture to suggest the immediate establishment of an absolute +sanctuary for all wild birds and mammals along as much of the coast as +possible on either side of cape Whittle. The best place of all to keep +is from cape Whittle eastward to cape Mekattina, 64 miles in a +straight line by sea. The 45 miles from cape Mekattina eastward to +Shekatika bay are probably the next best; and, next, the 35 from cape +Whittle westward to Cloudberry point. As there are 800 miles between +Quebec and the Strait, I am only proposing to make from one-tenth to +one-fifth of them into a sanctuary. And this part is the least fitted +for other purposes, except sea-fishing, which would not be restricted +at all, the least inhabited, and the most likely to succeed as a +sanctuary, especially for birds. + +Cape Whittle is 550 miles below Quebec, 70 below Natashkwan, which is +the last port of call for the mail boats, and 50 below Kegashka, the +last green spot along the shore. It faces cape Gregory, near the bay +of Islands in Newfoundland, 130 miles across; and is almost as far +from the north-east point of Anticosti. It is a great landmark for +coasting vessels, and for the seal herds as well. A refuge for seals +is absolutely necessary to preserve their numbers and the business +connected with them. Of course, I know there is a feeling that, if +they are going to disappear, the best thing to do is to exploit them +to the utmost in the meanwhile, so as to snatch every present +advantage, regardless of consequences. But is this business, sense, or +conservation? Even if any restriction in the way of numbers, sex, age +or season should be imposed on seal hunting, a small sanctuary cannot +but be beneficial. While, if there is no other protection, a sanctuary +is a _sine qua non_. It is possible that some protection might also be +afforded to the whales that hug the shore. + +The case of the birds is quite as strong, and the chance of protection +by this sanctuary much greater. With the exception of the limited +egging and shooting for the necessary food of the few residents--the +whole district of Mekattina contained only 213 people at the last +census--not an egg nor a bird should be touched at all. The birds soon +find out where they are well off, and their increase will recruit the +whole river and gulf. A few outlying bird sanctuaries should be +established in connection with this one, which might be called the +Harrington Sanctuary, as Harrington is a well-known telegraph station, +a central point between cape Whittle and Mekattina, and it enjoys a +name that can be easily pronounced. In the Gulf the Bird rocks and +Bonaventure island to the south; one of the Mingan islands, the +Perroquets and Egg island to the north; with the Pilgrims, up the +River, above the Saguenay and off the South Shore, are the best. The +Pilgrims, 700 miles from the Atlantic, are probably the furthest +inland point in the world where the eider breeds. They would make an +ideal seabird sanctuary. On the Atlantic Labrador there are plenty of +suitable islands from which to choose two or three sanctuaries, +between Hamilton inlet and Ramah. The east coast of Hudson bay is full +of islands from which two corresponding sanctuaries might be selected, +one in the neighbourhood of the Portland promontory and the other in +the southeast corner of James bay. + +There is the further question--affecting all migratory animals, but +especially birds--of making international agreements for their +protection. There are precedents for this, both in the Old World and +in the New. And, so far as the United States are concerned, there +should be no great difficulty. True, they have set us some lamentable +examples of wanton destruction. But they have also set us some noble +examples of conservation. And we have good friends at court, in the +members of the New York Zoological, the Audubon and other societies, +in Mr. Roosevelt, himself an ardent conserver of wild life, and in Mr. +Bryce, who is an ex-president of the Alpine Club and a devoted lover +of nature. Immediate steps should be taken to link our own bird +sanctuaries with the splendid American chain of them which runs round +the Gulf of Mexico and up the Atlantic coast to within easy reach of +the boundary line. Corresponding international chains up the +Mississippi and along the Pacific would be of immense benefit to all +species, and more particularly to those unfortunate ones which are +forced to migrate down along the shore and back by the middle of the +continent, thus running the deadly gauntlet both by land and sea. + +Inland sanctuaries are more difficult to choose and manage. A deer +sanctuary might answer near James bay. Fur sanctuaries must also be in +some fairly accessible places, on the seaward sides of the various +heights-of-land, and not too far in. The evergreen stretches of the +Eastmain river have several favourable spots. What is needed most is +an immediate examination by a trained zoologist. The existing +information should be brought together and carefully digested for him +in advance. There are the Dominion, Provincial and Newfoundland +official reports; the Hudson Bay Company, the Moravian missionaries; +Dr. Robert Bell, Mr. A.P. Low, Mr. D.I.V. Eaton, Dr. Grenfell, Dr. +Hare, Mr. Napoléon Comeau, not to mention previous writers, like +Packard, McLean and Cartwright--a whole host of original authorities. +But their work has never been thoroughly co-ordinated from a +zoological point of view. A form of sanctuary suggested for the +fur-bearing Yukon is well worth considering. It consists in opening +and closing the country by alternate sections, like crops and fallow +land in farming. The Indians have followed this method for +generations, dividing the family hunting grounds into three parts, +hunting each in rotation, and always leaving enough to breed back the +numbers. But the pressure of the grab-all policy from outside may +become irresistible. + +The one great point to remember is that there is no time to lose in +beginning conservation by protecting every species in at least two +separate localities. + +A word as to the management and wardens. Two zoologists and twenty men +afloat, and the same number ashore, could probably do the whole work, +in connection with local wardens. This may seem utterly ridiculous as +a police force to patrol ten Englands and three thousand miles of sea. +But look at what the Royal North West Mounted Police have done over +vast areas with a handful of men, and what has been effected in Maine, +New Brunswick and Ontario. Once the public understands the question, +and the governments mean business, the way of the transgressor will be +so hard--between the wardens, zoologists and all the preventive +machinery of modern administration--that it will no longer pay him to +walk in it. Special precautions must be taken against that vilest of +all inventions of diabolical ingenuity--the Maxim "silencer." No +argument is needed to prove that silent firearms could not suit crime +better if they were made expressly for it. The mere possession of any +kind of "silencer" should constitute a most serious criminal offence. +The right kind of warden will be forthcoming when he is really wanted +and is properly backed up. I need not describe the wrong kind. We all +know him, only too well. + + +BENEFITS + +I am afraid I have already exceeded my allotted time. But, with your +kind indulgence, Sir, I should like, in conclusion, simply to +enumerate a few of the benefits certain to follow the introduction and +enforcement of law and the establishment of sanctuaries. + +First, it cannot be denied that the constant breaking of the present +law makes for bad citizenship, and that the observance of law will +make for good. Next, though it is often said that what Canada needs +most is development and not conservation, I think no one will deny +that conservation is the best and most certainly productive form of +development in the case before us. Then, I think we have here a really +unique opportunity of effecting a reform that will unite and not +divide all the legitimate interests concerned. What could appear to +have less in common than electricity and sanctuaries? Yet electricity +in Labrador requires water-power, which requires a steady flow, which +requires a head-water forest, which, in its turn, is admirably fit to +shelter wild life. Except for those who would selfishly and +shortsightedly take all this wealth of wild life out of the world +altogether, in one grasping generation, there is nobody who will not +be the better for the change. I have talked with interested parties of +every different kind, and always found them agree that conservation is +the only thing to do--provided, as they invariably add, that it is +done "straight" and "the same for all." + +Fourthly, a word as to sport. I have invoked the public conscience +against wanton destruction and its inevitable accompaniment of +cruelty. I know, further, that man is generally cruel and a bully +towards other animals. And, as an extreme evolutionist, I believe all +animals are alike in kind, however much they may differ in degree. But +I don't think clean sport cruel. It does not add to the sum total of +cruelty under present conditions. Wild animals shun pain and death as +we do. But under Nature they never die what we call natural deaths. +They starve or get killed. Moreover, town-bred humanitarians feel pain +and death more than the simpler races of men, who, in their turn, feel +it more than lower animals. A wild animal that has just escaped death +will resume its occupation as if nothing had happened. The sportsman's +clean kill is only an incident in the day's work, not anxiously +apprehended like an operation or a battle. But pain and death are very +real, all the same. So death should be inflicted as quickly as +possible, even at the risk of losing the rest of one's bag. And, even +beyond the reach of any laws, no animal should ever be killed in sport +when its own death might entail the lingering death of its young. A +sportsman who observes these rules instinctively, and who never kills +what he cannot get and use, is not a cruel man. He certainly is a +beast of prey. But so is the most delicate invalid woman when drinking +a cup of beef tea. Sport has its use in the development of health and +skill and courage. Its practice is one of life's eternal compromises. +And the best thing we can do for it now is to make it clean. We have +far too much of the other kind. The essential difference has never +been more shrewdly put than in the caustic epigram, that there is the +same difference between a sportsman and a "sport" as there is between +a gentleman and a "gent." I believe that the enforcement of laws and +the establishment of sanctuaries will raise our sport to a higher +plane, reduce the suffering now inflicted when killing for business, +and help in every way towards the conversion of the human into the +humane. Besides, paradoxical as it may seem to some good people, the +true sportsman has always proved to be one of the very best conservers +of all wild life worth keeping. So there is a distinctly desirable +benefit to be expected in this direction, as in every other. + +Finally, I return to my zoophilists, a vast but formless class of +people, both in and outside of the other classes mentioned, and one +which includes every man, woman and child with any fondness for wild +life, from zoologists to tourists. There are higher considerations, +never to be forgotten. But let me first press the point that there's +money in the zoophilists--plenty of it. A gentleman, in whom you, Sir, +and your whole Commission have the greatest confidence, and who was +not particularly inexpert at the subject, made an under-valuation to +the extent of no less than 75 per cent., when trying to estimate the +amount of money made by the transportation companies directly out of +travel to "Nature" places for sport, study, scenery and other kinds of +outing. There is money in it now, millions of it; and there is going +to be much more money in it later on. Civilized town-dwelling men, +women and children are turning more and more to wild Nature for a +holiday. And their interest in Nature is widening and deepening in +proportion. I do not say this as a rhetorical flourish. I have taken +particular pains to find out the actual growth of this interest, which +is shown in ways as comprehensive as educational curricula, picture +books for children, all sorts of "Animal" works, "zoos", museums, +lectures, periodicals and advertisements; and I find all facts +pointing the same way. The president of one of the greatest +publishers' associations in the world told me, and without being +asked, that the most marked and the steadiest development in the trade +was in "Nature" books of every kind. And this reminds me of the +countless readers who rarely hear the call of the wild themselves, +except through word and picture, but who would bitterly and +justifiably resent the silencing of that call in the very places where +it ought to be heard at its best. + +Now, where can the call of wild Nature be heard to greater advantage +than in Labrador, which is a land made on purpose to be the home of +fur, fin and feather? And it is accessible, in the best of all +possible ways--by sea. It is about equidistant from central Canada, +England and the States--a wilderness park for all of them. Means of +communication are multiplying fast. Even now, it would be possible, in +a good steamer, to take a month's holiday from London to Labrador, +spending twenty days on the coast and only ten at sea. I think we may +be quite sure of such travel in the near future; that is, of course, +if the travellers have a land of life, not death, to come to. And an +excellent thing about it is that Labrador cannot be overrun and spoilt +like what our American friends so aptly call a "pocket wilderness". +Ten wild Englands, properly conserved, cannot be brought into the +catalogue of common things quite so easily as all that! Besides, +Labrador enjoys a double advantage in being essentially a seaboard +country. The visitor has the advantage of being able to see a great +deal of it--and the finest parts, too--without getting out of touch +with his moveable base afloat. And the country itself has the +corresponding advantage of being less liable to be turned into a +commonplace summer resort by the whole monotonizing apparatus of +hotels and boarding houses and conventional "sights". + +And now, Sir, I venture once more to mention the higher interests, and +actually to specify one of them, although I have been repeatedly +warned by outsiders that no public men would ever listen to anything +which could not be expressed in "easy terms of dollars and cents!" And +I do so in full confidence that no appeal to the intellectual life +would fall on deaf ears among the members of a Commission which was +founded to lead rather than follow the best thought of our time. I +need not remind you that from the topmost heights of Evolution you can +see whole realms of Nature infinitely surpassing all those of +business, sport and tourist recreation, and that the theory of +Evolution itself is the crowned brain of the entire Animal Kingdom. +But I doubt whether, as yet, we fully realize that Labrador is +absolutely unique in being the only stage on which the prologue and +living pageant of Evolution can be seen together from a single +panoramic point of view. The sea and sky are everywhere the same +primeval elements. But no other country has so much primeval land to +match them. Labrador is a miracle of youth and age combined. It is +still growing out of the depths with the irresistible vigour of youth. +But its titanic tablelands consist of those azoic rocks which form the +very roots of all the other mountains in the world, and which are so +old, so immeasurably older than any others now standing on the surface +of the globe, that their Laurentians alone have the real right to bear +the title of "The Everlasting Hills". Being azoic these Laurentians +are older than the first age when our remotest ancestors appeared in +the earliest of animal forms, millions and millions of years ago. +They are, in fact, the only part of the visible Earth which was +present when Life itself was born. So here are the three great +elemental characters, all together--the primal sea and sky and +land--to act the azoic prologue. And here, too, for all mankind to +glory in, is the whole pageant of animal life: from the weakest +invertebrate forms, which link us with the illimitable past, to the +mightiest developments of birds and mammals at the present day, the +leviathan whales around us, the soaring eagles overhead, and man +himself--the culmination of them all--and especially migrating man, +whose incoming myriads are linking us already with the most pregnant +phases of the future. Where else are there so many intimate appeals +both to the child and the philosopher? Where else, in all this world, +are there any parts of the Creation more fit to exalt our visions and +make us "Look, through Nature, up to Nature's God"? + +But, Sir, I must stop here; and not without renewed apologies for +having detained you so long over a question on which, as I have +already warned you, I do not profess to be a scientific expert. I fear +I have been no architect, not even a builder. But perhaps I have done +a hodman's work, by bringing a little mortar, with which some of the +nobler materials may presently be put together. + + + + +Bibliography + + +This short list is a mere indication of what can be found in any good +library. + +General information is given in _Labrador; its Discovery, Exploration +and Development--By W.G. Gosling: Toronto, Musson._ The Atlantic +Labrador is dealt with by competent experts in _Labrador: the Country +and the People--By W.T. Grenfell and Others: New York, The Macmillan +Company, 1910._ This has several valuable chapters on the fauna. The +Peninsula generally, the interior especially, and the fauna +incidentally, are dealt with in the reports of _A.P. Low_ and _D.I.V. +Eaton_ to the _Geological Survey of Canada, 1893-4-5._ An excellent +general paper on the country is _The Labrador Peninsula, By Robert +Bell_, in _The Scottish Geographical Magazine_ for July, 1895. The N. +of the S.W. part is more particularly described in his _Recent +Explorations to the South of Hudson Bay_ in _The Geographical Journal_ +for July, 1897. The Quebec Labrador is the subject of a recent +Provincial report, _La Côte Nord du Saint Laurent et le Labrador +Canadien--Par Eugène Rouillard: Quebec, 1908--Ministère de la +Colonisation, des Mines et des Pêcheries._ An excellent account of +animal life on the W. half of the Quebec Labrador is to be found in +_Life and Sport on the North Shore--By Napoléon A. Comeau: Quebec, +1909._ The zoology of the Mammals, though not particularly in their +Labrador habitat, is to be found in _Life-Histories of Northern +Mammals--By Ernest Thompson-Seton: London, Constable, 2 Vols., 1910._ +The birds, similarly, in the _Catalogue of Canadian Birds--By John +Macoun and James M. Macoun: Ottawa, Government Printing Bureau, 1909._ +Some books about adjacent areas may be profitably consulted, like +_Newfoundland and its Untrodden Ways--By John Guille Millais,_ and +American official publications, like the _Birds of New York--By Elon +Howard Eaton: Albany, University of the State of New York, 1910._ No. +34 of the _New York Zoological Society Bulletin_--for June, 1909--is a +"Wild-life Preservation Number." The best general history and +present-day summary of the world's fur trade is to be found in a +recent German work, a genuine _Urquellengeschichte._ French and +English translations will presumably appear in due course. The +statistical tables are wonderfully complete. The illustrations are the +least satisfactory feature. This book is--_Aus dem Reiche der Pelze. +Von Emil Brass: Berlin, Im Verlage der Neuen Pelzwaren-Zeitung, 1911._ + + + + + + + + + + +End of Project Gutenberg's Animal Sanctuaries in Labrador, by William Wood + +*** END OF THIS PROJECT GUTENBERG EBOOK ANIMAL SANCTUARIES IN LABRADOR *** + +***** This file should be named 14866-8.txt or 14866-8.zip ***** +This and all associated files of various formats will be found in: + http://www.gutenberg.net/1/4/8/6/14866/ + +Produced by Wallace McLean, Diane Monico and the Online Distributed +Proofreading Team (http://www.pgdp.net). + + +Updated editions will replace the previous one--the old editions +will be renamed. + +Creating the works from public domain print editions means that no +one owns a United States copyright in these works, so the Foundation +(and you!) can copy and distribute it in the United States without +permission and without paying copyright royalties. Special rules, +set forth in the General Terms of Use part of this license, apply to +copying and distributing Project Gutenberg-tm electronic works to +protect the PROJECT GUTENBERG-tm concept and trademark. Project +Gutenberg is a registered trademark, and may not be used if you +charge for the eBooks, unless you receive specific permission. If you +do not charge anything for copies of this eBook, complying with the +rules is very easy. You may use this eBook for nearly any purpose +such as creation of derivative works, reports, performances and +research. They may be modified and printed and given away--you may do +practically ANYTHING with public domain eBooks. Redistribution is +subject to the trademark license, especially commercial +redistribution. + + + +*** START: FULL LICENSE *** + +THE FULL PROJECT GUTENBERG LICENSE +PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK + +To protect the Project Gutenberg-tm mission of promoting the free +distribution of electronic works, by using or distributing this work +(or any other work associated in any way with the phrase "Project +Gutenberg"), you agree to comply with all the terms of the Full Project +Gutenberg-tm License (available with this file or online at +http://gutenberg.net/license). + + +Section 1. General Terms of Use and Redistributing Project Gutenberg-tm +electronic works + +1.A. By reading or using any part of this Project Gutenberg-tm +electronic work, you indicate that you have read, understand, agree to +and accept all the terms of this license and intellectual property +(trademark/copyright) agreement. If you do not agree to abide by all +the terms of this agreement, you must cease using and return or destroy +all copies of Project Gutenberg-tm electronic works in your possession. +If you paid a fee for obtaining a copy of or access to a Project +Gutenberg-tm electronic work and you do not agree to be bound by the +terms of this agreement, you may obtain a refund from the person or +entity to whom you paid the fee as set forth in paragraph 1.E.8. + +1.B. "Project Gutenberg" is a registered trademark. It may only be +used on or associated in any way with an electronic work by people who +agree to be bound by the terms of this agreement. There are a few +things that you can do with most Project Gutenberg-tm electronic works +even without complying with the full terms of this agreement. See +paragraph 1.C below. There are a lot of things you can do with Project +Gutenberg-tm electronic works if you follow the terms of this agreement +and help preserve free future access to Project Gutenberg-tm electronic +works. See paragraph 1.E below. + +1.C. The Project Gutenberg Literary Archive Foundation ("the Foundation" +or PGLAF), owns a compilation copyright in the collection of Project +Gutenberg-tm electronic works. Nearly all the individual works in the +collection are in the public domain in the United States. If an +individual work is in the public domain in the United States and you are +located in the United States, we do not claim a right to prevent you from +copying, distributing, performing, displaying or creating derivative +works based on the work as long as all references to Project Gutenberg +are removed. Of course, we hope that you will support the Project +Gutenberg-tm mission of promoting free access to electronic works by +freely sharing Project Gutenberg-tm works in compliance with the terms of +this agreement for keeping the Project Gutenberg-tm name associated with +the work. You can easily comply with the terms of this agreement by +keeping this work in the same format with its attached full Project +Gutenberg-tm License when you share it without charge with others. + +1.D. The copyright laws of the place where you are located also govern +what you can do with this work. Copyright laws in most countries are in +a constant state of change. If you are outside the United States, check +the laws of your country in addition to the terms of this agreement +before downloading, copying, displaying, performing, distributing or +creating derivative works based on this work or any other Project +Gutenberg-tm work. The Foundation makes no representations concerning +the copyright status of any work in any country outside the United +States. + +1.E. Unless you have removed all references to Project Gutenberg: + +1.E.1. The following sentence, with active links to, or other immediate +access to, the full Project Gutenberg-tm License must appear prominently +whenever any copy of a Project Gutenberg-tm work (any work on which the +phrase "Project Gutenberg" appears, or with which the phrase "Project +Gutenberg" is associated) is accessed, displayed, performed, viewed, +copied or distributed: + +This eBook is for the use of anyone anywhere at no cost and with +almost no restrictions whatsoever. You may copy it, give it away or +re-use it under the terms of the Project Gutenberg License included +with this eBook or online at www.gutenberg.net + +1.E.2. If an individual Project Gutenberg-tm electronic work is derived +from the public domain (does not contain a notice indicating that it is +posted with permission of the copyright holder), the work can be copied +and distributed to anyone in the United States without paying any fees +or charges. If you are redistributing or providing access to a work +with the phrase "Project Gutenberg" associated with or appearing on the +work, you must comply either with the requirements of paragraphs 1.E.1 +through 1.E.7 or obtain permission for the use of the work and the +Project Gutenberg-tm trademark as set forth in paragraphs 1.E.8 or +1.E.9. + +1.E.3. If an individual Project Gutenberg-tm electronic work is posted +with the permission of the copyright holder, your use and distribution +must comply with both paragraphs 1.E.1 through 1.E.7 and any additional +terms imposed by the copyright holder. Additional terms will be linked +to the Project Gutenberg-tm License for all works posted with the +permission of the copyright holder found at the beginning of this work. + +1.E.4. Do not unlink or detach or remove the full Project Gutenberg-tm +License terms from this work, or any files containing a part of this +work or any other work associated with Project Gutenberg-tm. + +1.E.5. Do not copy, display, perform, distribute or redistribute this +electronic work, or any part of this electronic work, without +prominently displaying the sentence set forth in paragraph 1.E.1 with +active links or immediate access to the full terms of the Project +Gutenberg-tm License. + +1.E.6. You may convert to and distribute this work in any binary, +compressed, marked up, nonproprietary or proprietary form, including any +word processing or hypertext form. However, if you provide access to or +distribute copies of a Project Gutenberg-tm work in a format other than +"Plain Vanilla ASCII" or other format used in the official version +posted on the official Project Gutenberg-tm web site (www.gutenberg.net), +you must, at no additional cost, fee or expense to the user, provide a +copy, a means of exporting a copy, or a means of obtaining a copy upon +request, of the work in its original "Plain Vanilla ASCII" or other +form. Any alternate format must include the full Project Gutenberg-tm +License as specified in paragraph 1.E.1. + +1.E.7. Do not charge a fee for access to, viewing, displaying, +performing, copying or distributing any Project Gutenberg-tm works +unless you comply with paragraph 1.E.8 or 1.E.9. + +1.E.8. You may charge a reasonable fee for copies of or providing +access to or distributing Project Gutenberg-tm electronic works provided +that + +- You pay a royalty fee of 20% of the gross profits you derive from + the use of Project Gutenberg-tm works calculated using the method + you already use to calculate your applicable taxes. The fee is + owed to the owner of the Project Gutenberg-tm trademark, but he + has agreed to donate royalties under this paragraph to the + Project Gutenberg Literary Archive Foundation. Royalty payments + must be paid within 60 days following each date on which you + prepare (or are legally required to prepare) your periodic tax + returns. Royalty payments should be clearly marked as such and + sent to the Project Gutenberg Literary Archive Foundation at the + address specified in Section 4, "Information about donations to + the Project Gutenberg Literary Archive Foundation." + +- You provide a full refund of any money paid by a user who notifies + you in writing (or by e-mail) within 30 days of receipt that s/he + does not agree to the terms of the full Project Gutenberg-tm + License. You must require such a user to return or + destroy all copies of the works possessed in a physical medium + and discontinue all use of and all access to other copies of + Project Gutenberg-tm works. + +- You provide, in accordance with paragraph 1.F.3, a full refund of any + money paid for a work or a replacement copy, if a defect in the + electronic work is discovered and reported to you within 90 days + of receipt of the work. + +- You comply with all other terms of this agreement for free + distribution of Project Gutenberg-tm works. + +1.E.9. If you wish to charge a fee or distribute a Project Gutenberg-tm +electronic work or group of works on different terms than are set +forth in this agreement, you must obtain permission in writing from +both the Project Gutenberg Literary Archive Foundation and Michael +Hart, the owner of the Project Gutenberg-tm trademark. Contact the +Foundation as set forth in Section 3 below. + +1.F. + +1.F.1. Project Gutenberg volunteers and employees expend considerable +effort to identify, do copyright research on, transcribe and proofread +public domain works in creating the Project Gutenberg-tm +collection. Despite these efforts, Project Gutenberg-tm electronic +works, and the medium on which they may be stored, may contain +"Defects," such as, but not limited to, incomplete, inaccurate or +corrupt data, transcription errors, a copyright or other intellectual +property infringement, a defective or damaged disk or other medium, a +computer virus, or computer codes that damage or cannot be read by +your equipment. + +1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for the "Right +of Replacement or Refund" described in paragraph 1.F.3, the Project +Gutenberg Literary Archive Foundation, the owner of the Project +Gutenberg-tm trademark, and any other party distributing a Project +Gutenberg-tm electronic work under this agreement, disclaim all +liability to you for damages, costs and expenses, including legal +fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT +LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT EXCEPT THOSE +PROVIDED IN PARAGRAPH F3. YOU AGREE THAT THE FOUNDATION, THE +TRADEMARK OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE +LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE OR +INCIDENTAL DAMAGES EVEN IF YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH +DAMAGE. + +1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you discover a +defect in this electronic work within 90 days of receiving it, you can +receive a refund of the money (if any) you paid for it by sending a +written explanation to the person you received the work from. If you +received the work on a physical medium, you must return the medium with +your written explanation. The person or entity that provided you with +the defective work may elect to provide a replacement copy in lieu of a +refund. If you received the work electronically, the person or entity +providing it to you may choose to give you a second opportunity to +receive the work electronically in lieu of a refund. If the second copy +is also defective, you may demand a refund in writing without further +opportunities to fix the problem. + +1.F.4. Except for the limited right of replacement or refund set forth +in paragraph 1.F.3, this work is provided to you 'AS-IS' WITH NO OTHER +WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +WARRANTIES OF MERCHANTIBILITY OR FITNESS FOR ANY PURPOSE. + +1.F.5. Some states do not allow disclaimers of certain implied +warranties or the exclusion or limitation of certain types of damages. +If any disclaimer or limitation set forth in this agreement violates the +law of the state applicable to this agreement, the agreement shall be +interpreted to make the maximum disclaimer or limitation permitted by +the applicable state law. The invalidity or unenforceability of any +provision of this agreement shall not void the remaining provisions. + +1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation, the +trademark owner, any agent or employee of the Foundation, anyone +providing copies of Project Gutenberg-tm electronic works in accordance +with this agreement, and any volunteers associated with the production, +promotion and distribution of Project Gutenberg-tm electronic works, +harmless from all liability, costs and expenses, including legal fees, +that arise directly or indirectly from any of the following which you do +or cause to occur: (a) distribution of this or any Project Gutenberg-tm +work, (b) alteration, modification, or additions or deletions to any +Project Gutenberg-tm work, and (c) any Defect you cause. + + +Section 2. Information about the Mission of Project Gutenberg-tm + +Project Gutenberg-tm is synonymous with the free distribution of +electronic works in formats readable by the widest variety of computers +including obsolete, old, middle-aged and new computers. It exists +because of the efforts of hundreds of volunteers and donations from +people in all walks of life. + +Volunteers and financial support to provide volunteers with the +assistance they need, is critical to reaching Project Gutenberg-tm's +goals and ensuring that the Project Gutenberg-tm collection will +remain freely available for generations to come. In 2001, the Project +Gutenberg Literary Archive Foundation was created to provide a secure +and permanent future for Project Gutenberg-tm and future generations. +To learn more about the Project Gutenberg Literary Archive Foundation +and how your efforts and donations can help, see Sections 3 and 4 +and the Foundation web page at http://www.pglaf.org. + + +Section 3. Information about the Project Gutenberg Literary Archive +Foundation + +The Project Gutenberg Literary Archive Foundation is a non profit +501(c)(3) educational corporation organized under the laws of the +state of Mississippi and granted tax exempt status by the Internal +Revenue Service. The Foundation's EIN or federal tax identification +number is 64-6221541. Its 501(c)(3) letter is posted at +http://pglaf.org/fundraising. Contributions to the Project Gutenberg +Literary Archive Foundation are tax deductible to the full extent +permitted by U.S. federal laws and your state's laws. + +The Foundation's principal office is located at 4557 Melan Dr. S. +Fairbanks, AK, 99712., but its volunteers and employees are scattered +throughout numerous locations. Its business office is located at +809 North 1500 West, Salt Lake City, UT 84116, (801) 596-1887, email +business@pglaf.org. Email contact links and up to date contact +information can be found at the Foundation's web site and official +page at http://pglaf.org + +For additional contact information: + Dr. Gregory B. Newby + Chief Executive and Director + gbnewby@pglaf.org + + +Section 4. Information about Donations to the Project Gutenberg +Literary Archive Foundation + +Project Gutenberg-tm depends upon and cannot survive without wide +spread public support and donations to carry out its mission of +increasing the number of public domain and licensed works that can be +freely distributed in machine readable form accessible by the widest +array of equipment including outdated equipment. Many small donations +($1 to $5,000) are particularly important to maintaining tax exempt +status with the IRS. + +The Foundation is committed to complying with the laws regulating +charities and charitable donations in all 50 states of the United +States. Compliance requirements are not uniform and it takes a +considerable effort, much paperwork and many fees to meet and keep up +with these requirements. We do not solicit donations in locations +where we have not received written confirmation of compliance. To +SEND DONATIONS or determine the status of compliance for any +particular state visit http://pglaf.org + +While we cannot and do not solicit contributions from states where we +have not met the solicitation requirements, we know of no prohibition +against accepting unsolicited donations from donors in such states who +approach us with offers to donate. + +International donations are gratefully accepted, but we cannot make +any statements concerning tax treatment of donations received from +outside the United States. U.S. laws alone swamp our small staff. + +Please check the Project Gutenberg Web pages for current donation +methods and addresses. Donations are accepted in a number of other +ways including including checks, online payments and credit card +donations. To donate, please visit: http://pglaf.org/donate + + +Section 5. General Information About Project Gutenberg-tm electronic +works. + +Professor Michael S. Hart is the originator of the Project Gutenberg-tm +concept of a library of electronic works that could be freely shared +with anyone. For thirty years, he produced and distributed Project +Gutenberg-tm eBooks with only a loose network of volunteer support. + + +Project Gutenberg-tm eBooks are often created from several printed +editions, all of which are confirmed as Public Domain in the U.S. +unless a copyright notice is included. Thus, we do not necessarily +keep eBooks in compliance with any particular paper edition. + + +Most people start at our Web site which has the main PG search facility: + + http://www.gutenberg.net + +This Web site includes information about Project Gutenberg-tm, +including how to make donations to the Project Gutenberg Literary +Archive Foundation, how to help produce our new eBooks, and how to +subscribe to our email newsletter to hear about new eBooks. \ No newline at end of file diff --git a/src/main/resources/testFile.txt b/src/main/resources/testFile.txt new file mode 100644 index 0000000..b3d51b2 --- /dev/null +++ b/src/main/resources/testFile.txt @@ -0,0 +1 @@ +The lab is interesting. Getting the lab done will help me. \ No newline at end of file diff --git a/src/test/java/io/zipcoder/WCTest.java b/src/test/java/io/zipcoder/WCTest.java index 895e831..5e07f7d 100644 --- a/src/test/java/io/zipcoder/WCTest.java +++ b/src/test/java/io/zipcoder/WCTest.java @@ -3,9 +3,20 @@ import org.junit.Assert; import org.junit.Test; -import java.util.ArrayList; -import java.util.Arrays; - public class WCTest { + WC testWC = new WC( WC.class.getResource("/testFile.txt").getFile()); + @Test + public void checkIfPrints(){ + String expected = "Total Words: appears 11 times\n" + "lab: appears 2 times\n" + "the: appears 2 times\n" + "done: appears 1 times\n" + + "getting: appears 1 times\n" + "help: appears 1 times\n" + "interesting: appears 1 times\n" + + "is: appears 1 times\n" + "me: appears 1 times\n" + "will: appears 1 times\n"; + String actual = testWC.printMap(); + Assert.assertEquals(expected, actual); + } + @Test + public void SanctuaryTest(){ + WC bookWC = new WC(WC.class.getResource("/someTextFile.txt").getFile()); + System.out.println(bookWC.printMap()); + } } \ No newline at end of file From 4592ead7e48e8ed2d3beed6df59af1a4710c52cb Mon Sep 17 00:00:00 2001 From: CWinarski Date: Thu, 15 Mar 2018 19:51:06 -0400 Subject: [PATCH 5/5] Refactored parens checker and used regex --- src/main/java/io/zipcoder/ParenChecker.java | 49 ++++++------------- src/main/java/io/zipcoder/WC.java | 1 + .../java/io/zipcoder/ParenCheckerTest.java | 27 ++++++---- 3 files changed, 34 insertions(+), 43 deletions(-) diff --git a/src/main/java/io/zipcoder/ParenChecker.java b/src/main/java/io/zipcoder/ParenChecker.java index fba90be..5124fdf 100644 --- a/src/main/java/io/zipcoder/ParenChecker.java +++ b/src/main/java/io/zipcoder/ParenChecker.java @@ -1,47 +1,28 @@ package io.zipcoder; - -import java.util.HashMap; import java.util.Stack; -public class ParenChecker{ +public class ParenChecker { Stack parensStack = new Stack(); - HashMap openClosingPairs = new HashMap(); - - public boolean verifyParensArePaired(String input){ - for(int i = 0; i < input.length(); i++){ - char inputCharacter = input.charAt(i); - if (inputCharacter == '('){ - parensStack.push(inputCharacter); - }else if (inputCharacter == ')' && parensStack.isEmpty() || parensStack.peek() != '('){ - return false; - } else if (inputCharacter == ')' && parensStack.peek() == '('){ - parensStack.pop(); - } - } - return parensStack.isEmpty(); - } - - public boolean verifyOpeningCharactersHaveAClosingOne(String input){ - openClosingPairs.put('(', ')'); - openClosingPairs.put('{', '}'); - openClosingPairs.put('[', ']'); - openClosingPairs.put('<', '>'); - openClosingPairs.put('"', '"'); - openClosingPairs.put('\'', '\''); - - for(int i = 0; i < input.length(); i++){ - Character inputCharacter = input.charAt(i); - if(openClosingPairs.containsKey(inputCharacter)){ + public boolean verifyOpeningCharactersHaveAClosingOne(String input) { + String changedInput = input.replaceAll("[\\(\\{\\[\\<]","("); + changedInput = changedInput.replaceAll("[\\)\\}\\]\\>]", ")"); + changedInput = changedInput.replaceAll("[\\\"\\']", "^"); + for (int i = 0; i < input.length(); i++) { + char inputCharacter = changedInput.charAt(i); + if (! parensStack.isEmpty() && ((inputCharacter == ')' || inputCharacter == '^') && (parensStack.peek() == '(' || parensStack.peek() == '^'))) { + parensStack.pop(); + } + else if (inputCharacter == '(' || inputCharacter == '^') { parensStack.push(inputCharacter); - } else if (openClosingPairs.containsValue(parensStack.peek()) && parensStack.isEmpty()){ + } else if (inputCharacter == ')' || parensStack.peek() != '(') { return false; - }else if (inputCharacter == openClosingPairs.get(parensStack.peek())){ - parensStack.pop(); } } return parensStack.isEmpty(); + + } } -} + diff --git a/src/main/java/io/zipcoder/WC.java b/src/main/java/io/zipcoder/WC.java index f2c021c..3a90afa 100644 --- a/src/main/java/io/zipcoder/WC.java +++ b/src/main/java/io/zipcoder/WC.java @@ -66,6 +66,7 @@ public String printMap(){ printedList.append(" times\n"); } return printedList.toString(); + } diff --git a/src/test/java/io/zipcoder/ParenCheckerTest.java b/src/test/java/io/zipcoder/ParenCheckerTest.java index b6cd6e9..b4fa0a7 100644 --- a/src/test/java/io/zipcoder/ParenCheckerTest.java +++ b/src/test/java/io/zipcoder/ParenCheckerTest.java @@ -11,7 +11,7 @@ public void verifyParensArePairedTest(){ String test = "()"; boolean expected = true; //When - boolean actual = parenCheckerTest.verifyParensArePaired(test); + boolean actual = parenCheckerTest.verifyOpeningCharactersHaveAClosingOne(test); Assert.assertEquals(expected,actual); } @@ -21,7 +21,7 @@ public void verifyParensArePairedTest2(){ String test = "(("; boolean expected = false; //When - boolean actual = parenCheckerTest.verifyParensArePaired(test); + boolean actual = parenCheckerTest.verifyOpeningCharactersHaveAClosingOne(test); Assert.assertEquals(expected,actual); } @@ -31,7 +31,7 @@ public void verifyParensArePairedTest3(){ String test = ")("; boolean expected = false; //When - boolean actual = parenCheckerTest.verifyParensArePaired(test); + boolean actual = parenCheckerTest.verifyOpeningCharactersHaveAClosingOne(test); Assert.assertEquals(expected,actual); } @@ -41,7 +41,7 @@ public void verifyParensArePairedTest4(){ String test = "("; boolean expected = false; //When - boolean actual = parenCheckerTest.verifyParensArePaired(test); + boolean actual = parenCheckerTest.verifyOpeningCharactersHaveAClosingOne(test); Assert.assertEquals(expected,actual); } @@ -55,7 +55,7 @@ public void verifyParenthesesHaveOpenAndClosingOneTest(){ Assert.assertEquals(expected,actual); } @Test - public void verifyBracketsHaveOpenAndClosingOneTest(){ + public void verifyCurlyBraceHaveOpenAndClosingOneTest(){ //Given String test = "{}"; boolean expected = true; @@ -63,11 +63,20 @@ public void verifyBracketsHaveOpenAndClosingOneTest(){ boolean actual = parenCheckerTest.verifyOpeningCharactersHaveAClosingOne(test); Assert.assertEquals(expected,actual); } + @Test + public void verifyBracketHaveOpenAndClosingOneTest(){ + //Given + String test = "[]"; + boolean expected = true; + //When + boolean actual = parenCheckerTest.verifyOpeningCharactersHaveAClosingOne(test); + Assert.assertEquals(expected,actual); + } @Test public void verifyDiamondsHaveOpenAndClosingOneTest(){ //Given - String test = "[]"; + String test = "<>"; boolean expected = true; //When boolean actual = parenCheckerTest.verifyOpeningCharactersHaveAClosingOne(test); @@ -77,7 +86,7 @@ public void verifyDiamondsHaveOpenAndClosingOneTest(){ @Test public void verifyDiamondsHaveOpenAndClosingOneTestFail(){ //Given - String test = "["; + String test = "<"; boolean expected = false; //When boolean actual = parenCheckerTest.verifyOpeningCharactersHaveAClosingOne(test); @@ -87,7 +96,7 @@ public void verifyDiamondsHaveOpenAndClosingOneTestFail(){ @Test public void verifyDoubleQuotesHaveOpenAndClosingOneTest(){ //Given - String test = "\"Hi\""; + String test = "\"\""; boolean expected = true; //When boolean actual = parenCheckerTest.verifyOpeningCharactersHaveAClosingOne(test); @@ -97,7 +106,7 @@ public void verifyDoubleQuotesHaveOpenAndClosingOneTest(){ @Test public void verifySingleQuotesHaveOpenAndClosingOneTest(){ //Given - String test = "'Merp'"; + String test = "''"; boolean expected = true; //When boolean actual = parenCheckerTest.verifyOpeningCharactersHaveAClosingOne(test);