From 08fbcde2a51f6409bdcf307d0025639cdebef1fb Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Tue, 5 Feb 2019 13:31:41 -0800 Subject: [PATCH 1/5] initial commit - package created - Main and Words class created --- .gitignore | 1 + .idea/vcs.xml | 6 ++++++ src/wordCount/Main.java | 11 +++++++++++ src/wordCount/Words.java | 5 +++++ 4 files changed, 23 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/vcs.xml create mode 100644 src/wordCount/Main.java create mode 100644 src/wordCount/Words.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62c8935 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/wordCount/Main.java b/src/wordCount/Main.java new file mode 100644 index 0000000..67d92b8 --- /dev/null +++ b/src/wordCount/Main.java @@ -0,0 +1,11 @@ +package wordCount; + +public class Main { + public static void main(String[] args){ + + + + + + } +} \ No newline at end of file diff --git a/src/wordCount/Words.java b/src/wordCount/Words.java new file mode 100644 index 0000000..8b9f7fe --- /dev/null +++ b/src/wordCount/Words.java @@ -0,0 +1,5 @@ +package wordCount; + +public class Words { + private String = "Preamble Whereas recognition of the inherent dignity and of the equal and inalienable rights of all members of the human family is the foundation of freedom, justice and peace in the world, Whereas disregard and contempt for human rights have resulted in barbarous acts which have outraged the conscience of mankind, and the advent of a world in which human beings shall enjoy freedom of speech and belief and freedom from fear and want has been proclaimed as the highest aspiration of the common people, Whereas it is essential, if man is not to be compelled to have recourse, as a last resort, to rebellion against tyranny and oppression, that human rights should be protected by the rule of law, Whereas it is essential to promote the development of friendly relations between nations, Whereas the peoples of the United Nations have in the Charter reaffirmed their faith in fundamental human rights, in the dignity and worth of the human person and in the equal rights of men and women and have determined to promote social progress and better standards of life in larger freedom, Whereas Member States have pledged themselves to achieve, in co-operation with the United Nations, the promotion of universal respect for and observance of human rights and fundamental freedoms, Whereas a common understanding of these rights and freedoms is of the greatest importance for the full realization of this pledge, Now, Therefore THE GENERAL ASSEMBLY proclaims THIS UNIVERSAL DECLARATION OF HUMAN RIGHTS as a common standard of achievement for all peoples and all nations, to the end that every individual and every organ of society, keeping this Declaration constantly in mind, shall strive by teaching and education to promote respect for these rights and freedoms and by progressive measures, national and international, to secure their universal and effective recognition and observance, both among the peoples of Member States themselves and among the peoples of territories under their jurisdiction. Article 1. All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood. Article 2. Everyone is entitled to all the rights and freedoms set forth in this Declaration, without distinction of any kind, such as race, colour, sex, language, religion, political or other opinion, national or social origin, property, birth or other status. Furthermore, no distinction shall be made on the basis of the political, jurisdictional or international status of the country or territory to which a person belongs, whether it be independent, trust, non-self-governing or under any other limitation of sovereignty. Article 3. Everyone has the right to life, liberty and security of person. Article 4. No one shall be held in slavery or servitude; slavery and the slave trade shall be prohibited in all their forms. Article 5. No one shall be subjected to torture or to cruel, inhuman or degrading treatment or punishment. Article 6. Everyone has the right to recognition everywhere as a person before the law. Article 7. All are equal before the law and are entitled without any discrimination to equal protection of the law. All are entitled to equal protection against any discrimination in violation of this Declaration and against any incitement to such discrimination. Article 8. Everyone has the right to an effective remedy by the competent national tribunals for acts violating the fundamental rights granted him by the constitution or by law. Article 9. No one shall be subjected to arbitrary arrest, detention or exile. Article 10. Everyone is entitled in full equality to a fair and public hearing by an independent and impartial tribunal, in the determination of his rights and obligations and of any criminal charge against him. Article 11. (1) Everyone charged with a penal offence has the right to be presumed innocent until proved guilty according to law in a public trial at which he has had all the guarantees necessary for his defence. (2) No one shall be held guilty of any penal offence on account of any act or omission which did not constitute a penal offence, under national or international law, at the time when it was committed. Nor shall a heavier penalty be imposed than the one that was applicable at the time the penal offence was committed. Article 12. No one shall be subjected to arbitrary interference with his privacy, family, home or correspondence, nor to attacks upon his honour and reputation. Everyone has the right to the protection of the law against such interference or attacks. Article 13. (1) Everyone has the right to freedom of movement and residence within the borders of each state. (2) Everyone has the right to leave any country, including his own, and to return to his country. Article 14. (1) Everyone has the right to seek and to enjoy in other countries asylum from persecution. (2) This right may not be invoked in the case of prosecutions genuinely arising from non-political crimes or from acts contrary to the purposes and principles of the United Nations. Article 15. (1) Everyone has the right to a nationality. (2) No one shall be arbitrarily deprived of his nationality nor denied the right to change his nationality. Article 16. (1) Men and women of full age, without any limitation due to race, nationality or religion, have the right to marry and to found a family. They are entitled to equal rights as to marriage, during marriage and at its dissolution. (2) Marriage shall be entered into only with the free and full consent of the intending spouses. (3) The family is the natural and fundamental group unit of society and is entitled to protection by society and the State. Article 17. (1) Everyone has the right to own property alone as well as in association with others. (2) No one shall be arbitrarily deprived of his property. Article 18. Everyone has the right to freedom of thought, conscience and religion; this right includes freedom to change his religion or belief, and freedom, either alone or in community with others and in public or private, to manifest his religion or belief in teaching, practice, worship and observance. Article 19. Everyone has the right to freedom of opinion and expression; this right includes freedom to hold opinions without interference and to seek, receive and impart information and ideas through any media and regardless of frontiers. Article 20. (1) Everyone has the right to freedom of peaceful assembly and association. (2) No one may be compelled to belong to an association. Article 21. (1) Everyone has the right to take part in the government of his country, directly or through freely chosen representatives. (2) Everyone has the right of equal access to public service in his country. (3) The will of the people shall be the basis of the authority of government; this will shall be expressed in periodic and genuine elections which shall be by universal and equal suffrage and shall be held by secret vote or by equivalent free voting procedures. Article 22. Everyone, as a member of society, has the right to social security and is entitled to realization, through national effort and international co-operation and in accordance with the organization and resources of each State, of the economic, social and cultural rights indispensable for his dignity and the free development of his personality. Article 23. (1) Everyone has the right to work, to free choice of employment, to just and favourable conditions of work and to protection against unemployment. (2) Everyone, without any discrimination, has the right to equal pay for equal work. (3) Everyone who works has the right to just and favourable remuneration ensuring for himself and his family an existence worthy of human dignity, and supplemented, if necessary, by other means of social protection. (4) Everyone has the right to form and to join trade unions for the protection of his interests. Article 24. Everyone has the right to rest and leisure, including reasonable limitation of working hours and periodic holidays with pay. Article 25. (1) Everyone has the right to a standard of living adequate for the health and well-being of himself and of his family, including food, clothing, housing and medical care and necessary social services, and the right to security in the event of unemployment, sickness, disability, widowhood, old age or other lack of livelihood in circumstances beyond his control. (2) Motherhood and childhood are entitled to special care and assistance. All children, whether born in or out of wedlock, shall enjoy the same social protection. Article 26. (1) Everyone has the right to education. Education shall be free, at least in the elementary and fundamental stages. Elementary education shall be compulsory. Technical and professional education shall be made generally available and higher education shall be equally accessible to all on the basis of merit. (2) Education shall be directed to the full development of the human personality and to the strengthening of respect for human rights and fundamental freedoms. It shall promote understanding, tolerance and friendship among all nations, racial or religious groups, and shall further the activities of the United Nations for the maintenance of peace. (3) Parents have a prior right to choose the kind of education that shall be given to their children. Article 27. (1) Everyone has the right freely to participate in the cultural life of the community, to enjoy the arts and to share in scientific advancement and its benefits. (2) Everyone has the right to the protection of the moral and material interests resulting from any scientific, literary or artistic production of which he is the author. Article 28. Everyone is entitled to a social and international order in which the rights and freedoms set forth in this Declaration can be fully realized. Article 29. (1) Everyone has duties to the community in which alone the free and full development of his personality is possible. (2) In the exercise of his rights and freedoms, everyone shall be subject only to such limitations as are determined by law solely for the purpose of securing due recognition and respect for the rights and freedoms of others and of meeting the just requirements of morality, public order and the general welfare in a democratic society. (3) These rights and freedoms may in no case be exercised contrary to the purposes and principles of the United Nations. Article 30. Nothing in this Declaration may be interpreted as implying for any State, group or person any right to engage in any activity or to perform any act aimed at the destruction of any of the rights and freedoms set forth herein." +} \ No newline at end of file From b2bbe547bc57321562b73db75bac82d813102bc1 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Tue, 5 Feb 2019 15:02:59 -0800 Subject: [PATCH 2/5] feat: add and test word strip and split --- src/wordCount/Main.java | 14 +++++++++----- src/wordCount/Words.java | 5 ----- 2 files changed, 9 insertions(+), 10 deletions(-) delete mode 100644 src/wordCount/Words.java diff --git a/src/wordCount/Main.java b/src/wordCount/Main.java index 67d92b8..4e1dd2a 100644 --- a/src/wordCount/Main.java +++ b/src/wordCount/Main.java @@ -1,11 +1,15 @@ -package wordCount; +package com.lambdaschool; public class Main { - public static void main(String[] args){ - - + public static void main(String[] args) { + String article = "Preamble Whereas recognition of the inherent dignity and of the equal and inalienable rights of all members of the human family is the foundation of freedom, justice and peace in the world, Whereas disregard and contempt for human rights have resulted in barbarous acts which have outraged the conscience of mankind, and the advent of a world in which human beings shall enjoy freedom of speech and belief and freedom from fear and want has been proclaimed as the highest aspiration of the common people, Whereas it is essential, if man is not to be compelled to have recourse, as a last resort, to rebellion against tyranny and oppression, that human rights should be protected by the rule of law, Whereas it is essential to promote the development of friendly relations between nations, Whereas the peoples of the United Nations have in the Charter reaffirmed their faith in fundamental human rights, in the dignity and worth of the human person and in the equal rights of men and women and have determined to promote social progress and better standards of life in larger freedom, Whereas Member States have pledged themselves to achieve, in co-operation with the United Nations, the promotion of universal respect for and observance of human rights and fundamental freedoms, Whereas a common understanding of these rights and freedoms is of the greatest importance for the full realization of this pledge, Now, Therefore THE GENERAL ASSEMBLY proclaims THIS UNIVERSAL DECLARATION OF HUMAN RIGHTS as a common standard of achievement for all peoples and all nations, to the end that every individual and every organ of society, keeping this Declaration constantly in mind, shall strive by teaching and education to promote respect for these rights and freedoms and by progressive measures, national and international, to secure their universal and effective recognition and observance, both among the peoples of Member States themselves and among the peoples of territories under their jurisdiction. Article 1. All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood. Article 2. Everyone is entitled to all the rights and freedoms set forth in this Declaration, without distinction of any kind, such as race, colour, sex, language, religion, political or other opinion, national or social origin, property, birth or other status. Furthermore, no distinction shall be made on the basis of the political, jurisdictional or international status of the country or territory to which a person belongs, whether it be independent, trust, non-self-governing or under any other limitation of sovereignty. Article 3. Everyone has the right to life, liberty and security of person. Article 4. No one shall be held in slavery or servitude; slavery and the slave trade shall be prohibited in all their forms. Article 5. No one shall be subjected to torture or to cruel, inhuman or degrading treatment or punishment. Article 6. Everyone has the right to recognition everywhere as a person before the law. Article 7. All are equal before the law and are entitled without any discrimination to equal protection of the law. All are entitled to equal protection against any discrimination in violation of this Declaration and against any incitement to such discrimination. Article 8. Everyone has the right to an effective remedy by the competent national tribunals for acts violating the fundamental rights granted him by the constitution or by law. Article 9. No one shall be subjected to arbitrary arrest, detention or exile. Article 10. Everyone is entitled in full equality to a fair and public hearing by an independent and impartial tribunal, in the determination of his rights and obligations and of any criminal charge against him. Article 11. (1) Everyone charged with a penal offence has the right to be presumed innocent until proved guilty according to law in a public trial at which he has had all the guarantees necessary for his defence. (2) No one shall be held guilty of any penal offence on account of any act or omission which did not constitute a penal offence, under national or international law, at the time when it was committed. Nor shall a heavier penalty be imposed than the one that was applicable at the time the penal offence was committed. Article 12. No one shall be subjected to arbitrary interference with his privacy, family, home or correspondence, nor to attacks upon his honour and reputation. Everyone has the right to the protection of the law against such interference or attacks. Article 13. (1) Everyone has the right to freedom of movement and residence within the borders of each state. (2) Everyone has the right to leave any country, including his own, and to return to his country. Article 14. (1) Everyone has the right to seek and to enjoy in other countries asylum from persecution. (2) This right may not be invoked in the case of prosecutions genuinely arising from non-political crimes or from acts contrary to the purposes and principles of the United Nations. Article 15. (1) Everyone has the right to a nationality. (2) No one shall be arbitrarily deprived of his nationality nor denied the right to change his nationality. Article 16. (1) Men and women of full age, without any limitation due to race, nationality or religion, have the right to marry and to found a family. They are entitled to equal rights as to marriage, during marriage and at its dissolution. (2) Marriage shall be entered into only with the free and full consent of the intending spouses. (3) The family is the natural and fundamental group unit of society and is entitled to protection by society and the State. Article 17. (1) Everyone has the right to own property alone as well as in association with others. (2) No one shall be arbitrarily deprived of his property. Article 18. Everyone has the right to freedom of thought, conscience and religion; this right includes freedom to change his religion or belief, and freedom, either alone or in community with others and in public or private, to manifest his religion or belief in teaching, practice, worship and observance. Article 19. Everyone has the right to freedom of opinion and expression; this right includes freedom to hold opinions without interference and to seek, receive and impart information and ideas through any media and regardless of frontiers. Article 20. (1) Everyone has the right to freedom of peaceful assembly and association. (2) No one may be compelled to belong to an association. Article 21. (1) Everyone has the right to take part in the government of his country, directly or through freely chosen representatives. (2) Everyone has the right of equal access to public service in his country. (3) The will of the people shall be the basis of the authority of government; this will shall be expressed in periodic and genuine elections which shall be by universal and equal suffrage and shall be held by secret vote or by equivalent free voting procedures. Article 22. Everyone, as a member of society, has the right to social security and is entitled to realization, through national effort and international co-operation and in accordance with the organization and resources of each State, of the economic, social and cultural rights indispensable for his dignity and the free development of his personality. Article 23. (1) Everyone has the right to work, to free choice of employment, to just and favourable conditions of work and to protection against unemployment. (2) Everyone, without any discrimination, has the right to equal pay for equal work. (3) Everyone who works has the right to just and favourable remuneration ensuring for himself and his family an existence worthy of human dignity, and supplemented, if necessary, by other means of social protection. (4) Everyone has the right to form and to join trade unions for the protection of his interests. Article 24. Everyone has the right to rest and leisure, including reasonable limitation of working hours and periodic holidays with pay. Article 25. (1) Everyone has the right to a standard of living adequate for the health and well-being of himself and of his family, including food, clothing, housing and medical care and necessary social services, and the right to security in the event of unemployment, sickness, disability, widowhood, old age or other lack of livelihood in circumstances beyond his control. (2) Motherhood and childhood are entitled to special care and assistance. All children, whether born in or out of wedlock, shall enjoy the same social protection. Article 26. (1) Everyone has the right to education. Education shall be free, at least in the elementary and fundamental stages. Elementary education shall be compulsory. Technical and professional education shall be made generally available and higher education shall be equally accessible to all on the basis of merit. (2) Education shall be directed to the full development of the human personality and to the strengthening of respect for human rights and fundamental freedoms. It shall promote understanding, tolerance and friendship among all nations, racial or religious groups, and shall further the activities of the United Nations for the maintenance of peace. (3) Parents have a prior right to choose the kind of education that shall be given to their children. Article 27. (1) Everyone has the right freely to participate in the cultural life of the community, to enjoy the arts and to share in scientific advancement and its benefits. (2) Everyone has the right to the protection of the moral and material interests resulting from any scientific, literary or artistic production of which he is the author. Article 28. Everyone is entitled to a social and international order in which the rights and freedoms set forth in this Declaration can be fully realized. Article 29. (1) Everyone has duties to the community in which alone the free and full development of his personality is possible. (2) In the exercise of his rights and freedoms, everyone shall be subject only to such limitations as are determined by law solely for the purpose of securing due recognition and respect for the rights and freedoms of others and of meeting the just requirements of morality, public order and the general welfare in a democratic society. (3) These rights and freedoms may in no case be exercised contrary to the purposes and principles of the United Nations. Article 30. Nothing in this Declaration may be interpreted as implying for any State, group or person any right to engage in any activity or to perform any act aimed at the destruction of any of the rights and freedoms set forth herein."; + // strip punctuations and split by blanks + String[] words = article.replaceAll("[[\\.\\?\\!\\,\\;\\:\\{\\}\\(\\)\\']]", "").split(" +"); + for (String s : words) { + System.out.println(s); + } } -} \ No newline at end of file +} diff --git a/src/wordCount/Words.java b/src/wordCount/Words.java deleted file mode 100644 index 8b9f7fe..0000000 --- a/src/wordCount/Words.java +++ /dev/null @@ -1,5 +0,0 @@ -package wordCount; - -public class Words { - private String = "Preamble Whereas recognition of the inherent dignity and of the equal and inalienable rights of all members of the human family is the foundation of freedom, justice and peace in the world, Whereas disregard and contempt for human rights have resulted in barbarous acts which have outraged the conscience of mankind, and the advent of a world in which human beings shall enjoy freedom of speech and belief and freedom from fear and want has been proclaimed as the highest aspiration of the common people, Whereas it is essential, if man is not to be compelled to have recourse, as a last resort, to rebellion against tyranny and oppression, that human rights should be protected by the rule of law, Whereas it is essential to promote the development of friendly relations between nations, Whereas the peoples of the United Nations have in the Charter reaffirmed their faith in fundamental human rights, in the dignity and worth of the human person and in the equal rights of men and women and have determined to promote social progress and better standards of life in larger freedom, Whereas Member States have pledged themselves to achieve, in co-operation with the United Nations, the promotion of universal respect for and observance of human rights and fundamental freedoms, Whereas a common understanding of these rights and freedoms is of the greatest importance for the full realization of this pledge, Now, Therefore THE GENERAL ASSEMBLY proclaims THIS UNIVERSAL DECLARATION OF HUMAN RIGHTS as a common standard of achievement for all peoples and all nations, to the end that every individual and every organ of society, keeping this Declaration constantly in mind, shall strive by teaching and education to promote respect for these rights and freedoms and by progressive measures, national and international, to secure their universal and effective recognition and observance, both among the peoples of Member States themselves and among the peoples of territories under their jurisdiction. Article 1. All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood. Article 2. Everyone is entitled to all the rights and freedoms set forth in this Declaration, without distinction of any kind, such as race, colour, sex, language, religion, political or other opinion, national or social origin, property, birth or other status. Furthermore, no distinction shall be made on the basis of the political, jurisdictional or international status of the country or territory to which a person belongs, whether it be independent, trust, non-self-governing or under any other limitation of sovereignty. Article 3. Everyone has the right to life, liberty and security of person. Article 4. No one shall be held in slavery or servitude; slavery and the slave trade shall be prohibited in all their forms. Article 5. No one shall be subjected to torture or to cruel, inhuman or degrading treatment or punishment. Article 6. Everyone has the right to recognition everywhere as a person before the law. Article 7. All are equal before the law and are entitled without any discrimination to equal protection of the law. All are entitled to equal protection against any discrimination in violation of this Declaration and against any incitement to such discrimination. Article 8. Everyone has the right to an effective remedy by the competent national tribunals for acts violating the fundamental rights granted him by the constitution or by law. Article 9. No one shall be subjected to arbitrary arrest, detention or exile. Article 10. Everyone is entitled in full equality to a fair and public hearing by an independent and impartial tribunal, in the determination of his rights and obligations and of any criminal charge against him. Article 11. (1) Everyone charged with a penal offence has the right to be presumed innocent until proved guilty according to law in a public trial at which he has had all the guarantees necessary for his defence. (2) No one shall be held guilty of any penal offence on account of any act or omission which did not constitute a penal offence, under national or international law, at the time when it was committed. Nor shall a heavier penalty be imposed than the one that was applicable at the time the penal offence was committed. Article 12. No one shall be subjected to arbitrary interference with his privacy, family, home or correspondence, nor to attacks upon his honour and reputation. Everyone has the right to the protection of the law against such interference or attacks. Article 13. (1) Everyone has the right to freedom of movement and residence within the borders of each state. (2) Everyone has the right to leave any country, including his own, and to return to his country. Article 14. (1) Everyone has the right to seek and to enjoy in other countries asylum from persecution. (2) This right may not be invoked in the case of prosecutions genuinely arising from non-political crimes or from acts contrary to the purposes and principles of the United Nations. Article 15. (1) Everyone has the right to a nationality. (2) No one shall be arbitrarily deprived of his nationality nor denied the right to change his nationality. Article 16. (1) Men and women of full age, without any limitation due to race, nationality or religion, have the right to marry and to found a family. They are entitled to equal rights as to marriage, during marriage and at its dissolution. (2) Marriage shall be entered into only with the free and full consent of the intending spouses. (3) The family is the natural and fundamental group unit of society and is entitled to protection by society and the State. Article 17. (1) Everyone has the right to own property alone as well as in association with others. (2) No one shall be arbitrarily deprived of his property. Article 18. Everyone has the right to freedom of thought, conscience and religion; this right includes freedom to change his religion or belief, and freedom, either alone or in community with others and in public or private, to manifest his religion or belief in teaching, practice, worship and observance. Article 19. Everyone has the right to freedom of opinion and expression; this right includes freedom to hold opinions without interference and to seek, receive and impart information and ideas through any media and regardless of frontiers. Article 20. (1) Everyone has the right to freedom of peaceful assembly and association. (2) No one may be compelled to belong to an association. Article 21. (1) Everyone has the right to take part in the government of his country, directly or through freely chosen representatives. (2) Everyone has the right of equal access to public service in his country. (3) The will of the people shall be the basis of the authority of government; this will shall be expressed in periodic and genuine elections which shall be by universal and equal suffrage and shall be held by secret vote or by equivalent free voting procedures. Article 22. Everyone, as a member of society, has the right to social security and is entitled to realization, through national effort and international co-operation and in accordance with the organization and resources of each State, of the economic, social and cultural rights indispensable for his dignity and the free development of his personality. Article 23. (1) Everyone has the right to work, to free choice of employment, to just and favourable conditions of work and to protection against unemployment. (2) Everyone, without any discrimination, has the right to equal pay for equal work. (3) Everyone who works has the right to just and favourable remuneration ensuring for himself and his family an existence worthy of human dignity, and supplemented, if necessary, by other means of social protection. (4) Everyone has the right to form and to join trade unions for the protection of his interests. Article 24. Everyone has the right to rest and leisure, including reasonable limitation of working hours and periodic holidays with pay. Article 25. (1) Everyone has the right to a standard of living adequate for the health and well-being of himself and of his family, including food, clothing, housing and medical care and necessary social services, and the right to security in the event of unemployment, sickness, disability, widowhood, old age or other lack of livelihood in circumstances beyond his control. (2) Motherhood and childhood are entitled to special care and assistance. All children, whether born in or out of wedlock, shall enjoy the same social protection. Article 26. (1) Everyone has the right to education. Education shall be free, at least in the elementary and fundamental stages. Elementary education shall be compulsory. Technical and professional education shall be made generally available and higher education shall be equally accessible to all on the basis of merit. (2) Education shall be directed to the full development of the human personality and to the strengthening of respect for human rights and fundamental freedoms. It shall promote understanding, tolerance and friendship among all nations, racial or religious groups, and shall further the activities of the United Nations for the maintenance of peace. (3) Parents have a prior right to choose the kind of education that shall be given to their children. Article 27. (1) Everyone has the right freely to participate in the cultural life of the community, to enjoy the arts and to share in scientific advancement and its benefits. (2) Everyone has the right to the protection of the moral and material interests resulting from any scientific, literary or artistic production of which he is the author. Article 28. Everyone is entitled to a social and international order in which the rights and freedoms set forth in this Declaration can be fully realized. Article 29. (1) Everyone has duties to the community in which alone the free and full development of his personality is possible. (2) In the exercise of his rights and freedoms, everyone shall be subject only to such limitations as are determined by law solely for the purpose of securing due recognition and respect for the rights and freedoms of others and of meeting the just requirements of morality, public order and the general welfare in a democratic society. (3) These rights and freedoms may in no case be exercised contrary to the purposes and principles of the United Nations. Article 30. Nothing in this Declaration may be interpreted as implying for any State, group or person any right to engage in any activity or to perform any act aimed at the destruction of any of the rights and freedoms set forth herein." -} \ No newline at end of file From 12ea09f0a1e3028f64dc6da5f16fbbcc236a5f9a Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Tue, 5 Feb 2019 16:52:00 -0800 Subject: [PATCH 3/5] recreated project - used intelliJ new project feature to make this run-able --- .gitignore | 3 ++- java-WordCount.iml | 12 +++++++++++ .../com/lambdaschool/Main.class | Bin 0 -> 11690 bytes src/{wordCount => com/lambdaschool}/Main.java | 19 +++++++++++++++--- 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 java-WordCount.iml create mode 100644 out/production/java-WordCount/com/lambdaschool/Main.class rename src/{wordCount => com/lambdaschool}/Main.java (96%) diff --git a/.gitignore b/.gitignore index 62c8935..68729d6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.idea/ \ No newline at end of file +.idea/ +.DS_Store \ No newline at end of file diff --git a/java-WordCount.iml b/java-WordCount.iml new file mode 100644 index 0000000..d5c0743 --- /dev/null +++ b/java-WordCount.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/out/production/java-WordCount/com/lambdaschool/Main.class b/out/production/java-WordCount/com/lambdaschool/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..2a2ace30e45e8860c260eeb9726fb85d2091d1ed GIT binary patch literal 11690 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 TXo8gg%fm_Zr+jfP`m_H7ed+&| literal 0 HcmV?d00001 diff --git a/src/wordCount/Main.java b/src/com/lambdaschool/Main.java similarity index 96% rename from src/wordCount/Main.java rename to src/com/lambdaschool/Main.java index 4e1dd2a..a108c1d 100644 --- a/src/wordCount/Main.java +++ b/src/com/lambdaschool/Main.java @@ -1,15 +1,28 @@ package com.lambdaschool; +import java.util.HashMap; +import java.util.Map; + public class Main { public static void main(String[] args) { String article = "Preamble Whereas recognition of the inherent dignity and of the equal and inalienable rights of all members of the human family is the foundation of freedom, justice and peace in the world, Whereas disregard and contempt for human rights have resulted in barbarous acts which have outraged the conscience of mankind, and the advent of a world in which human beings shall enjoy freedom of speech and belief and freedom from fear and want has been proclaimed as the highest aspiration of the common people, Whereas it is essential, if man is not to be compelled to have recourse, as a last resort, to rebellion against tyranny and oppression, that human rights should be protected by the rule of law, Whereas it is essential to promote the development of friendly relations between nations, Whereas the peoples of the United Nations have in the Charter reaffirmed their faith in fundamental human rights, in the dignity and worth of the human person and in the equal rights of men and women and have determined to promote social progress and better standards of life in larger freedom, Whereas Member States have pledged themselves to achieve, in co-operation with the United Nations, the promotion of universal respect for and observance of human rights and fundamental freedoms, Whereas a common understanding of these rights and freedoms is of the greatest importance for the full realization of this pledge, Now, Therefore THE GENERAL ASSEMBLY proclaims THIS UNIVERSAL DECLARATION OF HUMAN RIGHTS as a common standard of achievement for all peoples and all nations, to the end that every individual and every organ of society, keeping this Declaration constantly in mind, shall strive by teaching and education to promote respect for these rights and freedoms and by progressive measures, national and international, to secure their universal and effective recognition and observance, both among the peoples of Member States themselves and among the peoples of territories under their jurisdiction. Article 1. All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood. Article 2. Everyone is entitled to all the rights and freedoms set forth in this Declaration, without distinction of any kind, such as race, colour, sex, language, religion, political or other opinion, national or social origin, property, birth or other status. Furthermore, no distinction shall be made on the basis of the political, jurisdictional or international status of the country or territory to which a person belongs, whether it be independent, trust, non-self-governing or under any other limitation of sovereignty. Article 3. Everyone has the right to life, liberty and security of person. Article 4. No one shall be held in slavery or servitude; slavery and the slave trade shall be prohibited in all their forms. Article 5. No one shall be subjected to torture or to cruel, inhuman or degrading treatment or punishment. Article 6. Everyone has the right to recognition everywhere as a person before the law. Article 7. All are equal before the law and are entitled without any discrimination to equal protection of the law. All are entitled to equal protection against any discrimination in violation of this Declaration and against any incitement to such discrimination. Article 8. Everyone has the right to an effective remedy by the competent national tribunals for acts violating the fundamental rights granted him by the constitution or by law. Article 9. No one shall be subjected to arbitrary arrest, detention or exile. Article 10. Everyone is entitled in full equality to a fair and public hearing by an independent and impartial tribunal, in the determination of his rights and obligations and of any criminal charge against him. Article 11. (1) Everyone charged with a penal offence has the right to be presumed innocent until proved guilty according to law in a public trial at which he has had all the guarantees necessary for his defence. (2) No one shall be held guilty of any penal offence on account of any act or omission which did not constitute a penal offence, under national or international law, at the time when it was committed. Nor shall a heavier penalty be imposed than the one that was applicable at the time the penal offence was committed. Article 12. No one shall be subjected to arbitrary interference with his privacy, family, home or correspondence, nor to attacks upon his honour and reputation. Everyone has the right to the protection of the law against such interference or attacks. Article 13. (1) Everyone has the right to freedom of movement and residence within the borders of each state. (2) Everyone has the right to leave any country, including his own, and to return to his country. Article 14. (1) Everyone has the right to seek and to enjoy in other countries asylum from persecution. (2) This right may not be invoked in the case of prosecutions genuinely arising from non-political crimes or from acts contrary to the purposes and principles of the United Nations. Article 15. (1) Everyone has the right to a nationality. (2) No one shall be arbitrarily deprived of his nationality nor denied the right to change his nationality. Article 16. (1) Men and women of full age, without any limitation due to race, nationality or religion, have the right to marry and to found a family. They are entitled to equal rights as to marriage, during marriage and at its dissolution. (2) Marriage shall be entered into only with the free and full consent of the intending spouses. (3) The family is the natural and fundamental group unit of society and is entitled to protection by society and the State. Article 17. (1) Everyone has the right to own property alone as well as in association with others. (2) No one shall be arbitrarily deprived of his property. Article 18. Everyone has the right to freedom of thought, conscience and religion; this right includes freedom to change his religion or belief, and freedom, either alone or in community with others and in public or private, to manifest his religion or belief in teaching, practice, worship and observance. Article 19. Everyone has the right to freedom of opinion and expression; this right includes freedom to hold opinions without interference and to seek, receive and impart information and ideas through any media and regardless of frontiers. Article 20. (1) Everyone has the right to freedom of peaceful assembly and association. (2) No one may be compelled to belong to an association. Article 21. (1) Everyone has the right to take part in the government of his country, directly or through freely chosen representatives. (2) Everyone has the right of equal access to public service in his country. (3) The will of the people shall be the basis of the authority of government; this will shall be expressed in periodic and genuine elections which shall be by universal and equal suffrage and shall be held by secret vote or by equivalent free voting procedures. Article 22. Everyone, as a member of society, has the right to social security and is entitled to realization, through national effort and international co-operation and in accordance with the organization and resources of each State, of the economic, social and cultural rights indispensable for his dignity and the free development of his personality. Article 23. (1) Everyone has the right to work, to free choice of employment, to just and favourable conditions of work and to protection against unemployment. (2) Everyone, without any discrimination, has the right to equal pay for equal work. (3) Everyone who works has the right to just and favourable remuneration ensuring for himself and his family an existence worthy of human dignity, and supplemented, if necessary, by other means of social protection. (4) Everyone has the right to form and to join trade unions for the protection of his interests. Article 24. Everyone has the right to rest and leisure, including reasonable limitation of working hours and periodic holidays with pay. Article 25. (1) Everyone has the right to a standard of living adequate for the health and well-being of himself and of his family, including food, clothing, housing and medical care and necessary social services, and the right to security in the event of unemployment, sickness, disability, widowhood, old age or other lack of livelihood in circumstances beyond his control. (2) Motherhood and childhood are entitled to special care and assistance. All children, whether born in or out of wedlock, shall enjoy the same social protection. Article 26. (1) Everyone has the right to education. Education shall be free, at least in the elementary and fundamental stages. Elementary education shall be compulsory. Technical and professional education shall be made generally available and higher education shall be equally accessible to all on the basis of merit. (2) Education shall be directed to the full development of the human personality and to the strengthening of respect for human rights and fundamental freedoms. It shall promote understanding, tolerance and friendship among all nations, racial or religious groups, and shall further the activities of the United Nations for the maintenance of peace. (3) Parents have a prior right to choose the kind of education that shall be given to their children. Article 27. (1) Everyone has the right freely to participate in the cultural life of the community, to enjoy the arts and to share in scientific advancement and its benefits. (2) Everyone has the right to the protection of the moral and material interests resulting from any scientific, literary or artistic production of which he is the author. Article 28. Everyone is entitled to a social and international order in which the rights and freedoms set forth in this Declaration can be fully realized. Article 29. (1) Everyone has duties to the community in which alone the free and full development of his personality is possible. (2) In the exercise of his rights and freedoms, everyone shall be subject only to such limitations as are determined by law solely for the purpose of securing due recognition and respect for the rights and freedoms of others and of meeting the just requirements of morality, public order and the general welfare in a democratic society. (3) These rights and freedoms may in no case be exercised contrary to the purposes and principles of the United Nations. Article 30. Nothing in this Declaration may be interpreted as implying for any State, group or person any right to engage in any activity or to perform any act aimed at the destruction of any of the rights and freedoms set forth herein."; // strip punctuations and split by blanks - String[] words = article.replaceAll("[[\\.\\?\\!\\,\\;\\:\\{\\}\\(\\)\\']]", "").split(" +"); + String[] arrayWords = article.replaceAll("[[\\.\\?\\!\\,\\;\\:\\{\\}\\(\\)\\']]", "").split(" +"); + + // word strip/split check +// for (String s : arrayWords) { +// System.out.println(s); +// } + + Map wordsMap = new HashMap<>(); - for (String s : words) { - System.out.println(s); + for (String word : splitWords) { + if (wordsMap.containsKey(word)) { + + } } + } } From 4947c8bf2ec006d2dbc386d5153c27114aa47d9e Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Wed, 6 Feb 2019 00:19:07 -0800 Subject: [PATCH 4/5] feat: create HashMap of words and their occurrence --- .../com/lambdaschool/Main.class | Bin 11690 -> 12265 bytes .../com/lambdaschool/WordCounter.class | Bin 0 -> 847 bytes src/com/lambdaschool/Main.java | 15 ++++++--- src/com/lambdaschool/WordCounter.java | 30 ++++++++++++++++++ 4 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 out/production/java-WordCount/com/lambdaschool/WordCounter.class create mode 100644 src/com/lambdaschool/WordCounter.java diff --git a/out/production/java-WordCount/com/lambdaschool/Main.class b/out/production/java-WordCount/com/lambdaschool/Main.class index 2a2ace30e45e8860c260eeb9726fb85d2091d1ed..a418275af244f36239a20367c78607bdb5ebe0f7 100644 GIT binary patch delta 1024 zcmZuvOHUI~6#i~!+B+QvkYdsLL=fnMQms(1MSLMrX+bR(kwi1pp%!af+bM=sUGN78 zE4OY)+@VP^kPz4Y6aRrRMm)FBq)C~@d3@*foiq2#(yv#GKmY9=02sxBicSnE2q?Iw z;JOMQf(mX3JBjkT1U8+?}Z?@ASd~*(HX~*s8v!2g+t98<^HhZ{m6(!q64Vr}S)6FJ|=RtTDe{ zFy@895N=K%KZ3G)E*(gi#Y`?8X+WYhK5Y~u6V$aeVd|;3aot;}b>ryaxW}L-^5tU6 zn97I&_PCzO4GB&fPQ&?anDu#I-p3?^rQ4_B0j3x_nkZ{{h-nQ`JgP@)bdHB>m_bZK z9J3nc@R;L?hNnny%xidthwWo-NZ}lG{UnfUgN}ZiO!Fj(QqOrt5d2%tD!FjGZu}A-~S43EJ`x>Xmvl zi7Rl>s}i3DOdOPC7kL5FjI`Ce3${}WpCM_hfi|2aTRTdC3+KqQ<2)`9Ld7f$iG09x zSYkehPK0$E%_3Ej2LCTPzn+HsLEg-V8TnIc?lL4pO=W{{P3v B(g*+m delta 451 zcmX9(OHKko5Pdzv&;t%Cqaz@opd#{DkimEWH;NmKi80ZPgat~}_}jR^g%=>4KsF}s z!~_!)Ie@2drzRf2l~_IYqF&dls`skC_8)eOZ@({n041!rF@%VUsEQdCvu=bjry?eB z-i0_8+(;nFk>W_Vc5Wng-uhn8dny-J^{8x}ZdnJ78i$`F!{Dx*T%J{HYxPEr!Bw{E z$Js;c%F>|0^YqSQ$w(GC1}T!#u!tp&yoLgnIf@!glo*WGozcEdciJDBz4mLGHxt{4 zLTo6W1SXUy4pWvRWQ0oc8SK$6k5F{lq!Xj`*Zv#eg-)3ZV;Cn!40j=e6PmiTkw>nPG!UX3A&#)mh7hAWe~4w6q816$ Ef4b*8xBvhE diff --git a/out/production/java-WordCount/com/lambdaschool/WordCounter.class b/out/production/java-WordCount/com/lambdaschool/WordCounter.class new file mode 100644 index 0000000000000000000000000000000000000000..5561e440132d5cac90d3386ecb18295b6e2ef070 GIT binary patch literal 847 zcmaKrOK;jx5QWbe1BE!eLTDZ&O?E(}vh1Q&HjyetLd_x(QJ2PC5l7%F8Poo$E?Oy3 zr7rRV@}sJrd+jz4XoPehbLX7-W-RW1|GES44u@srv0H+RwpsRy*e~LZ!2PP@v7j-y z_P_Z3sUJ=H=Sdt!llOwU4uVA-t0+(>dJ!cm7Raff@F9%Cmu@Y1V zVWd7SW+N3}_@gN!je!pQ>ClfubI*cqauv=6`-4Ewh%g(C{dsVu^|XIUxU4jJiW8NX zh@jc&E>~v4{BOeM3Ni!Mq{Z2CSGi7?eKjdx@#uDJPvvvHhy(R8G=0<_k-ase^H9ct zhXRToUZEstztjv39_D>Ex>i9VAjA-d{5W}jF^4~z*%SS^=OL`I#?|BPGv9OEtG%C) z-q9_bUi%igA6Br=wLv2g#ih7JVTIBPBL}GrRn&N+fh{BUWC}SfP^UUA)8}s9^1T~4 z-+6Fg%nLSHv4&onkQoX#&}76g9y8l9*_Q7Ct!$$WcC=v~T4~llq(X)y*hDMydJK~L i_6(%8667_umOyr&%qRufG5?JJfS8Gx32fVnJAVLQYmFcP literal 0 HcmV?d00001 diff --git a/src/com/lambdaschool/Main.java b/src/com/lambdaschool/Main.java index a108c1d..2e3d0a0 100644 --- a/src/com/lambdaschool/Main.java +++ b/src/com/lambdaschool/Main.java @@ -1,7 +1,6 @@ package com.lambdaschool; import java.util.HashMap; -import java.util.Map; public class Main { @@ -16,13 +15,19 @@ public static void main(String[] args) { // System.out.println(s); // } - Map wordsMap = new HashMap<>(); - - for (String word : splitWords) { - if (wordsMap.containsKey(word)) { + HashMap mapWords = new HashMap<>(); + for (String word : arrayWords) { + if (mapWords.containsKey(word)) { + int counter = mapWords.get(word); + mapWords.put(word, counter++); + } else { + mapWords.put(word, 1); } } + // HashMap check +// System.out.println(mapWords); + } } diff --git a/src/com/lambdaschool/WordCounter.java b/src/com/lambdaschool/WordCounter.java new file mode 100644 index 0000000..3cb988b --- /dev/null +++ b/src/com/lambdaschool/WordCounter.java @@ -0,0 +1,30 @@ +package com.lambdaschool; + +public class WordCounter { + private String word; + private int occurrenceCounter; + + // practicing IntelliJ built-in 'Generate' + public WordCounter(String word, int occurrenceCounter) { + this.word = word; + this.occurrenceCounter = occurrenceCounter; + } + + public String getWord() { + return word; + } + + public void setWord(String word) { + this.word = word; + } + + public int getOccurrenceCounter() { + return occurrenceCounter; + } + + public void setOccurrenceCounter(int occurrenceCounter) { + this.occurrenceCounter = occurrenceCounter; + } + + +} From b778a004a561ecc7b88aa50ae329b9794f3dadc5 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Wed, 6 Feb 2019 07:57:45 -0800 Subject: [PATCH 5/5] fix: error fixed --- .../com/lambdaschool/Main.class | Bin 12265 -> 12264 bytes src/com/lambdaschool/Main.java | 5 ++++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/out/production/java-WordCount/com/lambdaschool/Main.class b/out/production/java-WordCount/com/lambdaschool/Main.class index a418275af244f36239a20367c78607bdb5ebe0f7..c7c388eaac984f19d2942464490b1aa988a4b7c6 100644 GIT binary patch delta 246 zcmW-Zy-vaa6h;qFXn|sYP_!h7pcI0(BoIi{goTMGFk!)%IJppc02g_JPCf()Fmz(z zar6xc1Mv&X{W<4;_iy$)TYm?!WVj4!=|>FGz#?1)9dGO!POA50`mPy~`Jr(hvU}`^ z+|bhISjKC33MyZ_EqOnpuu<6HQniPzYLOsIfg&y?F^6Z$Omy+W6;si7@ei)~2bEvB(? zIkE#oLc$Hr`<(OM{hRKmyH#YE@j5Cy1JXFaGTuhd&6gnKo85sG23A6LL;XBl{^BNF z^=)mwy|Rt?7?nPLzPSz)yf1xcD5`dGRUIX|c-#=+ixn8kzH-Z0WI~CV_&fJ3sEEP{ zQ$EL?n5~Z#8QQG*aMG}O`W)sijO}#Px-z@>p=FO3&FNz Gitq&7V