Elamur Research

CFG based grammar checker for Latvian

Paper · 2011 · Daiga Deksne and Raivis Skadiņš

Summary

A grammar checker for Latvian needs to know which words belong together before it can decide whether their endings agree. Related words can occur far apart, and a written form can have several grammatical readings. An earlier checker, implemented in 2004, looked for patterns among nearby words. That caught useful cases, but the authors report that some rules had to be switched off because they mistook legitimate readings for errors. The checker also slowed as rules were added. Daiga Deksne and Raivis Skadiņš build a new checker around parsing, the process of identifying the grammatical structure of a sentence.

The authors adapt a parser originally developed for machine translation. It builds phrases with a context-free grammar extended to record properties such as case, number and gender. Rules for correct constructions build phrases and, when possible, a complete sentence. Error rules look for suspect combinations of words or phrases. A complete correct analysis can suppress a matching syntactic warning. When only parts of the sentence can be analyzed, a candidate has to cover a larger phrase than the competing correct rule covers. A separate grammar handles shorter capitalization and style patterns.

The authors tune the rules on a development corpus of 9364 sentences and assess the checker on a separate test corpus of 4814 sentences withheld from the rule developers. The evaluation compares the checker’s findings with a human-reviewed record of errors and expected corrections. Across all error types, precision is 0.833 on development text and 0.710 on test text. Recall is 0.290 on the development corpus. The authors report recall there because the development sentences were marked in advance. Results vary considerably by category. Words that should be written together are detected with development recall of 0.761, while agreement errors have development recall of 0.247 and test precision of 0.426.

The paper demonstrates how sentence analysis can prevent a locally plausible warning from reaching the writer. Its results measure the resulting checker, with no head-to-head benchmark against the earlier implementation. The checker runs in the background in Microsoft Word and OpenOffice Writer. In the authors’ user evaluation, respondents found it helpful and preferred a checker that gave reliable warnings, even if some errors escaped detection. That preference matters for interpreting the results of a system intended for everyday grammatical error correction.

Deep dive: CFG based grammar checker for Latvian

How a Latvian grammar checker uses sentence structure to detect errors, suggest corrections, and limit false alarms in edited text. · about 34 minutes to read

The problem and its context

Why a nearby word can be misleading

A word ending supplies evidence about how a word is being used, and that evidence can admit several interpretations. In the authors’ account of Latvian, the same form can have several grammatical analyses. The ending can therefore make a grammatical warning look plausible before the checker has worked out what the word is doing in the sentence. This is a problem of morphology, the structure and grammatical variation of words.

Agreement adds a second question. A checker has to identify the elements whose grammatical properties ought to match, then decide which readings of those elements are relevant. With relatively free word order, the elements involved can be separated by other material. Checking a short sequence of words can work when the relationship regularly appears in that sequence. As the separation grows or the intervening material varies, a checker needs a way to recognize the relationship across more of the sentence. The paper makes the ability to analyze phrases central to that task.

Consider the difference between proposing that a noun has a certain gender and proposing that a pronoun should agree with that noun. The first judgment can come from an analysis of the noun form. The second also requires identifying which noun the pronoun goes with. A mismatch matters if the words have the proposed relationship and the proposed analyses fit their use there. A rule that responds to the mismatch alone risks asking the writer to change a form that already belongs to a valid construction.

The authors also need the checker to work on sentences for which its syntactic account is incomplete. A sentence may resist analysis because it contains a grammatical error. It can also resist analysis because its correct structure falls outside the rules the authors have written. A practical checker needs to continue looking at the portions it can understand in either case. Treating an incomplete parse as a reason to investigate preserves that possibility without making a missing grammatical analysis sufficient evidence for a warning.

What the earlier checker could express

The paper places the new system after the first Latvian and Lithuanian checkers, implemented in 2004. The earlier approach used advanced pattern matching with almost 200 rules. Rules could refer to grammatical categories and properties, as well as to specific words and punctuation. Their scope was constrained by where the relevant items appeared in relation to one another.

One example concerns an imperative verb followed by the Latvian word lūdzu, glossed as “please.” When that sequence matched, the checker could propose placing a comma between the verb and the adverb. The pattern was useful because it specified a construction through the order and grammatical character of nearby items. It also directly identified where the suggested change belonged. This shows what a local rule can do when the surface arrangement supplies the evidence it needs.

Another rule dealt with the gender of a pronoun. It looked for a nominative noun, a comma, the preposition uz and a form of kurš. The pronoun had to have the specified case and number combination, and the genders assigned to the noun and pronoun had to differ. If those conditions held, the rule proposed changing the gender of the pronoun to match the noun. The example shows how much grammatical detail a pattern can carry. It still depends on the noun, punctuation, preposition and pronoun appearing in the prescribed arrangement.

Both examples concern situations in which the checker can locate the relevant words by walking through a neighboring sequence. A misplaced comma and a pronoun ending require different corrections, but the same basic approach can propose them. The more difficult cases are those whose diagnosis depends on recognizing a relationship that survives a change in where the words appear. The paper says that the earlier rule format could express only patterns over nearby words, leaving long-distance errors and more complicated structures beyond its reach.

