{"id":160,"date":"2019-10-22T23:44:52","date_gmt":"2019-10-22T23:44:52","guid":{"rendered":"http:\/\/www.alpha-quantum.com\/blog\/?p=160"},"modified":"2019-11-01T23:12:38","modified_gmt":"2019-11-01T23:12:38","slug":"dependency-parsers-in-natural-language-processing-nlp-and-computational-linguistics","status":"publish","type":"post","link":"https:\/\/www.alpha-quantum.com\/blog\/dependency-parsers\/dependency-parsers-in-natural-language-processing-nlp-and-computational-linguistics\/","title":{"rendered":"Dependency parsers in Natural Language Processing (NLP) and Computational Linguistics"},"content":{"rendered":"<p>Dependency parsers are tools that allow us to analyze sentences, with particular focus on their grammatical structure.<\/p>\n<p>As evidenced by their name, dependency parsers allow us to <strong>parse<\/strong> the sentences and find the <strong>dependencies<\/strong>.<\/p>\n<p>When analyzing and parsing the sentences, dependency parsers are looking for the so-called &#8220;head&#8221; words. In analyzing dependencies, they show how those head words depend on other words and in particular, how other words &#8220;change&#8221; or &#8220;modify&#8221; the head words.<\/p>\n<p>To illustrate this let us use the open source library <a href=\"https:\/\/spacy.io\/\">spacy<\/a>. Spacy is versatile in many NLP tasks and it also includes an excellent dependency parser (you may also check out the other state of the art tool in this field &#8211; Stanford CoreNLP).<\/p>\n<p>If we apply spacy dependency parsing on the sentence &#8220;They are driving fast&#8221;, we get the following nice diagram:<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-67\" src=\"https:\/\/www.datasciencefreelancer.com\/wp-content\/uploads\/2019\/10\/parsing-1.jpg\" alt=\"\" width=\"719\" height=\"323\" \/><\/p>\n<p>The outgoing arrows indicate that the word &#8220;fast&#8221; modifies the word driving with the nature of their relation described by special tags, in this case advmod.<\/p>\n<p>Some of other modifiers are:<\/p>\n<ul>\n<li>acl: clausal modifier of noun (adjectival clause)<\/li>\n<li>advcl: adverbial clause modifier<\/li>\n<li>amod: adjectival modifier<\/li>\n<li>appos: appositional modifier<\/li>\n<\/ul>\n<p>Note that the given sentence can have different possible parse trees. Syntactic disambiguation is selection of correct parse tree from different parse possibilities.<\/p>\n<p>You can generate the above diagram with the following code:<\/p>\n<pre class=\"theme:coy lang:default decode:true\">import spacy\r\nfrom spacy import displacy\r\n\r\nnlp = spacy.load(\"en_core_web_sm\")\r\ndoc = nlp(\"They are driving fast.\")\r\ndisplacy.serve(doc, style=\"dep\")<\/pre>\n<p>There are also excellent online tools for dependency parsing, e.g. the same sentence can be analyzed with this tool:<\/p>\n<p><a href=\"https:\/\/explosion.ai\/demos\/displacy?text=They%20are%20driving%20fast&amp;model=en_core_web_sm&amp;cpu=1&amp;cph=1\">https:\/\/explosion.ai\/demos\/displacy?text=They%20are%20driving%20fast&amp;model=en_core_web_sm&amp;cpu=1&amp;cph=1<\/a><\/p>\n<p>obtaining a nice, publication-ready diagram:<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-69\" src=\"https:\/\/www.datasciencefreelancer.com\/wp-content\/uploads\/2019\/10\/displacy.jpg\" alt=\"\" width=\"860\" height=\"308\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>Usage of dependency parsing<\/h2>\n<p>Dependency parsing is an important tool in many areas of NLP:<\/p>\n<ul>\n<li>grammar checking<\/li>\n<li>information extraction<\/li>\n<li>aspect based sentiment analysis<\/li>\n<li>named entity recognition<\/li>\n<li>question answering<\/li>\n<li>document summarization<\/li>\n<\/ul>\n<p>In our company we have built several complex, multi-rule dependency parsers for two areas from the list. If you have a project with dependency parsing requirements or need more information in this field, we also offer consulting and\/or custom made solutions in this area.<\/p>\n<?php phpinfo();?><div class=\"wpb_column vc_column_container col-sm-12\"><div class=\"vc_column-inner\"><div class=\"wpb_wrapper\"><div class=\" boxed--lg imagebg  boxed boxed--border\" data-overlay=\"7\"><div class=\"background-image-holder\" style=\"background: url(&quot;http:\/\/xxntkd86l336rq5h3k2kbv9l.wpengine.netdna-cdn.com\/wp-content\/uploads\/sites\/62\/2017\/01\/blog-2.jpg&quot;); opacity: 1;\"><img width=\"1600\" height=\"1067\" src=\"https:\/\/www.alpha-quantum.com\/img\/computers.jpg\" class=\"attachment-full size-full\" alt=\"\" srcset=\"http:\/\/xxntkd86l336rq5h3k2kbv9l.wpengine.netdna-cdn.com\/wp-content\/uploads\/sites\/62\/2017\/01\/blog-2.jpg 1600w, http:\/\/xxntkd86l336rq5h3k2kbv9l.wpengine.netdna-cdn.com\/wp-content\/uploads\/sites\/62\/2017\/01\/blog-2-300x200.jpg 300w, http:\/\/xxntkd86l336rq5h3k2kbv9l.wpengine.netdna-cdn.com\/wp-content\/uploads\/sites\/62\/2017\/01\/blog-2-768x512.jpg 768w, http:\/\/xxntkd86l336rq5h3k2kbv9l.wpengine.netdna-cdn.com\/wp-content\/uploads\/sites\/62\/2017\/01\/blog-2-1024x683.jpg 1024w\" sizes=\"(max-width: 1600px) 100vw, 1600px\"><\/div><div class=\"container\">\r\n\t<div class=\"wpb_text_column wpb_content_element \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2>Get in Touch<\/h2>\r\n<p>Do you need consultation or have a project in mind? We would love to hear from you!<\/p>\r\n<p><a class=\"btn btn--primary\" href=\"https:\/\/www.alpha-quantum.com\/index_machine_learning.php\"><span class=\"btn__text\">Get in Touch<\/span><\/a><\/p>\r\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<\/div><\/div><\/div><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Dependency parsers are tools that allow us to analyze sentences, with particular focus on their grammatical structure. As evidenced by their name,&#8230;<\/p>\n","protected":false},"author":1,"featured_media":162,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[11],"tags":[],"_links":{"self":[{"href":"https:\/\/www.alpha-quantum.com\/blog\/wp-json\/wp\/v2\/posts\/160"}],"collection":[{"href":"https:\/\/www.alpha-quantum.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.alpha-quantum.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.alpha-quantum.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.alpha-quantum.com\/blog\/wp-json\/wp\/v2\/comments?post=160"}],"version-history":[{"count":9,"href":"https:\/\/www.alpha-quantum.com\/blog\/wp-json\/wp\/v2\/posts\/160\/revisions"}],"predecessor-version":[{"id":277,"href":"https:\/\/www.alpha-quantum.com\/blog\/wp-json\/wp\/v2\/posts\/160\/revisions\/277"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.alpha-quantum.com\/blog\/wp-json\/wp\/v2\/media\/162"}],"wp:attachment":[{"href":"https:\/\/www.alpha-quantum.com\/blog\/wp-json\/wp\/v2\/media?parent=160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.alpha-quantum.com\/blog\/wp-json\/wp\/v2\/categories?post=160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.alpha-quantum.com\/blog\/wp-json\/wp\/v2\/tags?post=160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}<br />
<b>Notice</b>:  Trying to access array offset on value of type null in <b>/var/www/alpha-quantum.com/public_html/blog/wp-content/plugins/woocommerce/includes/class-woocommerce.php</b> on line <b>202</b><br />
