{"id":36173,"date":"2016-04-14T10:49:00","date_gmt":"2016-04-14T15:49:00","guid":{"rendered":"http:\/\/rhcpalmarichiewordpresscom.wordpress.com\/?p=513"},"modified":"2016-04-14T11:02:11","modified_gmt":"2016-04-14T16:02:11","slug":"wsq12-word-count-3","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101winter2016\/2016\/04\/wsq12-word-count-3\/","title":{"rendered":"WSQ12 \u2018Word Count\u2019"},"content":{"rendered":"<p>The end of the semester is near, and we are seeing more advanced codes that in the beggining of the semester. This WSQ was kind of cool for me, since I enjoyed using the open files as read and writting. I do not know why, but do not judge me.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-524\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/c7624fe6f429c164edac11f8fefe4f0d.jpg\" alt=\"shiba inu.png\"   \/><\/p>\n<p>Majo &#8212;^<\/p>\n<p>For testing purposes, the text used for this WSQ says the following:<\/p>\n<blockquote>\n<p>ThisThis This is a test for wsq012 in order to count the words in this file<br \/>\nwsq012<br \/>\nwords<br \/>\nthisThis<br \/>\nsentences<br \/>\nallwordstogethertoproveapointallall<\/p>\n<\/blockquote>\n<p>I used two methods for this WSQ. The first one was with a\u00a0<strong>line.split()<\/strong> while reading the document. This way the program separates and reads the document line by line. Then search the word in the document with a conditional\u00a0<strong>if.\u00a0<\/strong>Then it adds the total matches to the counter.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-543\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/9e8bb0cd5a3eda11d809fa5122418313.jpg\" alt=\"WSQ12v2\"   \/><\/p>\n<p>As you may notice, this method does not distinguishes the matches of the established word if this word is mixed between the text without any space to separate it. For example, &#8220;This&#8221; is the word to search. Text says &#8220;Thisthis&#8221; that are two matches, tecnically; however, the code only recognizes it as one.<\/p>\n<p>This is why I made the second version of the WSQ. Ken suggested to use\u00a0<strong>find()<\/strong> in order to avoid this problem; however, since I failed in using it correctly, I rather used\u00a0<strong>count()<\/strong>. By the way, I also improved the code by using\u00a0<strong>.lower()<\/strong>, so it does not matters if the text and words are submited in cappital letters.\u00a0<code class=\"python-markpup\"><\/code><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-555\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/a59b27b0841cd56d110e1b8e2316507d.jpg\" alt=\"WSQ12v3\"   \/><\/p>\n<p>What is this? A picture for ants? Well&#8230; you can take a closer look at the code in my <a href=\"https:\/\/github.com\/RichiePalma\/CoderRichie\">GitHub<\/a>!<\/p>\n<p>Now that this blog has finally reach it&#8217;s end. Let me introduce you to Cage the Elephant and their song called &#8220;Ain&#8217;t No Rest for the Wicked&#8221;. Released <\/p>\n<div class=\"post-limited-image\"><img decoding=\"async\" class=\"alignnone size-full wp-image-564\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/99888768512792a9692a789107c9aeb9.jpg\" alt=\"no rest for the wicked\"   \/><\/div>\n<div class=\"post-limited-image\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/05d559408ca62aa9b89db4137e688e4f.jpg\" \/><\/div>\n<div class=\"post-limited-image\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/07c5118d2f7bd77bce4d9408a68f8d75.jpg#038;blog=105330260&#038;%23038;post=513&#038;%23038;subd=rhcpalmarichiewordpresscom&#038;%23038;ref=&#038;%23038;feed=1\" width=\"1\" height=\"1\" \/><\/div>\n<p><!--more--> 2013, this song was used for the intro of Borderlands, the first game from the epic saga. This song shows us that there is never a moment of one&#8217;s life where one does not have to make an effort.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-564\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/99888768512792a9692a789107c9aeb9.jpg\" alt=\"no rest for the wicked\"   \/><\/p>\n<p>  <a rel=\"nofollow\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gocomments\/rhcpalmarichiewordpresscom.wordpress.com\/513\/\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/05d559408ca62aa9b89db4137e688e4f.jpg\" \/><\/a> <img loading=\"lazy\" decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/04\/07c5118d2f7bd77bce4d9408a68f8d75.jpg#038;blog=105330260&#038;%23038;post=513&#038;%23038;subd=rhcpalmarichiewordpresscom&#038;%23038;ref=&#038;%23038;feed=1\" width=\"1\" height=\"1\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The end of the semester is near, and we are seeing more advanced codes that in the beggining of the semester. This WSQ was kind of cool for me, since I enjoyed using the open files as read and writting. I do not know why, but do not judge me. Majo &#8212;^ For testing purposes, &hellip; <a href=\"https:\/\/kenscourses.com\/tc101winter2016\/2016\/04\/wsq12-word-count-3\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">WSQ12 \u2018Word Count\u2019<\/span><\/a><\/p>\n","protected":false},"author":33,"featured_media":36175,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[124,24,226],"class_list":["post-36173","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogs","category-syndicated","tag-ironfromice","tag-wsq","tag-wsq12"],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/36173","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/users\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/comments?post=36173"}],"version-history":[{"count":2,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/36173\/revisions"}],"predecessor-version":[{"id":36185,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/36173\/revisions\/36185"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/media\/36175"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/media?parent=36173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/categories?post=36173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/tags?post=36173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}