The authors attribute another problem to the number of possible readings of a word. A pattern might have all of its formal conditions satisfied under some combination of readings, even though another reading gave the actual sentence a grammatical interpretation. The checker had no general sentence analysis to settle that question. The authors report that they disabled many rules because of false alarms arising from this ambiguity. Adding linguistic detail to a pattern was useful only if the checker could tell when that detail applied.

They also describe the earlier matching procedure as slow and say that adding rules slowed it further. This mattered for a tool expected to check text during writing. A new rule could extend coverage while increasing processing work and, if it responded to an ambiguous reading, adding warnings a writer would have to dismiss. These were the implementation problems that motivated the change of approach. The paper draws on the authors’ experience with the earlier system when describing them.

Why reuse a sentence parser?

The authors had access to a Latvian parser developed for translation. A translation parser already had to make sense of relationships within phrases and sentences, which made it a starting point for the checker. In checking, the structure serves a different immediate purpose. It supplies evidence that a stretch of text has a valid grammatical reading, or helps locate a more specific difficulty when the full sentence cannot be analyzed.

This makes the definition of a correct construction important in its own right. A checker that produces warnings from a list of error patterns mainly needs a representation of the situations it wants to flag. A checker that can use grammatical structure to suppress a warning also needs patterns for ordinary correct sentences and phrases. Those patterns determine when an apparently suspicious string belongs to a construction the checker accepts.

A parser that returns only a preferred reading would limit this use. An error rule might have matched a stretch of text even where a larger grammatical reading is available. Conversely, an error candidate could be worth examining even if it never appears inside a tree for a complete sentence. The authors therefore want access to the alternatives made available by the grammar. They also want the analyzer to retain usable stretches when the input will not yield a single complete tree.

The paper specifies another requirement that gives this design its practical tension. A structure marked correct should really be grammatical. If the correct rules accept too much, they can shield an error from inspection. If they accept too little, a legitimate sentence can lose that protection. The choice to base error checking on positive grammatical evidence makes the coverage and selectivity of the correct rules part of the checker’s behavior.

The new design keeps a place for checks that genuinely are local. Simple surface formatting can be checked with patterns over the text. Naming conventions and some kinds of style can be expressed over short strings of words. Grammatical relationships receive the richer analysis where the authors consider it necessary. That division follows from the examples the earlier implementation brought into focus. A punctuation pattern with a reliable local cue and an agreement judgment that depends on a phrase structure place different demands on the checker.

The method, step by step

From input text to possible grammatical readings

The checker works as a sequence of components. The tokenizer first turns the input into token objects and identifies sentence boundaries. Each object has a type, such as word, abbreviation, punctuation or numeric token. The later operations receive sentences as their units of work. Here tokenization provides the shared positions that formatting checks, grammatical analysis and proposed corrections can refer to.

A simple error locator checks formatting by means of regular expressions. A regular expression describes a pattern in text and can identify a surface irregularity directly. An analysis of which words form a noun phrase is unnecessary for such a check. Findings from the formatting component can travel separately to the last stage, where the system combines them with the findings from the parser.

The morphological analyzer attaches a grammatical analysis to each token. The account of ambiguity is important here. A token can enter the parser with more than one possible reading, so a later rule may recognize an interpretation that an early commitment would have discarded. The grammar can use readings of individual tokens when it builds phrases and can test properties of the phrases once they have been built.

The surface string and its grammatical features play different roles. A word may matter to a rule because it is a particular lexical item, as in the rule involving piemēram. It can also matter because a reading assigns it a grammatical category or a feature such as number. By making both available, the checker can express conditions that apply to a general construction and conditions restricted to a particular expression.

How the Latvian checker produces warnings and corrections

The steps in order.

How the Latvian checker produces warnings and correctionsStep 1: Identify tokens and sentence boundaries1. Identify tokens and sentence boundariesStep 2: Locate simple formatting errors with regular expressions2. Locate simple formatting errors with regular expressionsStep 3: Attach morphological analyses to tokens3. Attach morphological analyses to tokensStep 4: Build grammatical phrases and match error rules4. Build grammatical phrases and match error rulesStep 5: Inspect spans for reportable errors5. Inspect spans for reportable errorsStep 6: Generate corrections from applicable rules6. Generate corrections from applicable rulesStep 7: Merge findings for the calling application7. Merge findings for the calling application

The flow includes several opportunities to withhold a candidate before it reaches the writer. A combination of grammatical features may fail a rule’s conditions. A putative error may also overlap a valid construction that makes the warning inappropriate. The checker first acquires the information those judgments require and then has a dedicated stage for reading the parser’s output. A match and a report occur at different points in the process.

Building phrases with grammatical features

A context-free grammar describes how categories combine into larger units. A noun can supply a noun phrase, and a sentence rule can combine a noun phrase, a verb and another noun phrase. These category-level descriptions specify the kinds of constituents that may combine. The paper uses such rules to illustrate the starting point for syntax and grammar formalisms.

