{"id":9764,"date":"2020-06-17T16:15:00","date_gmt":"2020-06-17T10:45:00","guid":{"rendered":"http:\/\/ivyproschool.com\/blog\/?p=9764"},"modified":"2021-06-10T16:32:40","modified_gmt":"2021-06-10T11:02:40","slug":"string-operations-using-python-for-nlp-beginners","status":"publish","type":"post","link":"https:\/\/ivyproschool.com\/blog\/string-operations-using-python-for-nlp-beginners\/","title":{"rendered":"String Operations Using Python for NLP Beginners"},"content":{"rendered":"<p>Hello NLP learner!! I hope you had visited our last article &#8211; <a href=\"https:\/\/ivyproschool.com\/blog\/2020\/06\/10\/introduction-to-natural-language-processing\/\">Introduction to Natural Language Processing using Python<\/a>. With that, you would have got an idea that Natural Language Processing essentially deals with <em>Text Analytics<\/em>. As a next step, we naturally need to learn how to deal with text or in other words strings before we plunge into advanced techniques of NLP. This article will talk about useful string operations using Python for NLP beginners. Get ready for some facts about strings and interesting string operations.!!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9772\" src=\"https:\/\/ivyproschool.com\/blog\/wp-content\/uploads\/2015\/08\/Cover-1-1.png\" alt=\"string operation using python\" width=\"1080\" height=\"500\" srcset=\"https:\/\/ivyproschool.com\/blog\/wp-content\/uploads\/2015\/08\/Cover-1-1.png 1080w, https:\/\/ivyproschool.com\/blog\/wp-content\/uploads\/2015\/08\/Cover-1-1-300x139.png 300w, https:\/\/ivyproschool.com\/blog\/wp-content\/uploads\/2015\/08\/Cover-1-1-768x356.png 768w, https:\/\/ivyproschool.com\/blog\/wp-content\/uploads\/2015\/08\/Cover-1-1-1024x474.png 1024w\" sizes=\"auto, (max-width: 1080px) 100vw, 1080px\" \/><\/p>\n<h2>Important facts about Strings in Python:<\/h2>\n<ol>\n<li>Similar to arrays, strings can be considered as a sequence of characters<\/li>\n<li>Strings are the main data types with which we handle text data in Python<\/li>\n<li>Unlike Python 2.x versions, strings are Unicode by default in Python 3.x versions<\/li>\n<li>A string is immutable. We cannot edit or update a string value.<\/li>\n<\/ol>\n<h3>Explanation of Immutable Strings:<\/h3>\n<p>In the below code, we assign some value to the String1 variable. Let us see what happens when we try to assign a new value to a particular character index in the variable.<\/p>\n<pre>String1 = 'Natural Language Processing'\r\n\r\nString1[5] = 'X'<\/pre>\n<div class=\"output_subarea output_text\">\n<p>The code throws the following error.<br \/>\nTypeError: &#8216;str&#8217; object does not support item assignment<\/p>\n<p>This means we can not manipulate the string variable. What happens when we renew the variable value?. Even then, Python creates a completely new string internally. This can be observed with the generation of different id values while assigning a new value for the same string variable. Follow the below codes and the different id values.<\/p>\n<pre>String1\u00a0=\u00a0'Natural\u00a0Language\u00a0Processing'\r\nprint(id(String1))\r\n\r\noutput is 140713608669024\r\n\r\nString1 = 'NLP'\r\nprint(id(String1))\r\n\r\noutput is 140713609660712<\/pre>\n<\/div>\n<h2>What are String Literals:<\/h2>\n<p>The following are the common types of string literals used in Python.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9773\" src=\"https:\/\/ivyproschool.com\/blog\/wp-content\/uploads\/2015\/08\/literals.png\" alt=\"string literals\" width=\"1080\" height=\"500\" srcset=\"https:\/\/ivyproschool.com\/blog\/wp-content\/uploads\/2015\/08\/literals.png 1080w, https:\/\/ivyproschool.com\/blog\/wp-content\/uploads\/2015\/08\/literals-300x139.png 300w, https:\/\/ivyproschool.com\/blog\/wp-content\/uploads\/2015\/08\/literals-768x356.png 768w, https:\/\/ivyproschool.com\/blog\/wp-content\/uploads\/2015\/08\/literals-1024x474.png 1024w\" sizes=\"auto, (max-width: 1080px) 100vw, 1080px\" \/><\/p>\n<h3>Short strings:<\/h3>\n<p>We can define strings enclosed in single quotes (&#8216;) as well as double-quotes (&#8220;). For example &#8220;Python&#8221; or &#8216;Python&#8217;.<\/p>\n<h3>Long strings:<\/h3>\n<p>We can define strings enclosed in three single quotes (&#8221;&#8217;) or double-quotes (&#8220;&#8221;&#8221;). For example &#8220;&#8221;&#8221;Python 3.8 is the latest version&#8221;&#8221;&#8221; or &#8221;&#8217;I am a very long string&#8221;&#8217;. You might notice this way of defining strings at times.<\/p>\n<h3>Escape sequence in strings:<\/h3>\n<p>Escape sequences start with a backslash (\\) followed by an ASCII character. Commonly used escape sequences are &#8216;\\n&#8217; for a newline character, &#8216;\\t&#8217; to indicate a tab.<\/p>\n<h3>Byte strings:<\/h3>\n<p>We can create bytes of data type objects using byte strings. For example, bytes(&#8216;Python&#8217;) or b&#8217;Python&#8217;. You might notice byte strings when converting a data frame to a csv.<\/p>\n<h3>Unicode:<\/h3>\n<p>These strings are denoted by u&#8217;&#8230;.&#8217; notation. Unicode strings are non-ASCII character sequences. As already mentioned, all the strings are by default Unicode strings in Python 3.x versions. A string &#8216;H\u00e8llo&#8217; is u&#8217;H\\xe8llo&#8217; in Unicode.<\/p>\n<h3>Raw strings:<\/h3>\n<p>We can create raw strings to keep the strings in its native form. Raw strings do not perform any action on the escape sequence strings. An example is r&#8217;Python&#8217;.<\/p>\n<div>\n<pre>#Understanding\u00a0how\u00a0escape\u00a0sequence\u00a0strings\u00a0look\u00a0like\u00a0in\u00a0a\u00a0normal\u00a0string\r\n\r\nescape_strings\u00a0=\u00a0\u00a0\"C:<strong>\\n<\/strong>ew_directory<strong>\\t<\/strong>emporary_folder\\File.txt\"\r\nprint(escape_strings)\r\n\r\nThe\u00a0output\u00a0is\u00a0\r\nC:\r\new_directory\u00a0\u00a0emporary_folder\\File.txt\r\n\r\n#Understanding\u00a0how\u00a0the\u00a0<strong>raw\u00a0string<\/strong>\u00a0makes\u00a0a\u00a0difference\u00a0in\u00a0the\u00a0interpretation\u00a0of\u00a0string\u00a0\r\nescape_strings\u00a0=\u00a0\u00a0r\"C:\\new_directory\\temporary_folder\\File.txt\"\r\nprint(escape_strings)\r\n\r\nThe\u00a0output\u00a0is\u00a0\r\nC:\\new_directory\\temporary_folder\\File.txt<\/pre>\n<\/div>\n<h2>String Operations and Methods:<\/h2>\n<p>Let us begin string operations by working on the reversal of strings as our first interesting operation. It is very easy to <strong>reverse a string<\/strong> in Python. Have a look at the code below.<\/p>\n<div>\n<pre>string_variable\u00a0=\u00a0\u00a0\"I\u00a0love\u00a0Pizza\u00a0\ud83c\udf55!\"\r\nstring_reverse = string_variable[::-1]\r\nprint(string_reverse)\r\n\r\nOutput\u00a0is\r\n'!\ud83c\udf55\u00a0azziP\u00a0evol\u00a0I'<\/pre>\n<\/div>\n<p>Further, the various categories of operations most frequently performed on strings are &#8211;<\/p>\n<ol>\n<li>Basic operations<\/li>\n<li>Indexing and slicing<\/li>\n<li>Methods<\/li>\n<\/ol>\n<h3>Basic Python String Operations:<\/h3>\n<p>The common operations we would like to explain here are string concatenation, finding substrings, lengths, and characters. Many times we do require concatenating of strings or string variables during URL manipulations during web scraping. These python string concatenation operations can come in handy at that time. Let us check some codes for it.<\/p>\n<pre>#concatenating various strings\r\n'https:\/\/www.skillenable.com\/'\u00a0+\u00a0'SkillEnableLoanPortal\/'\u00a0+\u00a0'isa'\r\n\r\noutput\u00a0is\u00a0\r\n'https:\/\/www.skillenable.com\/SkillEnableLoanPortal\/isa'\r\n\r\n#concatenating various strings without a '+' operator<\/pre>\n<pre>'https:\/\/www.skillenable.com\/'\u00a0\u00a0'SkillEnableLoanPortal\/'\u00a0\u00a0'isa'<\/pre>\n<pre>output\u00a0is\u00a0\r\n'https:\/\/www.skillenable.com\/SkillEnableLoanPortal\/isa'<\/pre>\n<p>We can also perform the concatenation of string variables with string literals. During web scraping, we generate additional pages by adding a string literal to the base page link. An example scenario and its code are provided below.<\/p>\n<p>Assuming we are surfing the Ivy Professional School official blog site. The web link is &#8211; <a href=\"https:\/\/ivyproschool.com\/blog\/\">https:\/\/ivyproschool.com\/blog\/<\/a>. This is our base page. If we scroll down the page, we find pagination where we can move to the next page by clicking the &#8216;2&#8217; button. The click takes us to the next page whose URL becomes https:\/\/ivyproschool.com\/blog\/page\/2\/. We can generate different next page URLs by performing concatenation as shown in the code below.<\/p>\n<pre>base_url = 'https:\/\/ivyproschool.com\/blog\/'\r\n#base_url is string variable, 'page\/2\/' is string literal. We concatenate these by a + operator in between\r\nnew_url = base_url + 'page\/2\/'\r\nprint(new_url)\r\n\r\noutput is https:\/\/ivyproschool.com\/blog\/page\/2\/<\/pre>\n<p>Time for some exercise. Tell us in the comment section the outputs when you run the below codes.<\/p>\n<pre>1) new_url = base_url\u00a0 'page\/2\/'\r\n\r\n2) String1 = 'Ivy Professional School'   String2 = 'Data Science'   (String1 + String2)*3\r\n3) len(String1)<\/pre>\n<p>A very simple way to identify if a substring is present in a string variable is done using the below code. The output is in the form of a Boolean True or False. True in this example.<\/p>\n<pre>'Ivy' in String1<\/pre>\n<h2>Indexing and Slicing:<\/h2>\n<p>Other useful string operations using Python for NLP beginners are indexing and slicing of strings. We know that strings are a sequence of characters and iterables just like lists. We can access a single character using a specific position or index in the string is called indexing. Accessing a part of a string i.e., a substring using a start and end index is called slicing.<\/p>\n<p><strong>Please Note:<\/strong> Python provides 2 different ways in which we can index the characters in a string. One starting from 0 and increasing each character index by 1 until the end of the string. The other starting from -1 at the end of the string and decreasing each character index by 1 until the beginning of the string.<\/p>\n<p>Let us take a look at the <strong>indexing code snippet<\/strong> for a string variable along with the outputs. We have used the <a href=\"https:\/\/ivyproschool.com\/blog\/2020\/04\/02\/top-15-interesting-tricks-every-python-beginner-must-know\/\">enumerate<\/a> method.<\/p>\n<div>\n<pre>String1\u00a0=\u00a0'Natural\u00a0Language\u00a0Processing'\r\nfor\u00a0\u00a0index,\u00a0character\u00a0in\u00a0enumerate(String1):\r\n\u00a0 print(character,'has index', index)<\/pre>\n<p>Experiment with other ways of indexing and understand the outputs from the codes given below.<\/p>\n<div>\n<pre>1) String1[-5]\r\n2) String1[5]<\/pre>\n<\/div>\n<p>What if someone just wants to fetch the word &#8216;Processing&#8217; from the String1 variable. Or just a part out of it. How can this be done? This is where slicing comes in to picture. Some slicing code snippets are provided below. We encourage you to work these codes and observe the outputs.<\/p>\n<pre>String1[:]\r\nString1[::1]\r\nString1[0::1]\r\nString1[::]\r\nString1[8:16]\r\nString1[2::2]\r\nString1[-2::]\r\nString1[-2::-1]\r\nString1[-2:] + String1[5:]\r\nString1[-2] + String1[5]<\/pre>\n<div class=\"output_subarea output_text\">\n<h3>Methods:<\/h3>\n<p>A huge list of methods that we can apply on strings is available in this <a href=\"https:\/\/docs.python.org\/3\/library\/stdtypes.html#string-methods\">link<\/a>. We have also explained a few in our previous article &#8211; <a href=\"https:\/\/ivyproschool.com\/blog\/2020\/04\/02\/top-15-interesting-tricks-every-python-beginner-must-know\/\">Top 15 interesting tricks every Python Beginner must know<\/a>. For example, split, join, capitalize, reverse, swapcase, replace, and title. Additionally, provided below are some more relevant methods commonly applied in text analytics.<\/p>\n<p>We use the <strong>strip<\/strong> method to remove leading and trailing spaces from the string variable. This is very helpful after we perform text cleaning on tweets collected from twitter as a practical scenario.<\/p>\n<div>\n<pre>String1\u00a0=\u00a0\"\u00a0\u00a0\u00a0\u00a0Natural\u00a0\u00a0\u00a0\u00a0Language\u00a0Processing\u00a0\u00a0\u00a0\u00a0\u00a0\"\r\nString1.strip()<\/pre>\n<\/div>\n<p>We often need to identify if a string variable or literal is alphabets, alphanumeric, or decimal. We apply <strong>isalpha, isalnum or isdecimal<\/strong> respectively to find that out. The output is a Boolean True or False value.<\/p>\n<\/div>\n<\/div>\n<pre>'11111'.isdecimal()\r\n'123ab'.isalphanum()\r\n'NLP'.isalpha<\/pre>\n<div>The other 2 operations namely formatting and regular expressions will be dealt with in the next article. We will provide many other relevant scenarios wherever necessary for the ease of understanding of how and where to apply these commands. I hope you enjoy experimenting with the string operations using python for NLP beginners and gain confidence in it. Happy learning!!!<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hello NLP learner!! I hope you had visited our last article &#8211; Introduction to Natural Language Processing using Python. With that, you would have got an idea that Natural Language Processing essentially deals with Text Analytics. As a next step, we naturally need to learn how to deal with text or in other words strings before we plunge into advanced techniques of NLP. This article will talk about useful string operations using Python for NLP beginners. Get ready for some facts about strings and interesting string operations.!! Important facts about Strings in Python: Similar to arrays, strings can be considered as a sequence of characters Strings are the main data types with which we handle text data in Python Unlike Python 2.x versions, strings are Unicode by default in Python 3.x versions A string is immutable. We cannot edit or update a string value. Explanation of Immutable Strings: In the below code, we assign some value to the String1 variable. Let us see what happens when we try to assign a new value to a particular character index in the variable. String1 = &#8216;Natural Language Processing&#8217; String1[5] = &#8216;X&#8217; The code throws the following error. TypeError: &#8216;str&#8217; object does not [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":9772,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,715,552],"tags":[832,830,819,823,716,831,815,829],"class_list":["post-9764","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-analytics","category-machine-learning-ai","category-technology","tag-enumerate","tag-indexing","tag-join","tag-nlp","tag-python","tag-slicing","tag-split","tag-string-operations"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>String Operations using Python | Official Blog | Ivy Pro School<\/title>\n<meta name=\"description\" content=\"Find out about several basic string operations using Python for Natural Language Processing that is commonly applied as part of text preprocessing.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ivyproschool.com\/blog\/string-operations-using-python-for-nlp-beginners\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"String Operations using Python | Official Blog | Ivy Pro School\" \/>\n<meta property=\"og:description\" content=\"Find out about several basic string operations using Python for Natural Language Processing that is commonly applied as part of text preprocessing.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ivyproschool.com\/blog\/string-operations-using-python-for-nlp-beginners\/\" \/>\n<meta property=\"og:site_name\" content=\"R vs Python: Which Analytics Tool Should You Choose for Data Science?\" \/>\n<meta property=\"article:author\" content=\"https:\/\/facebook.com\/ivyproschool\" \/>\n<meta property=\"article:published_time\" content=\"2020-06-17T10:45:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-06-10T11:02:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ivyproschool.com\/blog\/wp-content\/uploads\/2015\/08\/Cover-1-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1080\" \/>\n\t<meta property=\"og:image:height\" content=\"500\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ivy Professional School\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ivyproschool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ivy Professional School\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/string-operations-using-python-for-nlp-beginners\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/string-operations-using-python-for-nlp-beginners\\\/\"},\"author\":{\"name\":\"Ivy Professional School\",\"@id\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/#\\\/schema\\\/person\\\/31fdab8559dd3db99173764bfb60215d\"},\"headline\":\"String Operations Using Python for NLP Beginners\",\"datePublished\":\"2020-06-17T10:45:00+00:00\",\"dateModified\":\"2021-06-10T11:02:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/string-operations-using-python-for-nlp-beginners\\\/\"},\"wordCount\":1151,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/string-operations-using-python-for-nlp-beginners\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/08\\\/Cover-1-1.png\",\"keywords\":[\"enumerate\",\"indexing\",\"Join\",\"NLP\",\"python\",\"slicing\",\"Split\",\"String Operations\"],\"articleSection\":[\"Data Analytics\",\"Machine Learning &amp; AI\",\"Technology\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/string-operations-using-python-for-nlp-beginners\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/string-operations-using-python-for-nlp-beginners\\\/\",\"url\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/string-operations-using-python-for-nlp-beginners\\\/\",\"name\":\"String Operations using Python | Official Blog | Ivy Pro School\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/string-operations-using-python-for-nlp-beginners\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/string-operations-using-python-for-nlp-beginners\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/08\\\/Cover-1-1.png\",\"datePublished\":\"2020-06-17T10:45:00+00:00\",\"dateModified\":\"2021-06-10T11:02:40+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/#\\\/schema\\\/person\\\/31fdab8559dd3db99173764bfb60215d\"},\"description\":\"Find out about several basic string operations using Python for Natural Language Processing that is commonly applied as part of text preprocessing.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/string-operations-using-python-for-nlp-beginners\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/string-operations-using-python-for-nlp-beginners\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/string-operations-using-python-for-nlp-beginners\\\/#primaryimage\",\"url\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/08\\\/Cover-1-1.png\",\"contentUrl\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/08\\\/Cover-1-1.png\",\"width\":1080,\"height\":500,\"caption\":\"string operation using python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/string-operations-using-python-for-nlp-beginners\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"String Operations Using Python for NLP Beginners\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/\",\"name\":\"Ivy Professional School | Official Blog\",\"description\":\"Confused between R and Python for your data science journey? Discover the key differences in data visualization, handling capabilities, speed, and ease of learning.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/#\\\/schema\\\/person\\\/31fdab8559dd3db99173764bfb60215d\",\"name\":\"Ivy Professional School\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/866b09293f13d461b399bb9a40607e85623ede13d844f763bf665689cb0d1452?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/866b09293f13d461b399bb9a40607e85623ede13d844f763bf665689cb0d1452?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/866b09293f13d461b399bb9a40607e85623ede13d844f763bf665689cb0d1452?s=96&d=mm&r=g\",\"caption\":\"Ivy Professional School\"},\"sameAs\":[\"http:\\\/\\\/www.ivyproschool.com\",\"https:\\\/\\\/facebook.com\\\/ivyproschool\",\"https:\\\/\\\/instagram.com\\\/ivyproschool\",\"https:\\\/\\\/x.com\\\/ivyproschool\",\"https:\\\/\\\/youtube.com\\\/ivyproschool\"],\"url\":\"https:\\\/\\\/ivyproschool.com\\\/blog\\\/author\\\/prateek\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"String Operations using Python | Official Blog | Ivy Pro School","description":"Find out about several basic string operations using Python for Natural Language Processing that is commonly applied as part of text preprocessing.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ivyproschool.com\/blog\/string-operations-using-python-for-nlp-beginners\/","og_locale":"en_US","og_type":"article","og_title":"String Operations using Python | Official Blog | Ivy Pro School","og_description":"Find out about several basic string operations using Python for Natural Language Processing that is commonly applied as part of text preprocessing.","og_url":"https:\/\/ivyproschool.com\/blog\/string-operations-using-python-for-nlp-beginners\/","og_site_name":"R vs Python: Which Analytics Tool Should You Choose for Data Science?","article_author":"https:\/\/facebook.com\/ivyproschool","article_published_time":"2020-06-17T10:45:00+00:00","article_modified_time":"2021-06-10T11:02:40+00:00","og_image":[{"width":1080,"height":500,"url":"https:\/\/ivyproschool.com\/blog\/wp-content\/uploads\/2015\/08\/Cover-1-1.png","type":"image\/png"}],"author":"Ivy Professional School","twitter_card":"summary_large_image","twitter_creator":"@ivyproschool","twitter_misc":{"Written by":"Ivy Professional School","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ivyproschool.com\/blog\/string-operations-using-python-for-nlp-beginners\/#article","isPartOf":{"@id":"https:\/\/ivyproschool.com\/blog\/string-operations-using-python-for-nlp-beginners\/"},"author":{"name":"Ivy Professional School","@id":"https:\/\/ivyproschool.com\/blog\/#\/schema\/person\/31fdab8559dd3db99173764bfb60215d"},"headline":"String Operations Using Python for NLP Beginners","datePublished":"2020-06-17T10:45:00+00:00","dateModified":"2021-06-10T11:02:40+00:00","mainEntityOfPage":{"@id":"https:\/\/ivyproschool.com\/blog\/string-operations-using-python-for-nlp-beginners\/"},"wordCount":1151,"commentCount":0,"image":{"@id":"https:\/\/ivyproschool.com\/blog\/string-operations-using-python-for-nlp-beginners\/#primaryimage"},"thumbnailUrl":"https:\/\/ivyproschool.com\/blog\/wp-content\/uploads\/2015\/08\/Cover-1-1.png","keywords":["enumerate","indexing","Join","NLP","python","slicing","Split","String Operations"],"articleSection":["Data Analytics","Machine Learning &amp; AI","Technology"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ivyproschool.com\/blog\/string-operations-using-python-for-nlp-beginners\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ivyproschool.com\/blog\/string-operations-using-python-for-nlp-beginners\/","url":"https:\/\/ivyproschool.com\/blog\/string-operations-using-python-for-nlp-beginners\/","name":"String Operations using Python | Official Blog | Ivy Pro School","isPartOf":{"@id":"https:\/\/ivyproschool.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ivyproschool.com\/blog\/string-operations-using-python-for-nlp-beginners\/#primaryimage"},"image":{"@id":"https:\/\/ivyproschool.com\/blog\/string-operations-using-python-for-nlp-beginners\/#primaryimage"},"thumbnailUrl":"https:\/\/ivyproschool.com\/blog\/wp-content\/uploads\/2015\/08\/Cover-1-1.png","datePublished":"2020-06-17T10:45:00+00:00","dateModified":"2021-06-10T11:02:40+00:00","author":{"@id":"https:\/\/ivyproschool.com\/blog\/#\/schema\/person\/31fdab8559dd3db99173764bfb60215d"},"description":"Find out about several basic string operations using Python for Natural Language Processing that is commonly applied as part of text preprocessing.","breadcrumb":{"@id":"https:\/\/ivyproschool.com\/blog\/string-operations-using-python-for-nlp-beginners\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ivyproschool.com\/blog\/string-operations-using-python-for-nlp-beginners\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ivyproschool.com\/blog\/string-operations-using-python-for-nlp-beginners\/#primaryimage","url":"https:\/\/ivyproschool.com\/blog\/wp-content\/uploads\/2015\/08\/Cover-1-1.png","contentUrl":"https:\/\/ivyproschool.com\/blog\/wp-content\/uploads\/2015\/08\/Cover-1-1.png","width":1080,"height":500,"caption":"string operation using python"},{"@type":"BreadcrumbList","@id":"https:\/\/ivyproschool.com\/blog\/string-operations-using-python-for-nlp-beginners\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ivyproschool.com\/blog\/"},{"@type":"ListItem","position":2,"name":"String Operations Using Python for NLP Beginners"}]},{"@type":"WebSite","@id":"https:\/\/ivyproschool.com\/blog\/#website","url":"https:\/\/ivyproschool.com\/blog\/","name":"Ivy Professional School | Official Blog","description":"Confused between R and Python for your data science journey? Discover the key differences in data visualization, handling capabilities, speed, and ease of learning.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ivyproschool.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ivyproschool.com\/blog\/#\/schema\/person\/31fdab8559dd3db99173764bfb60215d","name":"Ivy Professional School","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/866b09293f13d461b399bb9a40607e85623ede13d844f763bf665689cb0d1452?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/866b09293f13d461b399bb9a40607e85623ede13d844f763bf665689cb0d1452?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/866b09293f13d461b399bb9a40607e85623ede13d844f763bf665689cb0d1452?s=96&d=mm&r=g","caption":"Ivy Professional School"},"sameAs":["http:\/\/www.ivyproschool.com","https:\/\/facebook.com\/ivyproschool","https:\/\/instagram.com\/ivyproschool","https:\/\/x.com\/ivyproschool","https:\/\/youtube.com\/ivyproschool"],"url":"https:\/\/ivyproschool.com\/blog\/author\/prateek\/"}]}},"_links":{"self":[{"href":"https:\/\/ivyproschool.com\/blog\/wp-json\/wp\/v2\/posts\/9764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ivyproschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ivyproschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ivyproschool.com\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/ivyproschool.com\/blog\/wp-json\/wp\/v2\/comments?post=9764"}],"version-history":[{"count":1,"href":"https:\/\/ivyproschool.com\/blog\/wp-json\/wp\/v2\/posts\/9764\/revisions"}],"predecessor-version":[{"id":10567,"href":"https:\/\/ivyproschool.com\/blog\/wp-json\/wp\/v2\/posts\/9764\/revisions\/10567"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ivyproschool.com\/blog\/wp-json\/wp\/v2\/media\/9772"}],"wp:attachment":[{"href":"https:\/\/ivyproschool.com\/blog\/wp-json\/wp\/v2\/media?parent=9764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ivyproschool.com\/blog\/wp-json\/wp\/v2\/categories?post=9764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ivyproschool.com\/blog\/wp-json\/wp\/v2\/tags?post=9764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}