<p>Hunspell is built for languages which use spaces between words. That makes it easy to get the individual words, then check the spelling or even existence of each word. In Python, if <em>asentence</em> is a string variable, just do:</p>
<blockquote>
<p>asentence.split()</p>
</blockquote>
<p>to get a list of the separate words in <em>asentence</em>.</p>
<p>To find the words in Chinese is more difficult for a computer. <a href="http://technology.chtsai.org/mmseg/" rel="nofollow noreferrer">This link</a> may help. You can download MMSEG as a zip file. According to the author, this algorithm can reach 98% accuracy.</p>
<p>Going from the words to a grammatical analysis is then a completely different and daunting kettle of fish!</p>

CC BY-SA 4.0
2023-11-09T07:47:40.510Z
2023-11-09T07:47:40.510Z
Pedroski
<p>I am looking for structured data of Chinese grammar, however much might have been done. Specifically sentence-level grammar. By &quot;structured data&quot;, I mean something more structured than grammar written in prose / natural language, ideally in a data format like JSON. Here is a hypothetical JSON data format for word morphology rules related to the English word &quot;interconnected&quot;:</p>
<pre><code>{
  name: 'ed',
  load: [
    { form: 'anchor', name: 'base', base: true },
    { form: 'pattern', name: 'consonant', test: 'consonant' },
    { form: 'anchor', head: false }
  ],
  save: [
    { name: 'base' },
    { name: 'consonant' },
    { text: 'ed' },
  ]
}

{
  name: 'inter',
  save: [
    { text: 'inter' },
    { name: 'self' }
  ]
}

{
  save: [
    { rule: 'inter' },
    { name: 'self' },
    { rule: 'ed' }
  ]
}
</code></pre>
<p>This is modeled after the Hunspell dictionaries, which are the main modern digital dictionaries used by OSes, browsers, etc.. The <code>load</code> takes a word from a dictionary and applies the rule to it. The <code>save</code> is the final generated word. So the <code>ed</code> rule says &quot;base: true (meaning, read the first characters of the word), until the first consonant, where the consonant is the last letter. Then save the <code>base + consonant + ed</code>&quot;. The actual full Hunspell format entry is this:</p>
<pre><code>SFX D Y 4
SFX D   0     d          e
SFX D   y     ied        [^aeiou]y
SFX D   0     ed         [^ey]
SFX D   0     ed         [aeiou]y
</code></pre>
<p><em>Sidemote: Hunspell's format is a lot more compact and human readable, but it's a nightmare to parse, so the above JSON is closer to how a computer would perhaps model it after parsing the Hunspell format rule. But that is beside the point.</em></p>
<p>This all just goes to show what I am looking for in terms of &quot;structured data&quot; (even though this is an English example of a word morphology rule). JSON, XML, CSV, or some other data format would be perfect. The next best option is in raw code (which is pseudo-structured I would say, as it's better than natural language, but it's still hard to deal with and port to different places). <a href="https://github.com/vinagrito/pealim/blob/57e3c473d89cce461ab82f1aa4b7ff5ff08b7622/lib/verb_constructor/paal.rb" rel="nofollow noreferrer">This</a> huge pealim code file is for generating Hebrew verbs. It demonstrates what &quot;code&quot; would look like that I'm describing. That demonstrates the point, that code would be a second-best option for structured data for Chinese, after structured data.</p>
<p>So my question is, has anyone compiled (even the start of) a list of sentence-level grammar rules for Chinese, in structured data form, as described? Or if not in structured JSON/etc., then as code? And if not code, what is the remaining last best bet, ideally some natural language text on a website, instead of a PDF or physical book.</p>
<p>The <a href="https://resources.allsetlearning.com/chinese/grammar/" rel="nofollow noreferrer">Chinese Grammar Wiki</a> is an <em>excellent</em> first step in &quot;structuring&quot; Chinese sentence-level grammar rules. Now I'm looking if anyone has taken this further toward a structured form, either as code or data. For example, this could quickly become structured with enough effort.</p>
<p><a href="https://i.sstatic.net/BGFhT.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/BGFhT.png" alt="enter image description here" /></a></p>
<p><em>Mainly I am looking to build on top of it, and if nothing else, to gain inspiration on how to get started modeling sentence-level grammar rules in a structured way.</em></p>