Category names alone leave out features that are essential for Latvian agreement. Two constituents can have the categories demanded by a rule while differing in case, gender or number. The authors’ adapted grammar gives properties to both the individual input symbols, called terminals, and the categories that rules build, called nonterminals. A noun phrase can therefore be represented as a grammatical unit with number, gender, case and person, among other attributes.

This means a rule can speak about a whole phrase in the same comparison that it uses for another phrase or a token. Once a noun phrase has been recognized, a rule can inspect its number without reducing the phrase back to an adjacency condition on its component words. That is a central gain from the design. Constituents still occupy stretches of the sentence, but the comparison can take place between the grammatical units those stretches realize.

The parser uses an extended CYK algorithm. The useful picture for this paper is a matrix organized around stretches of an input sentence. The parser can build candidate phrases for shorter stretches and use them in analyses of larger ones. When a rule can apply, the resulting grammatical structure is made available for further analysis, including structures that will never become part of a full sentence tree.

The extensions let the parsing procedure handle attributes as it combines symbols. A rule can ask for equality of selected properties, require a property to have a particular value or test for a disagreement. The paper also allows rules to contain lexical restrictions. The availability of a category for a particular span thus depends on the grammatical information associated with its constituents as well as on the sequence of categories they form.

A successful analysis of a span records one way to understand that span. The same positions can support other analyses. The algorithm has to keep alternatives available because a word or phrase can carry more than one reading and because the error checker needs to inspect candidates outside a single completed tree. The paper’s examples use this fact directly. Elsewhere in a sentence there can be enough evidence for a correct construction even though the parser has identified a sequence that also satisfies an error rule.

When the correct rules cannot combine the whole input into a sentence, the matrix can still contain many successfully analyzed phrases. This is partial parsing in the authors’ design. Its value lies in what it preserves. A sentence may be too complex for the grammar, or a specific mistake may prevent part of it from combining as expected. In both cases the checker retains the available descriptions of smaller spans and can use them in evaluating an error rule.

What the correct rules and error rules each do

The paper calls rules for correct syntactic constructions G rules. They build phrases out of words and other phrases, under conditions specifying when the combination is grammatical. A complete analysis with G rules provides an interpretation of the entire sentence under the current grammar. A partial G analysis provides positive information about individual spans, even when the grammar cannot supply an interpretation of the whole.

The syntactic error rules are called E rules. They can take as input terminals and phrases already built with correct rules. The distinction allows an error to reside in how two constituents are combined even when each constituent is internally well formed. For example, the checker can know what one phrase is and what another phrase is, then inspect whether the pairing has grammatical features that fit together.

Some G and E rules use the same sequence of constituents. The difference lies in the conditions on their attributes. If the necessary properties agree, the G rule can build the correct construction. If the features meet the error rule’s condition, the E rule can supply a candidate diagnosis. Because plausible alternative readings of the constituents may coexist, a candidate diagnosis still has to be checked against whatever grammatical account the parser found.

In the paper’s sample rule pair, the two parts are an attributive constituent and the main noun phrase. The correct rule asks them to agree in case, number and gender. The corresponding error rule tests their disagreement on those features. The sample describes what the relationship must satisfy, so the check can refer to the analyses of the two constituents as units.

The error rule also contains instructions for the suggested repair. In this example it sets the gender and number of the attributive constituent from the main phrase and requests a suggestion using the two constituents together. It marks the matched material. Though the conditions inspect case, number and gender, the assignments shown in the example cover gender and number. The example thereby distinguishes the features examined during diagnosis from the changes explicitly requested by a particular suggestion rule.

This is a way of encoding the direction of a correction. An agreement test can establish that properties are incompatible for the proposed construction. The repair still has to pick the constituent that supplies the target value and the constituent to be changed. Here the main phrase supplies the values. The paper places such choices in the error rules, where they can depend on the construction being checked.

Deciding whether the match should reach the writer

The paper illustrates filtering with two uses of piemēram. In the first sentence, the word belongs to an expression meaning “my example.” The sentence says that the example must be clear. In the second sentence, the word has the adverbial use “for example” and introduces a statement about understanding something. In that second use, the error of interest is a missing comma after the introductory expression.

With G rules alone, the parser gives the first sentence a complete analysis and the second a partial one. That first pass establishes the difference in grammatical coverage. A partial result by itself leaves open whether the second sentence has an error or falls outside the ordinary constructions covered by the written rules. Adding E rules gives the checker a more specific diagnosis to consider.

The E rules yield an apparent error in each sentence. The match in the first sentence can be ignored because the G rules already account for the entire sentence as grammatical. In the second sentence, the parser still has only a partial correct analysis. An error rule identifies the adverb followed by a pronoun, and the checker can use that match as evidence for the punctuation warning. The value of the first example lies in showing how close a false alarm can be to a real one when the decision is made from a small stretch.

