User:Krvoje/Application2012

From Apertium
Jump to navigation Jump to search

(This is a draft)

GSoC application: Rule-based finite-state disambiguation

Hrvoje Peradin

hperadin@gmail.com,

krvoje on IRC: #apertium

Why is it you are interested in machine translation?

It's a perfect combination of Computer Science and Linguistics. I am very fascinated with languages, both natural or artificial. With MT it fascinates me to see a natural message transfered across a language barrier via only a process of computation. While the results are rarely perfect, it takes down communication barriers, and opens up new opportunities for learning and communication.

Why is it that you are interested in the Apertium project?

I have worked on a language pair in last year's GSoC, and it gave me great insights on rule based NLP. It gave me an invaluable chance to do real-life work on an immensely interesting topic, and to create an open-source resource. It was a great experience that taught me a lot about software development and NLP - and it also gave me the theme for my master thesis. So, I could say Apertium has a special place in my heart, and I would love to continue working on it.

Which of the published tasks are you interested in?

Writing the module for rule-based finite-state disambiguation.

Why should Google and Apertium sponsor it?

The module is intended to supplement the current bigram tagger, and Constraint Grammar, by implementing constraint based-disambiguation in a finite-state manner. Since the most common disambiguation rules can be expressed in a finite-state way, this will greatly improve speed of disambiguation, and will be beneficial for working with large texts.

How and whom it will benefit in society?

It will provide a fast tool for rule-based disambiguation, which will enable faster processing of larger corpora, and potentialy help improve translation quality in any language pair in Apertium.

What do you plan to do?

I will design an XML formalism for writing disambiguation rules, a validator for it, a compiler for representing the rules as a finite-state transducer that integrates with the lttoolbox API, and a processor which applies the rules to an Apertium input stream.

The compiler and the processor will be written in C++, based on the designs of Apertium's transfer module, and the lexical selection module, and will use the lttoolbox API.

The disambiguation module will be documented with use-case examples in various languages, based on my current experience with developing Constraint Grammar for Croatian.

Examples of rule formalism

The following are few examples of the proposed XML formalism, together with a rudimentary transducer implementation in the finite-state calculus of foma[1]. The transducers operate on simple patterns, and although they perform validation of the Apertium's stream format, no account was given to the robustness rule of Constraint Grammar (keeping the last remaining reading). (TODO: link na source code skripte).

A removal rule

<rule n="preposition_not_accusative">
	<lu>
		<tag n="pr"/>
		<tag n="acc"/>
	     	<remove> 
			<tag n="acc"/> <!--Removes readings where the tag is Accusative!-->
		</remove>
	</lu>
	<lu>
		<tag n="n"/>
		<tag n="loc"/>
	</lu>
</rule>

This rule matches the pattern ["LU containing the tag <pr> and the tag <acc>"] ["LU containing the tags <n> and <loc>"] and removes all readings containing the tag <acc>.

Code snippet from the foma script:

define RuleRemoveAccusative  [ [Preposition & Accusative & Locative] .o. MarkSuspicious(Contains({<acc>}))] 
       			     [ Noun & Locative ] ;

The transducer matches two LU's, with tags as described in the XML formalism, and the first match is given by composition to the MarkSuspicious transducer, which marks readings containing <acc> as pending removal.

The entire transducer applying this rule to the stream is made as the following composition.

define Example1 ValidInput .o. PrepareInput .o. RuleRemoveAccusative .o. Remove .o. CleanMarks ;

Where ValidInput validates the input stream according to the Apertium stream format, PrepareInput assigns temporary tags, and the Remove and CleanMarks transducers perform the removal of readings marked for removal, and the cleanup of the temporary tags. TODO: možda slike ovih nekompliciranih

A select rule example

<rule n="noun_not_dative_accusative">
	<lu>
		<tag n="pr"/>
		<tag n="loc"/>
	</lu>
	<lu>
		<tag n="n"/>
		<tag n="loc"/>
		<tag n="dat"/>
		<select>
			<tag n="loc"/> <!--Select the readings with the locative tag!-->
		</selec>
	</lu>
</rule>

The rule matches the pattern ["LU containing <pr> and <loc>"] ["LU containing <n>, <loc> and <dat>"], and selects all readings with <loc> in the second LU.

The foma snippet for this rule is:

define RuleSelectLocative [ Preposition & Locative ] 
       			  [ [Noun & Locative & Dative] .o. MarkSelection(Contains({<loc>})) ] ;

