{"id":811,"date":"2020-01-04T19:02:54","date_gmt":"2020-01-05T02:02:54","guid":{"rendered":"http:\/\/learnjapanese.best\/?p=811"},"modified":"2024-08-27T02:22:56","modified_gmt":"2024-08-27T02:22:56","slug":"ebnf-grammar-japanese","status":"publish","type":"post","link":"https:\/\/japanesecomplete.com\/articles\/?p=811","title":{"rendered":"Japanese Grammar in EBNF notation"},"content":{"rendered":"\n<p class=\"has-small-font-size\">We create a 5-rule parser to efficiently and accurately parse affirmative present tense sentences in Japanese.  With just 5 rules you can understand Japanese grammar deeply.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Deconstructing Japanese<\/h2>\n\n\n\n<p>Linguistics is often unnecessarily complicated.  &#8220;Why state concisely with one term when there are 300 different varieties for these intimates and particulars?!&#8221;  Simplicity speaks volumes and good teachers teach simple concepts that help unify greater features easily.<\/p>\n\n\n\n<p>To that end, let&#8217;s see if we can produce Japanese with an EBNF grammar.<\/p>\n\n\n\n<p>For this we will be using <a href=\"https:\/\/github.com\/Engelberg\/instaparse\">an excellent functional library for clojure called Instaparse<\/a>.  <\/p>\n\n\n\n<p><a href=\"http:\/\/instaparse-live.matt.is\/#\/-LxnE95QbDy2LZ_m5XAZ\/v1\">You can see a <em>live<\/em> <em>demo<\/em> of Instaparse online with this grammar here.<\/a><\/p>\n\n\n\n<p>Update: 2020-1-8: A fully recursive parser can be found here <a href=\"http:\/\/instaparse-live.matt.is\/#\/-Ly5y7xvJoDkHhIs0UKD\/v1\">http:\/\/instaparse-live.matt.is\/#\/-Ly5y7xvJoDkHhIs0UKD\/v1<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s an EBNF grammar?<\/h2>\n\n\n\n<p>It&#8217;s like a regular expression for sentences.  &#8220;Extended Backus-Naur Form.&#8221; If you&#8217;re familiar, skip ahead.  If not&#8230;<br><a href=\"https:\/\/condor.depaul.edu\/ichu\/csc447\/notes\/wk3\/BNF.pdf\">Here&#8217;s a useful slideshow.<\/a>  The wikipedia article is not for the uninitiated, but <a href=\"http:\/\/matt.might.net\/articles\/grammars-bnf-ebnf\/\">this article<\/a> is a bit clearer if you are new to this way of representing grammars.       EBNF is from the realm of &#8220;Context-Free Grammars&#8221; and is mainly used in computing.  Given that it is definitely about grammar and syntax, EBNF proves very useful in language analysis and generation.  You make rules for breaking down sequences of characters (sentences) into labeled output chunks (parse tree).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Is it possible to parse Japanese with EBNF?<\/h2>\n\n\n\n<p>Can we make any real headway using <em>computer syntax<\/em> to decipher human language?  English seems impossible for native language speakers to parse at times.  Is it really possible to parse Japanese with EBNF and label parts of speech accurately?<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u306f\u3044\uff01 Yes!<\/h3>\n\n\n\n<p>Yes!  However, for <strong>real<\/strong> Japanese from the wild there would need to be many many rules, and any slight deviations from the rules would not result in a full parse.  So, rather than try and build our own google translate today, why don&#8217;t we just try to cover the maximum amount of Japanese with the minimum amount of rules.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"648\" height=\"504\" src=\"https:\/\/japanesecomplete.com\/articles\/wp-content\/uploads\/2020\/01\/screen-shot-2020-01-04-at-18.52.52.png\" alt=\"5 Simple Rules to Parse Japanese Grammar with EBNF notation\" class=\"wp-image-828\"\/><figcaption>Extension of Rule 2 (JAR  = ) by adding &#8221; | JAR* noun-no no &#8221; ensures recursive reading.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Rules for an EBNF Japanese Grammar<\/h2>\n\n\n\n<p>Japanese has nouns, verbs, particles, and sentence-final-fitters.  That&#8217;s it. *  <strong>With 5 concepts we can cover the whole Japanese grammar.<\/strong>  Amazing.  Japanese is regular enough that its composition can be described in a handful of rules.<\/p>\n\n\n\n<ol><li>A sentence is made of zero or more Bunsetsu-Jars and a Sentence-Final-Fitter. <br><strong>S = JAR* SFF<\/strong><\/li><li>A Bunsetsu-Jar is made of zero or more Modifiers, and must have a noun and a particle. <br><strong>JAR = M* noun-no P |  JAR* noun-no no<\/strong> <br><br><em>[UPDATE 2020-1-8: fully recursive with extension of rule 2]<\/em><br><\/li><li>Particles can be any of the Japanese grammar particles that describe the role of their preceding word in a sentence: \u304c\u3001\u3092\u3001\u3068\u3001\u3067\u3001\u306b\u3001etc\u3002 <br><strong>P = \u304c | \u3092 | \u3068 | \u3067 | \u306b &#8230;<\/strong><\/li><li>Sentence-Final-Fitters have only 4 options and can be either nouns with the Copula \u3060 (da), or simply verbs with u, or verbs with i.<br><strong>SFF = noun-no \u3060\u3002 | noun-na \u3060\u3002 | verb-u\u3002 | verb-i\u3002<br><\/strong>(sentence-final period included in this rule)<\/li><li>Modifiers can be nouns  with their relevant letter (&#8220;no&#8221; or &#8220;na&#8221;), or simply verb-u or verb-i.<br><strong>M = noun-no \u306e | noun-na \u306a | verb-u | verb-i<\/strong><\/li><\/ol>\n\n\n\n<p>With just 5 main rules we can parse all of Japanese.  That&#8217;s exciting!  Granted, this is not negation or past tense, just present affirmative, but with small extensions those advancements are accommodatable. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Visuals to Help Expound<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"900\" height=\"400\" src=\"http:\/\/articles.japanesecomplete.com\/wp-content\/uploads\/2020\/01\/parse_1.png\" alt=\"\" class=\"wp-image-821\"\/><figcaption>Sentence ::= Complete-Jar*  SFF.<\/figcaption><\/figure>\n\n\n\n<p>Pictured Above: Any number of Complete Bunsetsu Jars (means a Jar with contents and a Lid =  a particle) plus a Sentence-Final-Fitter make a Japanese sentence.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"900\" height=\"400\" src=\"http:\/\/articles.japanesecomplete.com\/wp-content\/uploads\/2020\/01\/parse_2.png\" alt=\"\" class=\"wp-image-823\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"900\" height=\"400\" src=\"http:\/\/articles.japanesecomplete.com\/wp-content\/uploads\/2020\/01\/parse_3.png\" alt=\"\" class=\"wp-image-824\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"900\" height=\"400\" src=\"http:\/\/articles.japanesecomplete.com\/wp-content\/uploads\/2020\/01\/ebnf_6.png?w=900\" alt=\"\" class=\"wp-image-845\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"900\" height=\"400\" src=\"http:\/\/articles.japanesecomplete.com\/wp-content\/uploads\/2020\/01\/ebnf_5.png?w=900\" alt=\"\" class=\"wp-image-831\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Experimental Data<\/h2>\n\n\n\n<p class=\"has-text-align-center has-large-font-size\">\u3052\u3093\u304d\u306a\u3072\u3068\u304c\u3046\u3064\u304f\u3057\u3044\u30e2\u30f3\u30bf\u30ca\u306b\u3044\u308b\u3002<br>\u3044\u308b\u306e\u304c\u3046\u3064\u304f\u3057\u3044\u30e2\u30f3\u30bf\u30ca\u3060\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Results from InstaParsing<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"889\" height=\"218\" src=\"http:\/\/articles.japanesecomplete.com\/wp-content\/uploads\/2020\/01\/screen-shot-2020-01-04-at-18.54.04.png\" alt=\"\" class=\"wp-image-829\"\/><\/figure>\n\n\n\n<p>Notice Japanese has no spaces, all parsing relies on accurate detection of symbol in sequence.  ImagineifEnglishhadnospaceswoulditbehardtoread?<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Recursion Update 2020-1-8<\/strong><\/h2>\n\n\n\n<p>By extending Rule 2 (JAR = &#8230; ) to include JAR*, we achieve full recursion on Japanese terms using \u306e [no]<\/p>\n\n\n\n<p><a href=\"http:\/\/instaparse-live.matt.is\/#\/-Ly63ijYzrhVjVNf7b7a\/v1\">http:\/\/instaparse-live.matt.is\/#\/-Ly63ijYzrhVjVNf7b7a\/v1<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"576\" height=\"398\" src=\"http:\/\/articles.japanesecomplete.com\/wp-content\/uploads\/2020\/01\/screen-shot-2020-01-08-at-14.31.11.png?w=576\" alt=\"\" class=\"wp-image-843\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Death to Adjectives<\/h2>\n\n\n\n<p>Japanese has nouns that take \u306a [na] and nouns that take \u306e [no] when they are used as modifiers.  <\/p>\n\n\n\n<p>Japanese also has verbs that end with an \u3046 [u = oo as in &#8220;food&#8221;] sound and verbs that end with an \u3044 [i = ee as in &#8220;week&#8221;] sound.<\/p>\n\n\n\n<p>Bringing &#8220;adjectives&#8221; into the mix just gets things really dirty and offers no benefit to the learner.  Stick with 2 kinds of verb and 2 kinds of noun and Japanese will be easy to master.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"506\" height=\"433\" src=\"http:\/\/articles.japanesecomplete.com\/wp-content\/uploads\/2020\/01\/etym-altar-5.png\" alt=\"\" class=\"wp-image-826\"\/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Parsing Improves Comprehension<\/h2>\n\n\n\n<p>Important in language learning are the exercises that parse written language correctly.  Learning how the written language is parsed can help one&#8217;s mental model, and this will lend to stronger audible comprehension thanks to a deeper understanding of the underlying structure.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"3750\" height=\"5625\" src=\"http:\/\/articles.japanesecomplete.com\/wp-content\/uploads\/2020\/01\/buddha-stone.jpg\" alt=\"\" class=\"wp-image-827\"\/><\/figure>\n\n\n\n<p>Thanks for reading!  This breakdown brought to you by <a href=\"https:\/\/japanesecomplete.com\/articles\/\">Japanese Complete<\/a>, Rapid Fluency Acquisition Platform. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"580\" height=\"511\" src=\"http:\/\/articles.japanesecomplete.com\/wp-content\/uploads\/2019\/12\/babyfox2.jpg?w=580\" alt=\"\" class=\"wp-image-787\"\/><\/figure>\n\n\n\n<p class=\"has-small-font-size\"><strong>Related Initiatives<br><\/strong><a href=\"https:\/\/en.wikipedia.org\/wiki\/MeCab\">Standard Morphological Analyzer MeCab <\/a><br><a href=\"https:\/\/www.aclweb.org\/anthology\/W11-3503.pdf\">Google IME input method super fast lookups with a lossless trie<\/a><br><a href=\"https:\/\/github.com\/google\/sentencepiece\">Tokenizer &#8220;Sentencepiece&#8221;<\/a><br><a href=\"https:\/\/community.wanikani.com\/t\/dependency-parsing-for-japanese\/17984\">Parsing Convo from 2010 on WaniKani Community<\/a><br><a href=\"http:\/\/instaparse-live.matt.is\/#\/-LxnE95QbDy2LZ_m5XAZ\/v1\">Awesome demo of our simplistic parser on Instaparse Live<\/a><\/p>\n\n\n\n<p class=\"has-small-font-size\">*When we say &#8220;that&#8217;s it,&#8221; we are putting words like \u304a\u3044\u3057\u3044 into the verb-i column, and words like \u3052\u3093\u304d\u306a into the noun-na column.  Simplifying into two categories, nouns and verbs, actually proves immensely useful and practical in Japanese.  It&#8217;s a simplification that should be in all the textbooks and literature.  Congrats 2020.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"604\" height=\"453\" src=\"http:\/\/articles.japanesecomplete.com\/wp-content\/uploads\/2019\/12\/zen.jpg\" alt=\"\" class=\"wp-image-583\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>We create a 5-rule parser to efficiently and accurately parse affirmative present tense sentences in Japanese.  With just 5 rules you can understand Japanese grammar deeply.<\/p>\n","protected":false},"author":2,"featured_media":777,"comment_status":"open","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[59,60,138,142,149,158,232,259],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v15.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Japanese Grammar in EBNF notation<\/title>\n<meta name=\"description\" content=\"Japanese Grammar in EBNF notation. With 5 simple rules we can parse real Japanese and preserve the contextual and syntactic information.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/japanesecomplete.com\/articles\/?p=811\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Japanese Grammar in EBNF notation\" \/>\n<meta property=\"og:description\" content=\"Japanese Grammar in EBNF notation. With 5 simple rules we can parse real Japanese and preserve the contextual and syntactic information.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/japanesecomplete.com\/articles\/?p=811\" \/>\n<meta property=\"og:site_name\" content=\"Intuition for Japanese\" \/>\n<meta property=\"article:published_time\" content=\"2020-01-05T02:02:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-08-27T02:22:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/japanesecomplete.com\/articles\/wp-content\/uploads\/2019\/12\/bookshelf.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"945\" \/>\n\t<meta property=\"og:image:height\" content=\"1433\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\">\n\t<meta name=\"twitter:data1\" content=\"hake_hayashi\">\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data2\" content=\"3 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/japanesecomplete.com\/articles\/#organization\",\"name\":\"Japanese Complete\",\"url\":\"https:\/\/japanesecomplete.com\/articles\/\",\"sameAs\":[],\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/japanesecomplete.com\/articles\/#logo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/japanesecomplete.com\/articles\/wp-content\/uploads\/2020\/12\/logo.png\",\"width\":450,\"height\":300,\"caption\":\"Japanese Complete\"},\"image\":{\"@id\":\"https:\/\/japanesecomplete.com\/articles\/#logo\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/japanesecomplete.com\/articles\/#website\",\"url\":\"https:\/\/japanesecomplete.com\/articles\/\",\"name\":\"Intuition for Japanese\",\"description\":\"Learn Japanese, avoid the Struggle.\",\"publisher\":{\"@id\":\"https:\/\/japanesecomplete.com\/articles\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/japanesecomplete.com\/articles\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/japanesecomplete.com\/articles\/?p=811#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/japanesecomplete.com\/articles\/wp-content\/uploads\/2019\/12\/bookshelf.jpg\",\"width\":945,\"height\":1433},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/japanesecomplete.com\/articles\/?p=811#webpage\",\"url\":\"https:\/\/japanesecomplete.com\/articles\/?p=811\",\"name\":\"Japanese Grammar in EBNF notation\",\"isPartOf\":{\"@id\":\"https:\/\/japanesecomplete.com\/articles\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/japanesecomplete.com\/articles\/?p=811#primaryimage\"},\"datePublished\":\"2020-01-05T02:02:54+00:00\",\"dateModified\":\"2024-08-27T02:22:56+00:00\",\"description\":\"Japanese Grammar in EBNF notation. With 5 simple rules we can parse real Japanese and preserve the contextual and syntactic information.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/japanesecomplete.com\/articles\/?p=811\"]}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/japanesecomplete.com\/articles\/?p=811#article\",\"isPartOf\":{\"@id\":\"https:\/\/japanesecomplete.com\/articles\/?p=811#webpage\"},\"author\":{\"@id\":\"https:\/\/japanesecomplete.com\/articles\/#\/schema\/person\/8a54e4605a90cf79abab2ca1458f8db7\"},\"headline\":\"Japanese Grammar in EBNF notation\",\"datePublished\":\"2020-01-05T02:02:54+00:00\",\"dateModified\":\"2024-08-27T02:22:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/japanesecomplete.com\/articles\/?p=811#webpage\"},\"commentCount\":13,\"publisher\":{\"@id\":\"https:\/\/japanesecomplete.com\/articles\/#organization\"},\"image\":{\"@id\":\"https:\/\/japanesecomplete.com\/articles\/?p=811#primaryimage\"},\"keywords\":\"EBNF,ebnf notation,Japanese EBNF CFG,japanese grammar,japanese language,japanese parsing,noun-na noun-no verb-u verb-i,simplifying japanese\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/japanesecomplete.com\/articles\/?p=811#respond\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/japanesecomplete.com\/articles\/#\/schema\/person\/8a54e4605a90cf79abab2ca1458f8db7\",\"name\":\"hake_hayashi\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/japanesecomplete.com\/articles\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6d959be61c196fb7e3419875a80dbe51?s=96&d=mm&r=g\",\"caption\":\"hake_hayashi\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/japanesecomplete.com\/articles\/index.php?rest_route=\/wp\/v2\/posts\/811"}],"collection":[{"href":"https:\/\/japanesecomplete.com\/articles\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/japanesecomplete.com\/articles\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/japanesecomplete.com\/articles\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/japanesecomplete.com\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=811"}],"version-history":[{"count":4,"href":"https:\/\/japanesecomplete.com\/articles\/index.php?rest_route=\/wp\/v2\/posts\/811\/revisions"}],"predecessor-version":[{"id":1425,"href":"https:\/\/japanesecomplete.com\/articles\/index.php?rest_route=\/wp\/v2\/posts\/811\/revisions\/1425"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/japanesecomplete.com\/articles\/index.php?rest_route=\/wp\/v2\/media\/777"}],"wp:attachment":[{"href":"https:\/\/japanesecomplete.com\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=811"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/japanesecomplete.com\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=811"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/japanesecomplete.com\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=811"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}