The published procedure also compares coverage at the level of phrases. An error rule has to cover a larger phrase than the competing correct rule can account for. An error match contained within a span the grammar already explains has weaker grounds for being reported. Conversely, a rule that accounts for an erroneous combination across more material than the available correct analysis can help localize the problem in a partially analyzed sentence.

The coverage condition gives the grammar a role beyond deciding whether the entire sentence receives a tree. A checker could encounter a difficult sentence with a well-formed phrase inside it. Failing to analyze the entire sentence should leave the parser free to protect that phrase against a warning, where a correct rule covers it. The authors’ requirement for partial results therefore helps with both sides of checking. It preserves stretches that can be diagnosed and stretches that can be recognized as correct.

The grammatical alternatives and the error candidates remain available in the parse result. The paper explicitly observes that error rules can be absent from the parse trees themselves. A component that inspected only a chosen complete tree, or stopped when it could find no such tree, would miss the evidence the checker needs. The parse walker instead examines the parser’s result matrix, extracts the relevant error structures and generates corrections from the instructions stored with the rules.

Capitalization, style and the final result

The paper also describes a grammar containing error rules for capitalization and style. These rules can operate on shorter stretches and do not require phrases already built by the correct syntactic grammar. They frequently specify exact lexical items, which helps describe combinations such as names, titles and conventional expressions. A capitalization warning can thus be tied to the recognized expression and the letter pattern appropriate to it.

The capitalization operator is called CapPattern. A rule states the expected uses of upper-case and lower-case within a phrase. When the lexical and grammatical conditions for the expression are satisfied, a capitalization pattern that differs from the specified one triggers the error rule. The grammatical guards matter because the same words can occur in different combinations, and the capitalization requirement is attached to a particular expression.

In the paper’s example, the rule names the lexical forms Amerika, savienots and valsts. One constituent must be genitive singular, the adjectival constituent must have a definite ending, and the main noun must be plural. The adjective is tested for agreement with the main noun in case, number and gender. These conditions identify the intended construction before the capitalization comparison takes place. The example shows that a short rule can still make substantial use of morphology.

The authors describe the checker at this stage as using a capitalization and style grammar of 260 rules. The syntactic grammar contains 477 rules describing correct constructions and 237 error rules. The checker classifies its findings into 21 error types. The grammatical inventory and the set of error labels have different jobs. Several rules can recognize particular instances of the same broad error class, while correct rules can contribute to more than one kind of decision.

The parse walker produces error findings and correction suggestions for the analysis it inspects. The result preparation component receives those findings together with the surface formatting findings and merges them for the calling application. The modular arrangement lets a simple formatting check and a syntactic diagnosis reach the editor through the same final stage while drawing on different information.

How the rules are developed

Development proceeds by editing and recompiling the grammar. The authors use a development corpus, its human error record and the latest evaluation results to see where the existing rules succeed or fail. They can then refine the rules and repeat the evaluation. The evaluation scores are feedback about the grammar at a given stage and help point to error types carrying useful evidence for revision.

The human error record has a role both before and after a checker run. Annotators initially supply judgments for development sentences. Later, when the checker identifies cases absent from the record, evaluators can judge the detection and its suggested correction. Accepted updates enlarge the record against which subsequent runs can be assessed. This gives rule development access to cases discovered during the checking process as well as to errors marked by people ahead of time.

The paper reserves a separate corpus for assessing the current checker. The people developing the rules do not see its text. Keeping that material out of rule tuning lets the authors observe how precision changes when the checker moves away from the sentences used during development. The initial annotation differs across the two corpora, so the same separation has a consequence for which measures can be reported on each.

Experiments and results

What went into the corpora

The development and test corpora have 9364 and 4814 sentences, respectively. The development text is used for tuning and assessment. The test text is held back from rule developers and used for assessment of the current checker. This gives the reported development and test precision scores identifiable roles. The former describes performance where evaluation has already informed the grammar, and the latter describes warnings on text the people writing those rules have not seen.

The authors sample kinds of writing that they expect users to submit for checking. Student writing includes secondary-school essays and university papers. Other material comes from blogs and email, with attention to writing the authors considered reasonably good but unedited. The corpus design also accounts for promotional writing and texts by non-native speakers with a good command of Latvian. These choices make the test relevant to a checker intended to operate before editing is finished.

News, drafts connected with project tenders, and work by amateur writers also appear in the authors’ description. They include writing by specialists in different fields. This extends the intended setting from general personal writing to texts that may use the vocabulary and habits of a particular profession. The authors say that the proportions of the genres are roughly matched between development and test. The reported results combine the genres.

The record of errors and expected corrections is called the Golden Standard. On the development corpus, a person marks sentences with error types before the checker runs. The system’s results can then be compared with the initial human decisions. This supplies evidence about errors the checker has missed, which is required for measuring recall. It also makes the human choice of error category part of the evaluation. The process is an application of linguistic annotation.