Here the second match is given to the transducer MarkSelection, which marks all the readings containing <loc> for keeping, and all other readings for removal.

The entire rule is similarly made as the composition:

define Example1 ValidInput .o. PrepareInput .o. RuleSelectLocative .o. Remove .o. CleanMarks ;

Combination of both rules

Since <select> and <remove> are compositions of replace transducers with their corresponding pattern elements, these two rules can easily be combined in one that is more compact:

<rule n="combined_rule">
	<lu>
		<tag n="pr"/>
		<tag n="loc"/>
		<tag n="acc"/>
		<remove>
			<tag n="acc"/> <!-- Remove readings containing accusative -->
		</remove>
	</lu>
	<lu>
		<tag n="n"/>
		<tag n="loc"/>
		<tag n="dat"/>
		<select>
			<tag n="loc"/> <!-- Select readings containing locative -->
		</selec>
	</lu>
</rule>

This rule performs a similar match, and the transducers for <select> and <remove> are composed to both of the cohorts, yielding a more compact representation than the former two rule variants:

define RuleCombine  [ [Preposition & Locative & Accusative] .o. MarkSuspicious(Contains({<acc>}))]
		    [ [Noun & Locative & Dative] .o.  MarkSelection(Contains({<loc>})) ] ;

The entire rule is again a composition with auxilliary transducers

define ExampleCombined ValidInput .o. PrepareInput .o. RuleCombine .o. Remove .o. CleanMarks ;

Work already done

Community bonding period

- written a program for the coding challenge

- started familiarising myself with lttoolbox, written a small program that composes strings and regexes into an FST

Work To do

Before the coding period:

- explore the API

- write a simple prototype, that implements a simple hardcoded rule (e.g. preposition-based case disambiguation for Serbo-Croatian)

The coding period:

- Week 1: A thorough design of the XML formalism along with a validator. The basis for functionality will be CG-2, and the syntax will be based on apertium-lex-tools.

The XML formalism will in effect contain a subset of Constraint Grammar rules, as much as it is possible to express with finite-state transducers. I am currently writing my master thesis on disambiguation with Constraint Grammar and I am quite familiar with principles of morphological disambiguation, so I will base the design of this formalism on my experience with Constraint Grammar. As well as this, I will look into other finite-state NLP systems like LanguageTool[2], IceNLP[3] and Apertium's lexical selection tools[4] and use them as role models.

- Deliverable #1 : A complete XML formalism for expressing finite-state disambiguation rules, along with preliminary documentation.

- Week 2-8: Writing a compiler and a stream processor and integrate it with lttoolbox.

The syntax of the disambiguation will be based on the syntax of the lexical selection module. The funcionality will be expanded by adding a negation element (to implement funcionality analogous to barriers and negation in CG), and adding elements to match one or more LU's (analogous to scanning in CG, or the +,? and * quantifiers in regular expressions syntax), as well as a "remove" element. The sets and lists used in Constraint Grammar will be defined analogously to categories in Apertium's transfer by using a combination of regular expressions and category items.

- Deliverable #2 : A compiler and processor for the complete formalism

- Week 9-12: Testing and polishing the system, writing the documentation, along with use-case examples on various languages.

For testing of the rules I will use examples of rules of varying complexity based on my current experience with Constraint Grammar. The documentation will contain use-case examples in form of tutorials, and will be based on my current work with Constraint Grammar for Croatian. The examples will be based mostly on the rules I am currently developing for Croatian, as well as on Constraint Grammar rules available for other languages.

- Deliverable #3 : The complete disambiguation system, with a compiler, a processor, and the documentation.

Non-GSoC activities

TODO:

Bio

I am an Graduate student of Computer Science and Mathematics at the Faculty of Science, University of Zagreb.

During my courses I have worked with C/C++, Python, C\#, Java, JavaScript, PHP + CSS + HTML, XML, SQL, Coq... Besides Coq, I also have a basic knowledge of functional programming through Haskell and the GF formalism. Currently I am writing my master thesis on disambiguation for the Croatian language with Constraint Grammar.

I have worked on the language pair apertium-sh-mk for the GSoC of 2011., and have been a mentor for Google Code-In 2011 for several tasks involving that and similar language pairs.

Regarding the technologies used in machine translation we I've been enrolled in courses with finite state machines, and context free grammars (implementation of a parser using yacc+flex), and machine learning.

References