9 ms·
Japanese Grammar in EBNF notation
- hprotagonist 7y ago...However, for real 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. Much like the rest of biological systems, natural language "laws" and formalisms are more or less guaranteed to have a "except when..." clause after them. I tried to think of a recursive "except when" to the above, but couldn't come up with anything appropriately witty.
- gizmo686 7y ago... Except when the formalism is so powerful as to be consistent with anything.
- james_s_tayler 7y ago... except when it's not.
- hprotagonist 7y agoI have a small town in italy with a barber problem i’d like to tell you all about...
- gizmo686 7y agoContext-free grammar was originally invented by linguistics to describe sentence structure. Ultimately the field moved away from them, but they are still the first model of sentence structure taught in introductory linguistics classes (at least the one I took).
- macleginn 7y agoWe know theoretically that language in general is non-context-free. However, proven examples of non-context-free-ness are rare. The field has not really moved away from CFGs as the basis for formalisms (otherwise we can't really parse anything), but the complexity of attributes that need to be passed around to account for even basic phenomena (agreement, question or relative-clause formation, etc.) is such that CFG trees become very complex. Instead people (HPSG and CCG people, for instance) now prefer to use lexicalist models with everything stuffed inside lexical units with complex bottom-up derivation/unification rules.
- haecceity 7y agoImagine wanting to learn Japanese and learning compiler theory just to learn Japanese easier.
- sanxiyn 7y agoA bit off-topic, but you mean parser. Compiler is so much more than parser that I consider equating them harmful.
- deleted 7y ago[deleted]
- deleted 7y ago[deleted]
- irq11 7y agoThis is not terribly dissimilar to the kind of language LARPing that you encounter regularly in Japanese learning communities.
- contravariant 7y agoNot the worst decision I ever made to be honest.
- userbinator 7y agoI wonder if https://en.wikipedia.org/wiki/Buffalo_buffalo_Buffalo_buffalo_buffalo_buffalo_Buffalo_buffalo https://en.wikipedia.org/wiki/Buffalo_buffalo_Buffalo_buffal... has a Japanese equivalent, or perhaps just 100% hirigana will easily confuse this, thus making context-dependency a necessity. The content is good, but unfortunately if I came across this domain name in a search engine result page I would think it was yet more SEO spam --- over two decades of Internet use has made me weary of domains containing words like "best" in them. (For similar examples, think of domains like best-antivirus-2020.online --- sounds like a fake AV scam.) IMHO the proliferation of such TLDs has only made things easier for phishing and such.
- krackers 7y ago> if I came across this domain name in a search engine result page I would think it was yet more SEO spam Their main landing page doesn't inspire much confidence either: https://japanesecomplete.com/purchase https://japanesecomplete.com/purchase The combination of layout and font gives that sketchy feel. I'm sure the content itself is great, but I think it would benefit from a bit more carefully constructed site along with some sort of trial (á la Wanikani) since almost every resource claims to be the panacea you've been looking for.
- SpicyLemonZest 7y agoIt is indeed SEO spam, although atypically well written and informative. At the bottom of the post, they encourage you to pay $2/day (!!) for their learning service hosted at a real .com domain.
- ThrowawayR2 7y agoThe spam pattern becomes clearer if you look at the posting history for articles from this site: https://news.ycombinator.com/from?site=learnjapanese.best https://news.ycombinator.com/from?site=learnjapanese.best It's a pretty consistent pattern of once every couple of days. If you look at the post history for the spammer's main account, they try to disguise their spamming by posting a few miscellaneous Wikipedia articles and the like between posting their site: https://news.ycombinator.com/submitted?id=sova https://news.ycombinator.com/submitted?id=sova You can also see them experimenting with spamming their other sites as well; the poster is always the same individual. https://news.ycombinator.com/from?site=japanesecomplete.com https://news.ycombinator.com/from?site=japanesecomplete.com https://news.ycombinator.com/from?site=learnjapanesebest.wordpress.com https://news.ycombinator.com/from?site=learnjapanesebest.wor...
- euske 7y agoTheir grammar lacks the crucial component that is the recursive structure of natural languages, which was originally pointed by Chomsky, et al. Here's how I (Japanese native) would do it: SENTENCE = S 。 S = BUN* verb | BUN* NP be-verb BUN = NP pp | adv (pp = postposition, or 助詞) NP = noun | adj NP | S NP Warning: this is a highly simplistic version. But this way, things like "今日 築地 で 寿司 を 食った 。 (Today Tsukiji [place-mark] sushi [object-mark] ate .)" could be parsed as follows: (S (BUN (adv 今日)) (BUN (NP (noun 築地)) (pp で)) (BUN (NP (noun 寿司)) (pp を)) (verb 食った)) 。 Then, this can be further extended to a compound sentence: "築地 で 食った 寿司 は うまい 寿司 だった 。 (Tsukiji [place-mark] ate sushi [subject-mark] good sushi was .)" (S (BUN (NP (S (BUN (NP (noun 築地)) (pp で)) (verb 食った)) (NP (noun 寿司))) (pp は)) (NP (adj うまい) (NP (noun 寿司))) (be-verb だった)) 。 p.s. Yoda has nothing to do with this grammar.
- mikekchar 7y agoMy (non-native) criticism :-) The be-verb is optional in S. "S = NP" is completely valid grammatically. Also "adj = BUN* verb | B* NP be-verb" if you allow "i-adjectives" to be classed as verb phrases (as they were historically) and "na-adjectives" to be "noun-phrase ni aru". So you would actually get: SENTENCE = VP | NP VP = BUN* verb | BUN* NP be-verb BUN = NP pp | adv NP = VP? noun I'm also not sure about the fact that "adv NP be-verb" is allowed by this grammar... Edit: spelling
- tasogare 7y agoYes, that’s my criticism as well: a single adj category has no meaning because there is two of adjectives in Japanese, one with verbal trait, the other acting more like nouns. The difference can and needs to be addressed in a grammar. The grandparent point about recursive rule(s) is valid however and their easiness is one of my favorite things in Japanese grammar. Anyway, the problem seems easy at first but it’s totally possible to vaste hours perfecting a grammar that still doesn’t capture frequently occurring construction (been there done that).
- jotakami 7y ago
- mikekchar 7y agoThis is awesome! I've always wanted to try this. The only real complaint I have is that "da" is not actually a copula in the strictest sense. It's a contraction of "de aru". Similarly "na" is not a modifier. It's a contraction of "ni aru". "aru" is the verb which is the closest you get to a copula in Japanese - it means "it exists" for non-animate noun-phrases. So if you say "sakana da", it does mean "It is fish", but so does just "sakana". The copula is implied. The "da" is completely optional and is actually only added for emphasis -- the literal translation is kind of like "That it is fish exists". In literary Japanese you would say "sakana de aru", "de" being the particle that links a verb the the means with which the verb is executed. For example "basu de iku" means "will go by bus" -- bus is the means by which we will go. In "sakana de aru" or "sakana da" we are basically saying that "fish" is the means of its existence. The "na" modifier is also interesting. It is really "ni aru" where "ni" is essentially the "direction" in which something exists. "Something like a fish" would be "sakana no you". If you want to say "It is a fragrance something like a fish" you could say "sakana no you na kaori". Although I'm not aware of any modern Japanese that would express it like this, this is equivalent to "sakana no you ni aru kaori" -- "It is a fragrance that exists in the direction like a fish". Hopefully you can understand. The interesting part of this is that adding "ni aru" to the end of a noun phrase just turns it into a verb phrase. And the even more interesting bit is that the only thing that can modify a noun phrase is a verb phrase. But, you may have heard of "i-adjectives" -- these are adjectives that end in i. In actuality, these are not adjectives! They are verb phrases! So the word "cute" is "kawaii". However, the actual word is "kawai" and the inflection is "i". That's why when you want to say "not cute" it becomes "kawaiku nai" -- the "i" turns into "ku" because you are inflecting a verb. This in turn is why you modify nouns directly with "i-adjectives". "kawai sakana", or "cute fish". Other adjectives are actually noun phrases in Japanese. "yumei na sakana" or "famous fish". This is, again, exactly the same as "yumei ni aru sakana" -- "The fish exists in the direction of fame". So the rules are even simpler than presented in this blog post. By the way, for anyone trying to learn Japanese and who wants to go beyond phrase-book level: learn plain form first and polite form later (if ever). Japanese makes absolutely no sense if you learn polite form first. It's incredibly logical (even the polite form extensions) if you start with plain form.
- krackers 7y ago
- deleted 7y ago[deleted]
- ngcc_hk 7y agoInteresting. Wish it is more complete at lest have some negative. But do not want to pay up.
- Grue3 7y agoMy algorithm ( https://ichi.moe/ https://ichi.moe/ ) assumes almost nothing about the grammar and simply divides the sentences into the most valuable chunks (based on the word's length and how common it is), and then some sequences get bonus scores (for example noun followed by a particle). It performs surprisingly well in real life cases (where strict grammar is unlikely to be followed). I think it's the best algorithm that's currently available. Example text from the blog post: https://ichi.moe/cl/qr/?q=%E3%81%B2%E3%81%A8%E3%81%8C%E3%81%99%E3%81%94%E3%81%84%E3%80%82%E3%81%92%E3%82%93%E3%81%8D%E3%81%AA%E3%81%B2%E3%81%A8%E3%81%8C%E3%81%84%E3%82%8B%E3%80%82%E3%83%A2%E3%83%B3%E3%82%BF%E3%83%8A%E3%81%8C%E3%81%86%E3%81%A4%E3%81%8F%E3%81%97%E3%81%84%E3%80%82%E3%81%92%E3%82%93%E3%81%8D%E3%81%AA%E3%81%B2%E3%81%A8%E3%81%8C%E3%81%86%E3%81%A4%E3%81%8F%E3%81%97%E3%81%84%E3%83%A2%E3%83%B3%E3%82%BF%E3%83%8A%E3%81%AB%E3%81%84%E3%82%8B%E3%80%82%E3%81%84%E3%82%8B%E3%81%AE%E3%81%8C%E3%81%86%E3%81%A4%E3%81%8F%E3%81%97%E3%81%84%E3%83%A2%E3%83%B3%E3%82%BF%E3%83%8A%E3%81%A0%E3%80%82&r=htr https://ichi.moe/cl/qr/?q=%E3%81%B2%E3%81%A8%E3%81%8C%E3%81%...
- GolDDranks 7y agoWhat you are doing is essentially different: you are doing word sequencing and possibly part-of-speech tagging from a character stream. What is being done in this post, is parsing, which imposes a tree-like structure on the input sequence. These two techniques complement each other, and it might be beneficial to first do the word sequencing (the Viterbi algorithm is a good choice) and parsing after that.
- derefr 7y agoJapanese is quite structured, in the sense that it doesn't form a very hairy AST data structure. But, as someone who knows both Japanese and a variety of programming languages, I've always seen the "seams" of Japanese a bit differently. I've always thought of Japanese as a stack-based language, like Forth. A refresher on Forth: in Forth, you run a lexer over text input to get a stream of tokens; but you don't run a parser (or at least not much of one) over the tokens to get an AST. Instead, each lexeme—each "word" in Forth—self-describes as either a literal or a symbol representing a function call. All words the lexer encounters are immediately "run" using the runtime. Structured programming (like defining functions and then later calling them) is enabled by having the runtime itself be a finite-state machine, that can be put in different states by the execution of certain words, such that all words that are executed in the new state are executed to different effect (e.g. the word `[` will make all words up to a matching `]` have the execution semantics of pushing their symbolic representation onto the stack, sort of like a Lisp quote; the `]` itself then captures what's on the stack and builds a function, sort of like the `defmodule` macro does in Elixir.) Analogously, in Japanese, most words are literals, that just push themselves onto the stack; while there are two types of "active" words: grammatical particles and verbs. Each particle is a construction function, which attempts to match and consume a certain shape of existing words on the stack, pushing back a tagged structure in its place; and then verbs consume a particular set of tagged structures from the stack (varying by verb), in any order, leaving on the stack anything they didn't expect, and pushing back a representation of the structured meaning of the sentence-as-a-whole up to that point. I think this is well-represented by showing how Japanese does quotation: 上司は「私は彼が好きじゃない!」と言った。 To transliterate and rewrite this in a Forth-like grammar, with grammatical particles as lower-case keyword symbols, verbs as upper-case bare symbols, and everything else as quoted literal words: "Boss" :subject [ "I" :subject "him" :referent DISLIKE NEGATION ] :cons SAID. Note that, in this particular case, the brackets are sugar here: the sentence would have the same semantics without them. (They're helpful to visually disambiguate where you should mentally backtrack to, but it's clear by the fact that there's two :subject-particles that the inner verb DISLIKE is only going to capture the last-pushed one, leaving the previously-pushed one on the stack for SAID to later consume.) One could also describe this as what a shift-reduce parser does internally, but with the reduction edges triggered as explicit command-words in the input lexeme stream, rather than being triggered implicitly by non-conflicting pattern-matches. And this is also, as it happens, the core of any pure-functional abstract-machine bytecode ISA (e.g. Erlang's BEAM bytecode ISA.) You've got ops that push literals; ops that take patterns of stuff off the stack and push back new product-types containing those same things; and ops for calls to (maybe-built-in) functions named by a pushed symbol term.