The authors describe a second route into the Golden Standard. Once the checker has run over both corpora, cases that it flags and that are new to the record are forwarded to an evaluator. The evaluator considers whether the detected error is genuine and whether the proposed fix is correct. The outcome can then be incorporated into the record. This keeps the checker from being judged solely on whether it matches the initial annotations, which could leave some genuine discoveries unrecognized.

The second route has different implications for test precision and test recall. Reviewing a warning gives the evaluator evidence for counting that warning as correct or incorrect. Discovering missed errors would require looking elsewhere in the text as well. Since the test corpus lacked the initial marking step, the paper reports test precision and gives recall only on development text. A blank in the results calls for attention to the relevant annotation or evaluation condition.

What the scores count

Recall concerns the errors of a given type that are present in the corpus reference. It measures the share of those errors that the checker successfully finds. A missed error increases the denominator without increasing the number found. The paper defines recall as follows.

R(x) = tp(x) / (tp(x) + fn(x))

Here x is the error type under consideration, and R(x) is its recall. The term tp(x) counts true positives, the errors of that type the checker correctly detects. The term fn(x) counts false negatives, errors of that type that it misses. The plus sign combines the two counts into the reference total for that type, and the slash divides the number detected by that total. The equals sign gives the definition, with parentheses grouping the arguments and the denominator.

Precision starts from the checker’s own findings. For a given type, it measures the share of reported errors that are judged correct. An incorrect warning increases the number reported without increasing the number judged correct. The paper defines it as follows.

P(x) = tp(x) / (tp(x) + fp(x))

Here x is the error type, and P(x) is its precision. The term tp(x) again counts correctly detected errors of type x. The term fp(x) counts false positives, cases incorrectly reported as errors of that type. The plus sign gives the total number of findings in that type, and the slash divides the correct findings by that total. The equals sign defines precision, and the parentheses show where the argument and the denominator begin and end.

The authors say that they calculate an F-measure and a confidence interval for precision for individual error types, alongside recall and precision. The numerical results they present are the recall and precision values. These give two views of the checker’s usefulness. A reader who wants to understand what happens to existing mistakes needs the recall figure. A reader who wants to understand how frequently the editor’s warnings deserve attention needs the precision figure.

The evaluation uses a single error type from the human evaluator for a sentence. The checker likewise selects a single error, choosing the one associated with the largest phrase. A sentence can contain several errors. The checker can therefore select a different problem from the person’s selected error, despite both judgments referring to real issues in the sentence. The authors explicitly identify such mismatches as a possible influence on their precision and recall results.

The earlier pattern checker gives the paper a historical comparison and explains the design change. The results table concerns the new system, with its scores broken down by error type and corpus. The paper supplies no equivalent precision or recall scores for the 2004 implementation under this evaluation procedure. The baseline for deciding whether a warning was correct is the human record. Estimates of improvement over an earlier checker would require measurements for that checker under comparable conditions.

Overall performance and coverage by error type

Across all error types, the reported development recall is 0.290. Precision across all types is 0.833 on the development corpus and 0.710 on the test corpus. These are results for the checker at the stage described in the paper. Development precision describes the findings on the corpus used to refine the grammar. The lower test precision shows that findings on withheld sentences were less often judged correct in this evaluation.

Overall recall gives a view of how much work remained for the writer or editor. The checker found some of the human-recorded errors on the development corpus and left many others undetected. The overall score also combines problems with very different kinds of evidence. Capitalization and phrasing can depend on recognizing a short conventional expression. Agreement and comma placement can require identifying how constituents are related in a longer sequence.

Latvian checker by error category on the development corpus, recall

The checker finds the largest share of recorded errors when words should be written together and the smallest share for commas between equal parts of a sentence.

Latvian checker by error category on the development corpus, recallAgreement between words: 0.247Agreement between words0.247Punctuation at the end of a sentence: 0.240Punctuation at the end of a sentence0.240Words that should be written together (this paper): 0.761Words that should be written together(this paper)0.761Commas in insertions: 0.563Commas in insertions0.563Commas in participial phrases: 0.427Commas in participial phrases0.427Incorrect writing style: 0.397Incorrect writing style0.397Commas between equal parts of a sentence: 0.140Commas between equal parts of a sentence0.140Commas in subordinate clauses: 0.329Commas in subordinate clauses0.329All error types: 0.290All error types0.290
The numbers
System or settingRecall
Agreement between words0.247
Punctuation at the end of a sentence0.240
Words that should be written together (this paper)0.761
Commas in insertions0.563
Commas in participial phrases0.427
Incorrect writing style0.397
Commas between equal parts of a sentence0.140
Commas in subordinate clauses0.329
All error types0.290

Writing words together is the strongest category in the development recall breakdown. Its recall is 0.761, and its development precision is 0.962. The class concerns words that should be joined. The combination of scores means that the checker detects a substantial share of the recorded errors in this class and that most of the warnings it raises for this class are judged correct. On test text, the class has precision of 1.000.