<grammar><sentence-structure>
Collection of Chinese sentence-level grammar rules as semi-structured "data"?
# Collection of Chinese sentence-level grammar rules as semi-structured "data"?

(Asked by: username_0 on 2023-11-09)

I am looking for structured data of Chinese grammar, however much might have been done. Specifically sentence-level grammar. By "structured data", I mean something more structured than grammar written in prose / natural language, ideally in a data format like JSON. Here is a hypothetical JSON data format for word morphology rules related to the English word "interconnected":
{
  name: 'ed',
  load: [
    { form: 'anchor', name: 'base', base: true },
    { form: 'pattern', name: 'consonant', test: 'consonant' },
    { form: 'anchor', head: false }
  ],
  save: [
    { name: 'base' },
    { name: 'consonant' },
    { text: 'ed' },
  ]
}

{
  name: 'inter',
  save: [
    { text: 'inter' },
    { name: 'self' }
  ]
}

{
  save: [
    { rule: 'inter' },
    { name: 'self' },
    { rule: 'ed' }
  ]
}

This is modeled after the Hunspell dictionaries, which are the main modern digital dictionaries used by OSes, browsers, etc.. The load takes a word from a dictionary and applies the rule to it. The save is the final generated word. So the ed rule says "base: true (meaning, read the first characters of the word), until the first consonant, where the consonant is the last letter. Then save the base + consonant + ed". The actual full Hunspell format entry is this:
SFX D Y 4
SFX D   0     d          e
SFX D   y     ied        [^aeiou]y
SFX D   0     ed         [^ey]
SFX D   0     ed         [aeiou]y

Sidemote: Hunspell's format is a lot more compact and human readable, but it's a nightmare to parse, so the above JSON is closer to how a computer would perhaps model it after parsing the Hunspell format rule. But that is beside the point.
This all just goes to show what I am looking for in terms of "structured data" (even though this is an English example of a word morphology rule). JSON, XML, CSV, or some other data format would be perfect. The next best option is in raw code (which is pseudo-structured I would say, as it's better than natural language, but it's still hard to deal with and port to different places). This huge pealim code file is for generating Hebrew verbs. It demonstrates what "code" would look like that I'm describing. That demonstrates the point, that code would be a second-best option for structured data for Chinese, after structured data.
So my question is, has anyone compiled (even the start of) a list of sentence-level grammar rules for Chinese, in structured data form, as described? Or if not in structured JSON/etc., then as code? And if not code, what is the remaining last best bet, ideally some natural language text on a website, instead of a PDF or physical book.
The Chinese Grammar Wiki is an excellent first step in "structuring" Chinese sentence-level grammar rules. Now I'm looking if anyone has taken this further toward a structured form, either as code or data. For example, this could quickly become structured with enough effort.

Mainly I am looking to build on top of it, and if nothing else, to gain inspiration on how to get started modeling sentence-level grammar rules in a structured way.

**Tags:** grammar, sentence-structure


---

## 1 answers

### Answer by username_1 on 2023-11-09. Score: -1

Hunspell is built for languages which use spaces between words. That makes it easy to get the individual words, then check the spelling or even existence of each word. In Python, if *asentence* is a string variable, just do:

> asentence.split()

to get a list of the separate words in *asentence*.

To find the words in Chinese is more difficult for a computer. [This link](http://technology.chtsai.org/mmseg/) may help. You can download MMSEG as a zip file. According to the author, this algorithm can reach 98% accuracy.

Going from the words to a grammatical analysis is then a completely different and daunting kettle of fish!


---

