{"id":815,"date":"2024-10-30T13:26:06","date_gmt":"2024-10-30T17:26:06","guid":{"rendered":"https:\/\/brian.digitalmaddox.com\/blog\/?p=815"},"modified":"2024-10-30T13:26:06","modified_gmt":"2024-10-30T17:26:06","slug":"some-background-on-natural-language-processing-part-1-english","status":"publish","type":"post","link":"https:\/\/brian.digitalmaddox.com\/blog\/?p=815","title":{"rendered":"Some Background on Natural Language Processing &#8211; Part 1: English"},"content":{"rendered":"<p>I thought I would switch topics and start to talk about things like Large Language Models and how they could be applied to things like Geographic Information System (GIS) data.<span class=\"Apple-converted-space\">\u00a0 <\/span>To do this, I think first it would be good to talk about the basis for some of these tools, such as natural language processing (NLP). <span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>NLP is the basis for tools such as LLMs and even the ability to extract information from GIS data such as people, places, and things.<span class=\"Apple-converted-space\">\u00a0 <\/span>As such, I feel it is important to understand NLP as it provides a lot of value to GIS information as well as advanced processing of such information.<\/p>\n<h1>Some background about English<\/h1>\n<p>Before I dive into how NLP works, I first want to talk about the English language and how it relates to NLP.<span class=\"Apple-converted-space\">\u00a0 <\/span>This will give some background about why NLP is hard and how far we have come over the years.<span class=\"Apple-converted-space\">\u00a0 <\/span>So we will have a bit of a history lesson.<span class=\"Apple-converted-space\">\u00a0 <\/span>I love history and I finally have a reason to blog about it.<span class=\"Apple-converted-space\">\u00a0 <\/span>Next post we will dig into the background of how NLP used to work and how it works today.<\/p>\n<h2>What is the English Language?<\/h2>\n<p>First off, English is a horrible language.<span class=\"Apple-converted-space\">\u00a0 <\/span>It is a West Germanic language that is a part of the Indo-European language family.<span class=\"Apple-converted-space\">\u00a0 <\/span>It is a mashup of several different languages and continues to evolve almost yearly with new terms being added.<span class=\"Apple-converted-space\">\u00a0 <\/span>It got its start in what is now the UK prior to the fifth century when it was inhabited Celtic-speaking peoples.<span class=\"Apple-converted-space\">\u00a0 <\/span>Then came the Romans who tried to enforce Latin, but the natives said no for the most part.<\/p>\n<h2>Old English<\/h2>\n<p>Next came the Anglo-Saxons who came to Britain from the area around the northwest of modern <a href=\"https:\/\/en.wikipedia.org\/wiki\/History_of_English\">Germany<\/a>.<span class=\"Apple-converted-space\">\u00a0 <\/span>These Anglo-Saxon travelers brought their <a href=\"https:\/\/en.wikipedia.org\/wiki\/North_Sea_Germanic\">Ingvaeonic<\/a> languages to Britain, displaced the Celts, and then started what we now call Old English.<span class=\"Apple-converted-space\">\u00a0 <\/span>Then while Old English was forming, we throw in some influence form the Vikings who invaded off and on and imparted some of their Norse words into the mix.<span class=\"Apple-converted-space\">\u00a0 <\/span>Then, to top things off, we had four known <a href=\"https:\/\/www.britannica.com\/topic\/Old-English-language\">variants<\/a> of the language that developed in Britain.<\/p>\n<p>An example comes from Beowulf what was written around 1000 AD and here is the first line of it:<\/p>\n<p style=\"padding-left: 40px\">HW\u00c6T:\u00a0 WE GAR-DENA IN GEARDAGUM (So. The Spear-Danes in days gone by)<\/p>\n<h2>Middle English<\/h2>\n<p>Then came the Normans in <a href=\"https:\/\/en.wikipedia.org\/wiki\/Norman_Conquest\">1066<\/a>.<span class=\"Apple-converted-space\">\u00a0 <\/span>The Normans at the time spoke Anglo-Norman \/ Anglo-Norman French \/ Old French.<span class=\"Apple-converted-space\">\u00a0 <\/span>This became the language of the upper class and the courts of the time.<span class=\"Apple-converted-space\">\u00a0 <\/span>English then brought in some of the French words to add to the mix.<span class=\"Apple-converted-space\">\u00a0 <\/span>However, this did simplify the grammar of the language a bit.<span class=\"Apple-converted-space\">\u00a0 <\/span>This then went on to give us Middle English.<span class=\"Apple-converted-space\">\u00a0 <\/span>An example of this is found in <a href=\"https:\/\/chaucer.fas.harvard.edu\/pages\/literary-works\">The Canterbury Tales<\/a>, where one of my high school English teachers made us memorize the first verse of it and scarred me for life.<\/p>\n<p style=\"padding-left: 40px\">Whan that Aprill with his shoures soote (When April with its sweet-smelling showers)<\/p>\n<h2>Early Modern English<\/h2>\n<p>Then we move on to Early Modern English that started to take root in the 15th to 17th centuries, better known as the Renaissance.<span class=\"Apple-converted-space\">\u00a0 <\/span>Here we decided to throw in some Latin, Greek, and even more French words for good measure.<span class=\"Apple-converted-space\">\u00a0 <\/span>The good news is that we started to simplify the grammar even more.<span class=\"Apple-converted-space\">\u00a0 <\/span>During this time, English went through the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Great_Vowel_Shift\">Great Vowel Shift<\/a>.<span class=\"Apple-converted-space\">\u00a0 <\/span>This change modified how long vowels were pronounced and thus threw in some spelling changes.<span class=\"Apple-converted-space\">\u00a0 <\/span>The results of this shift have had wide-ranging impacts, including the basis for spelling and pronunciation mismatches in Modern English.<span class=\"Apple-converted-space\">\u00a0 <\/span>Plus the English and French began their love\/hate relationship so it is possible that some anti-French sentiment caused some words to be modified to lose their influence, so to speak.<span class=\"Apple-converted-space\">\u00a0 <\/span>This was also the language used by Shakespeare who also added words to the language.<span class=\"Apple-converted-space\">\u00a0 <\/span>Here is an example of what the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Lord%27s_Prayer\">Lord\u2019s Prayer<\/a> would have looked like during this period.<\/p>\n<p style=\"padding-left: 40px\">Our father which art in heauen, hallowed be thy name. Thy kingdome come. Thy will be done, in earth, as it is in heauen.<\/p>\n<h2>Modern and Contemporary English<\/h2>\n<p>We finally arrive at Modern English which started in the 17th century and continues on today.<span class=\"Apple-converted-space\">\u00a0 <\/span>Thanks to the British Empire, English spread globally.<span class=\"Apple-converted-space\">\u00a0 <\/span>This global contact ended up adding more word to the language.<span class=\"Apple-converted-space\">\u00a0 <\/span>It went on to become the language of business, science, and diplomacy.<\/p>\n<p>Then you may have heard of a bit of a spat between the British and a bunch of upstart colonies that formed the United States.<span class=\"Apple-converted-space\">\u00a0 <\/span>As time went on, American English began to differ a bit from British English, mainly in some spellings and different words for things (a car\u2019s hood vs a car\u2019s bonnet).<span class=\"Apple-converted-space\">\u00a0 <\/span>As the empire fell, we also got various dialects of English including Canadian and Australian English.<\/p>\n<h1>A Language that Confuses Native Speakers<\/h1>\n<p>This brings us to Contemporary English, a language with a large history of change and influences and words from various cultures.<span class=\"Apple-converted-space\">\u00a0 <\/span>Unlike Latin-based languages, it really does not follow many rules.<span class=\"Apple-converted-space\">\u00a0 <\/span>It tends to reuse words with different tenses and even different parts of speech.<span class=\"Apple-converted-space\">\u00a0 <\/span>The same word can have a lot of different and even non-related meanings.<span class=\"Apple-converted-space\">\u00a0 <\/span>Consider this, a perfectly valid sentence today:<\/p>\n<p style=\"padding-left: 40px\">I banked(1) on the advice from my friend and ended up making a lot of bank(2) by playing the bank(3) of slot machines at the casino.<span class=\"Apple-converted-space\">\u00a0 <\/span>To keep it safe, I decided to take it to the new bank(4) that they built on the south bank(5) of the river.<\/p>\n<p>As a native American English speaker, this makes me want to cry.<span class=\"Apple-converted-space\">\u00a0 <\/span>This is why it is so hard for non-native English speakers to learn the language.<span class=\"Apple-converted-space\">\u00a0 <\/span>Let us look at the abomination that I just wrote.<span class=\"Apple-converted-space\">\u00a0 <\/span>The word bank is used as a:<\/p>\n<ol>\n<li>Verb: meaning to rely on<\/li>\n<li>Noun (slang really): meaning money<\/li>\n<li>Noun: meaning a row of similar items<\/li>\n<li>Noun: meaning a place to store things for later use<\/li>\n<li>Noun: sloping raised land near a river<\/li>\n<\/ol>\n<p>Imagine you are someone trying to learn English and you come across that sentence.<span class=\"Apple-converted-space\">\u00a0 <\/span>Your head would explode.<span class=\"Apple-converted-space\">\u00a0 <\/span>Think about how hard it would be to figure out what was actually being said.<span class=\"Apple-converted-space\">\u00a0 <\/span>Note that I could have added another verb use by saying something like \u201cOn the way there, I had to bank to the left in my car to get in the proper lane.\u201d<span class=\"Apple-converted-space\">\u00a0 <\/span>Thankfully I felt bad enough making the above sentence in the first place.<\/p>\n<p>Now imagine a computer trying to parse this.<span class=\"Apple-converted-space\">\u00a0 <\/span>Remember that a computer is a glorified calculator.<span class=\"Apple-converted-space\">\u00a0 <\/span>Admittedly that sentence was made up to be a specific edge case, but it illustrates the point that if a human would have trouble understanding something, you can be sure that I computer will too.<span class=\"Apple-converted-space\">\u00a0 <\/span>And NLP has come a long way and these days would actually be able to make use of that sentence.<\/p>\n<p>Distinguishing the meaning of the same word used in many different contexts has been, and continues to be, one of the primary reasons that getting NLP right has been so hard.<span class=\"Apple-converted-space\">\u00a0 <\/span>We have ended up with many historic and structural complexities that have led to the language today.<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>Historically, most NLP research has been done on the English language due to its dominance in commerce and the link.<span class=\"Apple-converted-space\">\u00a0 <\/span>NLP into other languages is working to catch up, but for these blog posts I am going to consider that to be out of scope since, well, I do not speak those languages.<\/p>\n<p>And to add in another complication, research and methods of NLP for the English languages do not exactly work well for other languages.<span class=\"Apple-converted-space\">\u00a0 <\/span>Each language has its own grammar and usage.<span class=\"Apple-converted-space\">\u00a0 <\/span>Some languages such as Spanish and French (<a href=\"https:\/\/rom.uga.edu\/what-are-romance-languages#:~:text=The%20major%20languages%20of%20the,a%20political%20and%20cultural%20significance.\">Romance Languages<\/a>) are similar at least.<span class=\"Apple-converted-space\">\u00a0 <\/span>But it is basically an apples to oranges comparison to try to apply English NLP principals to something like an Asian language.<\/p>\n<h1>Conclusion<\/h1>\n<p>I think I will leave things here for today.<span class=\"Apple-converted-space\">\u00a0 <\/span>Next time I will go into the history of how NLP worked in the past before moving on to how it works today.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I thought I would switch topics and start to talk about things like Large Language Models and how they could be applied to things like Geographic Information System (GIS) data.\u00a0 To do this, I think first it would be good &hellip; <a href=\"https:\/\/brian.digitalmaddox.com\/blog\/?p=815\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":818,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[23,39],"class_list":["post-815","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-gis","tag-nlp"],"_links":{"self":[{"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/815","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=815"}],"version-history":[{"count":2,"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/815\/revisions"}],"predecessor-version":[{"id":817,"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/815\/revisions\/817"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=\/wp\/v2\/media\/818"}],"wp:attachment":[{"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/brian.digitalmaddox.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}