Errors involving commas in insertions also have relatively high development recall, at 0.563. Precision for these errors is 0.913 on the development corpus and 0.892 on the test corpus. An insertion is material set into the surrounding sentence, and a comma rule needs to recognize the relevant portion before checking its punctuation. The scores show that the checker addressed this category with both reasonably broad coverage on development text and a high share of correct warnings on the withheld text.

Comma errors in participial phrases have development recall of 0.427. The corresponding precision values are 0.704 on development text and 0.660 on test text. Commas in subordinate clauses have development recall of 0.329 and precision of 0.773 on development text and 0.758 on test text. In both categories, punctuation is assessed in relation to a grammatical unit. The distinction between the categories matters empirically because their reported precision and recall differ.

Commas between equal parts of a sentence give the lowest development recall among the individual categories shown, at 0.140. Precision for that category is 0.773 on development and 0.583 on test. Punctuation at the end of a sentence has development recall of 0.240 and development precision of 0.957. The results table leaves test precision for sentence-final punctuation unspecified. That omission gives no numerical account of the checker’s behavior in that category on withheld material.

Incorrect style has development recall of 0.397. Its warnings have precision of 1.0 on development text and 0.950 on test text. Here the precision values describe how the flagged style cases were judged. The recall value describes how much of the annotated style category those warnings covered. The two measures together leave room for a system to be highly selective and still useful within the particular patterns it recognizes.

Agreement is central to the authors’ motivation and remains a difficult category in the results. Development recall is 0.247. Precision is 0.543 on the development corpus and 0.426 on the test corpus. Those scores say that the checker finds only a limited share of the marked agreement errors in development text and that a substantial share of its agreement warnings are judged incorrect. Introducing grammatical structure gives the authors a way to express agreements and mistreatments of them that the older rule format struggled to reach. The category scores show how much uncertainty remains in using those rules on text.

Latvian checker by error category on the development corpus, precision

Incorrect style yields the most reliable warnings on development text, while agreement warnings are the least reliable among the categories shown.

Latvian checker by error category on the development corpus, precisionAgreement between words: 0.543Agreement between words0.543Punctuation at the end of a sentence: 0.957Punctuation at the end of a sentence0.957Words that should be written together: 0.962Words that should be written together0.962Commas in insertions: 0.913Commas in insertions0.913Commas in participial phrases: 0.704Commas in participial phrases0.704Incorrect writing style (this paper): 1.0Incorrect writing style (this paper)1.0Commas between equal parts of a sentence: 0.773Commas between equal parts of a sentence0.773Commas in subordinate clauses: 0.773Commas in subordinate clauses0.773All error types: 0.833All error types0.833
The numbers
System or settingPrecision
Agreement between words0.543
Punctuation at the end of a sentence0.957
Words that should be written together0.962
Commas in insertions0.913
Commas in participial phrases0.704
Incorrect writing style (this paper)1.0
Commas between equal parts of a sentence0.773
Commas in subordinate clauses0.773
All error types0.833

The difference between the best precision category on development text and the best recall category is informative. Wrong-style warnings were all accepted in the development evaluation at the precision reported, while the checker recovered a larger share of recorded errors in the category of words that should be written together. For writers, one measure describes the reliability of an interruption. The other describes how much of a problem the checker can be expected to notice in the assessed development material.

The punctuation results show why the paper reports distinct error types. Sentence-final punctuation warnings have high development precision and low development recall. Insertion commas have stronger coverage on that corpus. Commas between equal parts of a sentence have particularly limited coverage, and their test precision is lower than the precision of insertion commas. A single result for punctuation would obscure the variation among those judgments.

Latvian checker by error category on the withheld test corpus, precision

Warnings about words that should be written together are the most reliable on withheld text, and agreement warnings remain the least reliable among the categories shown.

Latvian checker by error category on the withheld test corpus, precisionAgreement between words: 0.426Agreement between words0.426Words that should be written together (this paper): 1.000Words that should be written together(this paper)1.000Commas in insertions: 0.892Commas in insertions0.892Commas in participial phrases: 0.660Commas in participial phrases0.660Incorrect writing style: 0.950Incorrect writing style0.950Commas between equal parts of a sentence: 0.583Commas between equal parts of a sentence0.583Commas in subordinate clauses: 0.758Commas in subordinate clauses0.758All error types: 0.710All error types0.710
The numbers
System or settingPrecision
Agreement between words0.426
Words that should be written together (this paper)1.000
Commas in insertions0.892
Commas in participial phrases0.660
Incorrect writing style0.950
Commas between equal parts of a sentence0.583
Commas in subordinate clauses0.758
All error types0.710

The withheld evaluation preserves a broad pattern seen in development. Warnings about word joining and incorrect style are typically accepted, and agreement warnings are harder to trust. The scores for comma errors depend on the construction. Relative performance across categories gives a more specific picture of what a user can expect than the overall test precision alone. It also gives the rule developers a way to locate weaknesses within a checker that covers several kinds of writing problems.

The highest observed test precision deserves the same care as the weakest result. The value 1.000 for joining words describes the warnings assessed in that category in the test corpus. The paper does not give the count of those warnings in its results table. The category precision should therefore be read together with what the evaluation measured. It is direct evidence on the warnings that were observed, and the absent denominator limits what can be said about the estimate’s stability.

Use in an editor

The paper reports integration into Microsoft Word and OpenOffice Writer. The checker runs in the background, and the authors regard its speed as sufficient for everyday use. This places the correction suggestions in the setting that motivated the concern about false alarms. A user can receive a warning while writing, assess it and decide whether to accept the requested change.

The user-satisfaction evaluation provides a separate kind of evidence from the corpus scores. The authors report that users found the checker helpful and were more interested in high precision than in high recall. A checker with higher precision makes its warnings easier to take seriously. The reported preference helps explain the practical importance of suppressing uncertain candidates, especially for a program that runs while the writer is engaged with something else.

That user evidence concerns the usefulness of the resulting tool and stated preferences about its behavior. The corpus evaluation concerns agreement between checker findings and human judgments of errors. The two address different questions. A favorable user judgment can coexist with modest recall, because writers may value having certain recurring mistakes brought to their attention even when many other mistakes go undetected.

What the ablations show

The paper gives no quantitative ablation study of the checker’s individual components, and its analyses consist of a worked comparison of grammar configurations, corpus comparisons and results by error type.

What adding error rules reveals in the worked example

The closest comparison to a component experiment is the paper’s treatment of the sentences containing piemēram. With correct rules alone, the first sentence has a complete analysis and the second has a partial analysis. The result says something about the coverage of the grammar, but leaves the parser with an incomplete account of what has happened in the second sentence. When the E rules are available, the checker has a specific candidate involving the adverb and the following pronoun.

The error rules also add a candidate in the first sentence. The complete G analysis is the reason the checker can set it aside. The example shows both effects of adding an error grammar. It can provide a useful diagnosis where analysis fails, and it can create a diagnosis for a word sequence that already belongs to a valid sentence. The decision procedure needs the positive grammatical evidence as well as the evidence supplied by the error rules.

A further observation is that the second sentence still has only a partial correct parse once the error rule has matched. The role of the E rule is to identify a problem and guide a correction. The correction can be proposed even though the checker has no completed sentence tree. Retaining intermediate analyses and consulting the error rules can therefore change what the writer learns from the parser, even where complete grammatical coverage remains the same.

At the phrase level, the larger-span requirement gives a related answer to the same ambiguity problem. The checker can regard a locally suspicious combination as worth reporting when it covers a larger stretch than the competing correct analysis. The example involving complete analysis shows the strongest form of grammatical protection. The phrase rule extends the comparison to sentences the parser can understand only in part.

These cases demonstrate the operation of the decision procedure. They do not quantify how many false positives are rejected by a full parse, how often phrase coverage changes a decision, or how many true errors either filter discards. The paper would need corpus results with otherwise identical configurations to resolve those questions. The examples establish the kind of difference the rules can make in interpretation.

What the score differences can establish

The development and test results compare the same checker across different text collections. That makes them evidence about performance away from the rule-tuning material. The overall precision falls on the withheld corpus, and the change differs by category. The test split helps establish that some strengths remain visible outside development, including reliable joining warnings and problems with agreement. It leaves open which properties of the withheld text account for the lower overall precision.

The category breakdown also tests any broad reading of the motivation. Agreement gave the authors a strong reason to introduce a parser, because it can require relationships beyond a local pattern. Agreement nevertheless has the lowest precision among the categories shown on both corpora. A more expressive rule format creates a way to describe such cases. The ability to describe them and the reliability of detecting them in actual text are distinct empirical questions.

The stronger result for joining words shows where the implemented checker already performs well. The paper gives no component comparison that would attribute that performance to the correct grammar, the error grammar, morphological analysis or a particular set of lexical rules. Likewise, the category results for punctuation do not isolate whether a successful warning depends on the parser’s treatment of the whole sentence or on reliable recognition of a smaller construction.

The example, corpus comparison and category breakdown support conclusions at different levels. The example explains a specific suppression of a false warning. The corpus split describes the precision of the checker on text withheld from rule developers. The error categories show where the available grammar produces more or less successful judgments. A numerical estimate of any component’s effect would require varying that component on the same material under the same evaluation rules.

Limitations

Limits the authors identify

The authors explicitly acknowledge that failure to parse can have more than one cause. A sentence can contain an error, or it can have a structure the current correct grammar cannot fully describe. That leaves the checker dependent on its library of specific error rules and on the relative coverage of grammatical analyses. A partial parse supplies a place to look. The detection still needs evidence from a rule whose conditions and span justify a warning.

The requirement that correct rules mark only genuinely correct structures is important here. A complete G parse has enough authority to suppress a warning. If the grammar supplies a valid-looking analysis too freely, the same mechanism can suppress a warranted warning. Restrictive G rules place pressure in the other direction because correct constructions may fail to receive protection. The authors identify accuracy of the correct grammar as a requirement, and their evaluation measures the finished checking decisions rather than separately scoring those grammatical judgments.

The authors also identify the one-error-per-sentence policy as a limitation of their measures. A human evaluator records one error type, and the checker selects the error covering the largest phrase. Each can focus on a different genuine problem in the same sentence. A matched error type is therefore partly a product of how the system and the person select among the sentence’s problems. The scores represent this evaluation convention as well as the ability of the rules to recognize errors.

Recall is explicitly confined to the development corpus because the test text was not annotated before checking. The evaluation of test warnings can establish test precision. It offers no estimate of the total number of overlooked errors in withheld text. This leaves the relationship between development recall and test recall unknown. The test split is valuable for assessing submitted warnings and more limited as an assessment of coverage.

The system’s scope also reflects the rule inventories in use when the paper was written. The authors cover 21 error types and report measurements for the common types and for all types together. The overall result describes that inventory and the way a finding gets selected for comparison. Additional rules or changes to the correct grammar could alter which warning is selected, even in a sentence for which one of the existing rules would still apply.

Limits of the evidence

The paper explains why the old checker was replaced, but its reported results give no estimate of how much better or worse the new checker is on the same texts. The known difficulties of the old system motivate the use of grammatical structure. The corpus scores characterize the result of that design decision. A measured improvement in precision, recall or speed would require a shared evaluation including the older checker. The paper also supplies no timed breakdown of the new system.

The precision figures aggregate findings within an error type. The results table gives no denominator for each type, so it cannot show how many decisions lie behind very high or low values. The authors mention confidence intervals as a calculated quantity, but the displayed results provide no interval bounds. This limits comparisons between categories whose values are close and limits how broadly any apparently perfect observed precision can be generalized.

The corpus design incorporates several kinds of writing that intended users might submit. The authors describe approximately similar representation across the splits, but the results give no breakdown by genre. A reader can assess precision over the withheld mixture. The figures do not establish the same precision in email, student essays, news and specialist writing considered separately. Differences in vocabulary, construction and editing stage could matter to the rule inventory, and the reported scores do not resolve their contributions.

The procedure for updating the Golden Standard is useful for judging unexpected findings. It also means that some assessment cases arrive at the evaluator because the checker proposed them. On the test corpus this is suited to the question of whether a warning is correct, the target of precision. Questions about false negatives would require a procedure that could discover problems the checker never suggested. The paper respects this distinction when it withholds a test recall figure.

Although the evaluator is asked to judge both the detected problem and the suggested repair, the table does not report standalone measures for the quality of suggested corrections. It gives no separate estimate of how often the checker identifies the right construction but chooses an unsuitable change. The rule example explains how a suggestion can be formed by assigning feature values. The evaluation summary leaves the success of those assignments as part of the broader picture of checker quality.

The span comparison is described as a requirement for the syntactic error rule to succeed. The paper gives the rationale and a working example but no frequency breakdown for the possible outcomes of that comparison. It therefore leaves open whether most missed errors arise from absent error rules, failed phrase analysis, the coverage filter or competition with another warning in the sentence. Each explanation points to a different part of the checker and would need a different diagnostic count.

The authors report that the checker was fast enough for daily use and that users found it helpful. The paper gives no latency measurements or details of the user study sufficient to quantify either result. The integration demonstrates that the authors got the checker working in the named editors. The broader claims about speed and user preference remain qualitative, as reported by the authors.

Finally, this is a checker for Latvian developed around an existing Latvian parser and a set of rules written for that purpose. The method shows one way of bringing feature agreement, partial parsing and error reporting together for a language the authors describe as highly inflected and relatively free in word order. The reported evaluations concern Latvian text. They offer a description of the mechanism and its practical tradeoffs without establishing its scores in a different language or under a different grammar.

What came after

Follow-up work building on this checker is undocumented here. The paper itself describes an implementation already running in Microsoft Word and OpenOffice Writer and a repeated development cycle in which human judgments inform revisions to the grammar. That establishes the immediate outcome of the research. The parser had moved from translation into a working Latvian editing tool, where its analyses could support warnings and also prevent some misleading matches from reaching the writer.

The account ends with a checker that users found helpful and whose evaluation exposed uneven performance. It was strong at warning about forms that should be written together and continued to struggle with agreement, the problem that had helped motivate the move to parsing. The paper records that stage of the system. It leaves the course of later development and the use of the approach in subsequent research unestablished.

Cite

Cite as Daiga Deksne and Raivis Skadiņš. 2011. CFG based grammar checker for Latvian. Proceedings of the 18th Nordic Conference of Computational Linguistics (NODALIDA 2011).

The paper itself, not this page. BibTeX from the library's record of the work.

@inproceedings{deksne2011cfg,
  title = {{CFG based grammar checker for Latvian}},
  author = {Daiga Deksne and Raivis Skadiņš},
  booktitle = {Proceedings of the 18th Nordic Conference of Computational Linguistics (NODALIDA 2011)},
  year = {2011},
  url = {https://aclanthology.org/W11-4638/}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/deksne-2011-cfg-based-grammar-checker-latvian/