Difference between revisions of "Contrastive grammar"

From LING073
Jump to: navigation, search
(→‎The assignment)
 
(35 intermediate revisions by 2 users not shown)
Line 1: Line 1:
−
This document is in flux.  Stand by while it's worked on.  —[[User:Jwashin1|Jwashin1]] ([[User talk:Jwashin1|talk]]) 15:03, 19 March 2019 (EDT)
 
−
 
 
A previous version of this document is available at [[Spring 2018/Contrastive grammar]].
 
A previous version of this document is available at [[Spring 2018/Contrastive grammar]].
  
 
Some of the content that used to be here is now on the [[Lexical selection]] page.
 
Some of the content that used to be here is now on the [[Lexical selection]] page.
  
−
== What constitutes a contrastive grammar for RBMT ==
+
== Contrastive grammars ==
−
* Start by looking at material in the language you're translating into your language.
+
=== How to approach identifying linguistic differences ===
−
* For a given way of expressing the same thing (a translation, or equivalent sentence), find differences in the parse, ignoring the content of the lexical items.
+
* The last step we'll be implementing in our RBMT pipeline is '''structural transfer''', where we can adjust the output of lexical transfer and lexical selection.  We can adjust (change, add, subtract) tags and the order of words and phrases.
−
* I.e., make sure the full version of the sentence in each language parses correctly (and has correct disambiguation), and then compare the parses side-by-side.
+
* Start by '''comparing the current output of your translation system to the ideal output'''.  Focus on words marked with <code>#</code> in the output and words in the wrong order.  If you don't have many issues like this because your languages are similar, try looking at the output of a large corpus (e.g., Wikipedia or Bible translation) to identify such things.
 +
* For a given way of expressing the same thing (a translation, or equivalent sentence), '''find differences in the parse''' (tags or order generated versus expected), ignoring the content of the lexical items.
 +
* I.e., make sure a given full version of the sentence in each language is tagged correctly and otherwise translates correctly (has correct analysis, disambiguation, lexical transfer, and lexical selection), and then '''compare the output of the <code>lex</code> mode''' to the desired analysis to be generated (e.g., by running the correct translation through that language's transducer).
 +
 
 +
=== What constitutes a linguistic difference for structural transfer ===
 
* You'll want to identify any differences in word order, tags used, etc.
 
* You'll want to identify any differences in word order, tags used, etc.
−
** An example of a set of similar languages might be:
+
** An example of a set of '''similar languages''' might be:
 
**: "Je le mangerai": <code>^je/je<prn><pers><p1><sg><nom>$ ^le/le<prn><pers><p3><m><acc>$ ^mangerais/manger<v><tv><fut><p1><sg>$</code>
 
**: "Je le mangerai": <code>^je/je<prn><pers><p1><sg><nom>$ ^le/le<prn><pers><p3><m><acc>$ ^mangerais/manger<v><tv><fut><p1><sg>$</code>
 
**: "Yo lo comeré": <code>^yo/yo<prn><pers><p1><sg><nom>$ ^lo/lo<prn><pers><p3><m><acc>$ ^comeré/comer<v><tv><fut><p1><sg>$</code>
 
**: "Yo lo comeré": <code>^yo/yo<prn><pers><p1><sg><nom>$ ^lo/lo<prn><pers><p3><m><acc>$ ^comeré/comer<v><tv><fut><p1><sg>$</code>
−
** An example of a set of rather different languages might be:
+
** An example of a set of rather '''different languages''' might be:
 
**: "Yiyemeyeceğim": <code>^yiyemeyeceğim/ye<v><tv><abil><neg><fut>+i<cop><aor><p1><sg>$</code>
 
**: "Yiyemeyeceğim": <code>^yiyemeyeceğim/ye<v><tv><abil><neg><fut>+i<cop><aor><p1><sg>$</code>
−
**: "I won't be able to eat it": <code>^I/I<prn><pers><p1><sg><subj>$ ^won't/will<vaux>+not<adv>$ ^be/be<v><iv>$ ^able/able<adj>$ ^to eat/eat<v><tv><inf>$ ^it/it<prn>pers><p3><nt><obj>$</code>
+
**: "I won't be able to eat it": <code>^I/I<prn><pers><p1><sg><subj>$ ^won't/will<vaux>+not<adv>$ ^be/be<v><iv><inf>$ ^able/able<adj>$ ^to/to<pr>$ $eat/eat<v><tv><inf>$ ^it/it<prn><pers><p3><nt><obj>$</code>
 
* In the above example of similar languages, there are no differences in tags, only in stems.  Here there is nothing to contrast.  In the above example of different languages, there is quite a bit that can be contrasted—but almost too much to break down into individual points.
 
* In the above example of similar languages, there are no differences in tags, only in stems.  Here there is nothing to contrast.  In the above example of different languages, there is quite a bit that can be contrasted—but almost too much to break down into individual points.
−
* An example of languages with some minor differences might be:
+
* An example of '''languages with some minor differences''' might be:
 
**: "Je l'ai vu": <code>^je/je<prn><pers><p1><sg><nom>$ ^l'ai/le<prn><pers><p3><m><acc>+avoir<vaux><pres><p1><sg>$ ^vu/voir<v><tv><prc_past>$</code>
 
**: "Je l'ai vu": <code>^je/je<prn><pers><p1><sg><nom>$ ^l'ai/le<prn><pers><p3><m><acc>+avoir<vaux><pres><p1><sg>$ ^vu/voir<v><tv><prc_past>$</code>
 
**: "Yo lo vi": <code>^yo/yo<prn><pers><p1><sg><nom>$ ^lo/lo<prn><pers><p3><m><acc>$ ^vi/ver<v><tv><ifi><p1><sg>$</code>
 
**: "Yo lo vi": <code>^yo/yo<prn><pers><p1><sg><nom>$ ^lo/lo<prn><pers><p3><m><acc>$ ^vi/ver<v><tv><ifi><p1><sg>$</code>
Line 27: Line 29:
  
 
=== The examples above using templates ===
 
=== The examples above using templates ===
 +
Click to edit or view the source of this section to see how the <code>transferTest</code> and <code>transferMorphText</code> templates are structured.
 +
 
* {{transferTest|fra|spa|Je le mangerai|Yo lo comeré}} ("I'll eat it.")
 
* {{transferTest|fra|spa|Je le mangerai|Yo lo comeré}} ("I'll eat it.")
 
*: {{transferMorphTest|fra|spa|je{{tag|prn}}{{tag|pers}}{{tag|p1}}{{tag|sg}}{{tag|nom}} le{{tag|prn}}{{tag|pers}}{{tag|p3}}{{tag|m}}{{tag|acc}} manger{{tag|v}}{{tag|tv}}{{tag|fut}}{{tag|p1}}{{tag|sg}}|yo{{tag|prn}}{{tag|pers}}{{tag|p1}}{{tag|sg}}{{tag|nom}} lo{{tag|prn}}{{tag|pers}}{{tag|p3}}{{tag|m}}{{tag|acc}} comer{{tag|v}}{{tag|tv}}{{tag|fut}}{{tag|p1}}{{tag|sg}}}}
 
*: {{transferMorphTest|fra|spa|je{{tag|prn}}{{tag|pers}}{{tag|p1}}{{tag|sg}}{{tag|nom}} le{{tag|prn}}{{tag|pers}}{{tag|p3}}{{tag|m}}{{tag|acc}} manger{{tag|v}}{{tag|tv}}{{tag|fut}}{{tag|p1}}{{tag|sg}}|yo{{tag|prn}}{{tag|pers}}{{tag|p1}}{{tag|sg}}{{tag|nom}} lo{{tag|prn}}{{tag|pers}}{{tag|p3}}{{tag|m}}{{tag|acc}} comer{{tag|v}}{{tag|tv}}{{tag|fut}}{{tag|p1}}{{tag|sg}}}}
  
−
== The assignment ==
+
* {{transferTest|fra|spa|Je l'ai vu|Yo lo vi}} ("I saw it.")
−
This assignment is due at the end of the 8th week of class (this semester: '''Friday, March 23rd, 2018 at 23:59''', i.e., by midnight)
+
*: {{transferMorphTest|fra|spa|je{{tag|prn}}{{tag|pers}}{{tag|p1}}{{tag|sg}}{{tag|nom}} le{{tag|prn}}{{tag|pers}}{{tag|p3}}{{tag|m}}{{tag|acc}}+avoir{{tag|vaux}}{{tag|pres}}{{tag|p1}}{{tag|sg}} voir{{tag|v}}{{tag|tv}}{{tag|prc_past}}|yo{{tag|prn}}{{tag|pers}}{{tag|p1}}{{tag|sg}}{{tag|nom}} lo{{tag|prn}}{{tag|pers}}{{tag|p3}}{{tag|m}}{{tag|acc}} ver{{tag|v}}{{tag|tv}}{{tag|ifi}}{{tag|p1}}{{tag|sg}}}}
 +
 
 +
* {{transferTest|tur|eng|yiyemeyeceğim|I won't be able to eat it}}
 +
*: {{transferMorphTest|tur|eng|ye{{tag|v}}{{tag|tv}}{{tag|abil}}{{tag|neg}}{{tag|fut}}+i{{tag|cop}}{{tag|aor}}{{tag|p1}}{{tag|sg}}|I{{tag|prn}}{{tag|pers}}{{tag|p1}}{{tag|sg}}{{tag|subj}} will{{tag|vaux}}+not{{tag|adv}} be{{tag|v}}{{tag|iv}}{{tag|inf}} able{{tag|adj}} to{{tag|pr}} eat{{tag|v}}{{tag|tv}}{{tag|inf}} it{{tag|prn}}{{tag|pers}}{{tag|p3}}{{tag|nt}}{{tag|obj}}}}
  
−
=== Getting started ===
+
=== What to focus on ===
−
# Figure out who and what languages you'd like to work with on MT (source and destination languages).  You can chose to work in the same or different groups, and to work with the language you're already working on or with a different language. This is an opportunity to regroup, especially if you don't enjoy the language you're working on, or you're having trouble working in your current group, etc.
+
To spell this out, you should focus on:
−
#* The simplest case is that the source language is the language you've been working on this semester and the destination language is English or another language you know well (are able to easily make sense of text in the language) and that has an open source transducer (e.g., in Apertium).
+
* any difference in word order, within a phrase, and of phrases.
−
#* You may also choose to do MT between your language and:
+
: For example, do nouns and adjectives occur in the same order in your two languages?  adpositions and noun phrases?  subjects and predicates (e.g., verbs)?
−
#** a closely related or structurally extremely similar language (e.g., that mark similar things on the same parts of speech and/or that have similar word order)
+
: Importantly, think of how words group together, and how the order of the groups are important. For example, in English, you can get a series of adjectives before a noun (''in an expensive big fancy white house''), so you can have preposition before a noun phrase, and within the noun phrase you get a determiner followed by an adjective phrase followed by a noun, and within the adjective phrase you get a whole bunch of adjectives.
−
#** a language spoken in close proximity to your language or shares similar cultural influences, even if unrelated (harder)
+
* any difference in how tags are used, including how they have to agree between words.
−
#* You may work in groups of 2 or 3, or in some rare cases I may allow groups of 4.
+
: An example of this might be subject-verb agreement, or gender agreement between adjectives and nouns.  Any type of grammatical marking in one language but not another is fair game.
−
#** In groups where both languages have been worked on up to this point in the course, each language should be both a source and destination of translation.
+
: But don't worry about subcategorisation, like transitivity in verbs or gender in nouns. (Note that in many languages with noun classes, such as "gender" systems, these classes constitute subcategory tags for nouns, but grammatical tags for adjectives.)
−
#** Otherwise, the destination language should be a language you're comfortable with.
 
−
# Get additional repositories set up:
 
−
#* If you are working with someone who's done another language in this class:
 
−
#** Share the corpus, keyboard, and transducer repos with each other.  I.e., give each other read access (not necessarily write access).
 
−
#** Fork the repos of the language you're translating from.  Do this through the github interface.
 
−
#** Clone the forked repos locally (in your ~/ling073 directory).
 
−
#** You'll want to look at the corpus repo for this assignment, and you'll want the other stuff around for later.  We'll also talk more about forking, pull requests, etc. later.
 
−
#* If you're working with another language that you know
 
−
#** Make sure you can type in the language
 
−
#** Fork the repository (on [http://github.com/apertium github.com]) for that language from Apertium and make sure everyone in your group has write access to the fork.
 
−
#** Clone the forked repo locally (in your ~/ling073 directory).
 
−
# Create a '''page on the wiki''' named "LanguageX and LanguageY" (either order, and just one page).
 
−
#* Add the page to the category [[:Category:Sp19_TranslationPairs]].
 
−
#* Put a note at the top along the lines of "Resources for machine translation between LanguageX and LanguageY", where the language names link back to your pages on them.
 
−
#* Add a link on each of the language pages to this new page, making a similar note as above.
 
  
−
=== Parallel corpus ===
+
== The assignment ==
−
# Create a repository on github named <code>ling073-xyz-abc-corpus</code> in the course github group.  Make sure both/all collaborators have full access to it.  Put a link to it on the wiki page in a section title "Developed resources".
+
This assignment is due at the end of the 11th week of class (this semester: '''Friday, April 9th, 2026 at 23:59''', i.e., by midnight)
−
# Construct a parallel corpus of at least 500 characters in one of the languages (or 250 characters if a syllabic writing system).  If you're doing translation to English, double this number (since you should already have some parallel text prepared).
 
−
#* The corpus will ideally consist of sentences with the same meaning.  You can extract sentences from translations of the same text (e.g., bible translations or the Universal Declaration of Human Rights), or use phrasebook examples that are similar.
 
−
#* You can also try to use example sentences from your sources to try to construct grammatical sentences with similar meaning, but make note of this.
 
−
#* In extreme cases, you may include short phrases with the same meaning, but please speak with the professor about this as soon as possible.
 
−
# Populate two files <code>xyz.sentences.txt</code> and <code>abc.sentences.txt</code> with the parallel text, one sentence per line. I recommend adding <code>eng.sentences.txt</code> to keep track of what the sentences mean if you're not working with English.
 
−
# Include a <code>LICENSE</code>, <code>AUTHORS</code>, and <code>MANIFEST</code> files as before (the latter to note origin and licensing of groups of sentences and any other notes).
 
  
 
=== Contrastive grammar ===
 
=== Contrastive grammar ===
−
# Create a page on the wiki named "LanguageX and LanguageY/Contrastive Grammar".  Add it to the category [[:Category:Sp19_ContrastiveGrammars]].  Add a link to the page under "Developed resources" on the main page.
+
# '''Create a page on the wiki''' named "{{rainbow|LanguageX}} and {{rainbow|LanguageY}}/Contrastive Grammar".  Add it to [[:Category:Sp26_ContrastiveGrammars]] and the categories for the two languages.  Add a link to the page under "Developed resources" on the main page.
−
# Identify at least five differences between the two languages.
+
# Using the ten sentences with all stems translated from the [[lexical transfer]] assignment, '''identify at least five differences''' between the two languages, trying to cover a range of phenomena (e.g., don't make everything about nouns).
−
#* These can be anything where the analyses of equivalent phrases look different when the roots are ignored: i.e., differences in tags used, differences in basic word order, etc.
+
#* These can be anything where the analyses of equivalent phrases look different when the roots are ignored: i.e., differences in tags used (will appear as <code>#</code> in full pipeline output), differences in basic word order, etc.  It can also be where a word is added (e.g., adding a definite article in English where one doesn't occur in another language) or where a tag determines a new word (e.g., a negative morpheme on a verb being realised as "not" in English).
−
# Document these differences on the wiki.
+
# '''Document these differences''' on the wiki.
−
#* You'll want on the order of two or three examples of each grammatical difference.
+
#* You'll want on the order of '''two or three examples''' of each grammatical difference.
−
#* Make two sections on the Contrastive Grammar page: one called "xyz-abc tests" and one called "abc-xyz tests".
+
#* '''Make a section''' on the Contrastive Grammar page for "{{rainbow|xyz}}-{{rainbow|abc}} tests"
−
#** If you're translating in one direction only, you just need "xyz-abc tests".
+
#** If you're doing two-way translation (i.e., you've joined forces with another group and each half of the group is working on a separate direction), then also add a section called "{{rainbow|abc}}-{{rainbow|xyz}} tests". In this case, each section will have equivalent tests, but in opposite directions.
−
#** Each section will have equivalent tests, but in opposite directions.
+
#* '''Use the [[Template:TransferMorphTest|TransferMorphTest]] and [[Template:TransferTest|TransferTest]] templates'''.  For each example, use both templates.  The use of these templates is demonstrated above and on the [[Transfer rules]] page. You'll scrape the content of these templates into a file later for testing, so make sure to use them correctly!
−
#* Use the [[Template:TransferMorphTest|TransferMorphTest]] and [[Template:TransferTest|TransferTest]] templates as used above and on the [[Transfer rules]] page.
 
  
 
[[Category:Assignments]]
 
[[Category:Assignments]]
 
[[Category:Contrastive grammar]]
 
[[Category:Contrastive grammar]]

Latest revision as of 14:01, 31 March 2026

A previous version of this document is available at Spring 2018/Contrastive grammar.

Some of the content that used to be here is now on the Lexical selection page.

Contrastive grammars

How to approach identifying linguistic differences

  • The last step we'll be implementing in our RBMT pipeline is structural transfer, where we can adjust the output of lexical transfer and lexical selection. We can adjust (change, add, subtract) tags and the order of words and phrases.
  • Start by comparing the current output of your translation system to the ideal output. Focus on words marked with # in the output and words in the wrong order. If you don't have many issues like this because your languages are similar, try looking at the output of a large corpus (e.g., Wikipedia or Bible translation) to identify such things.
  • For a given way of expressing the same thing (a translation, or equivalent sentence), find differences in the parse (tags or order generated versus expected), ignoring the content of the lexical items.
  • I.e., make sure a given full version of the sentence in each language is tagged correctly and otherwise translates correctly (has correct analysis, disambiguation, lexical transfer, and lexical selection), and then compare the output of the lex mode to the desired analysis to be generated (e.g., by running the correct translation through that language's transducer).

What constitutes a linguistic difference for structural transfer

  • You'll want to identify any differences in word order, tags used, etc.
    • An example of a set of similar languages might be:
      "Je le mangerai": ^je/je<prn><pers><p1><sg><nom>$ ^le/le<prn><pers><p3><m><acc>$ ^mangerais/manger<v><tv><fut><p1><sg>$
      "Yo lo comeré": ^yo/yo<prn><pers><p1><sg><nom>$ ^lo/lo<prn><pers><p3><m><acc>$ ^comeré/comer<v><tv><fut><p1><sg>$
    • An example of a set of rather different languages might be:
      "Yiyemeyeceğim": ^yiyemeyeceğim/ye<v><tv><abil><neg><fut>+i<cop><aor><p1><sg>$
      "I won't be able to eat it": ^I/I<prn><pers><p1><sg><subj>$ ^won't/will<vaux>+not<adv>$ ^be/be<v><iv><inf>$ ^able/able<adj>$ ^to/to<pr>$ $eat/eat<v><tv><inf>$ ^it/it<prn><pers><p3><nt><obj>$
  • In the above example of similar languages, there are no differences in tags, only in stems. Here there is nothing to contrast. In the above example of different languages, there is quite a bit that can be contrasted—but almost too much to break down into individual points.
  • An example of languages with some minor differences might be:
    • "Je l'ai vu": ^je/je<prn><pers><p1><sg><nom>$ ^l'ai/le<prn><pers><p3><m><acc>+avoir<vaux><pres><p1><sg>$ ^vu/voir<v><tv><prc_past>$
      "Yo lo vi": ^yo/yo<prn><pers><p1><sg><nom>$ ^lo/lo<prn><pers><p3><m><acc>$ ^vi/ver<v><tv><ifi><p1><sg>$
    • Here the difference is that one language uses the auxiliary with a participle where the other language uses a simple verb form
  • Note that the following does not constitute a contrastive difference
    • "Je mange la glace": ^je/je<prn><pers><p1><sg><nom>$ ^mange/manger<v><tv><pres><p1><sg>$ ^la/le<det><def><f>$ ^glace/glace<n><f>$
      "Yo como el hielo": ^yo/yo<prn><pers><p1><sg><nom>$ ^como/comer<v><tv><pres><p1><sg>$ ^el/el<det><def><m>$ ^hielo/hielo<n><m>$
    • This is still useful to note, as it can still be implemented as a transfer rule.

The examples above using templates

Click to edit or view the source of this section to see how the transferTest and transferMorphText templates are structured.

  • (fra) Je le mangerai → (spa) Yo lo comeré ("I'll eat it.")
    (fra) je<prn><pers><p1><sg><nom> le<prn><pers><p3><m><acc> manger<v><tv><fut><p1><sg> → (spa) yo<prn><pers><p1><sg><nom> lo<prn><pers><p3><m><acc> comer<v><tv><fut><p1><sg>
  • (fra) Je l'ai vu → (spa) Yo lo vi ("I saw it.")
    (fra) je<prn><pers><p1><sg><nom> le<prn><pers><p3><m><acc>+avoir<vaux><pres><p1><sg> voir<v><tv><prc_past> → (spa) yo<prn><pers><p1><sg><nom> lo<prn><pers><p3><m><acc> ver<v><tv><ifi><p1><sg>
  • (tur) yiyemeyeceğim → (eng) I won't be able to eat it
    (tur) ye<v><tv><abil><neg><fut>+i<cop><aor><p1><sg> → (eng) I<prn><pers><p1><sg><subj> will<vaux>+not<adv> be<v><iv><inf> able<adj> to<pr> eat<v><tv><inf> it<prn><pers><p3><nt><obj>

What to focus on

To spell this out, you should focus on:

  • any difference in word order, within a phrase, and of phrases.
For example, do nouns and adjectives occur in the same order in your two languages? adpositions and noun phrases? subjects and predicates (e.g., verbs)?
Importantly, think of how words group together, and how the order of the groups are important. For example, in English, you can get a series of adjectives before a noun (in an expensive big fancy white house), so you can have preposition before a noun phrase, and within the noun phrase you get a determiner followed by an adjective phrase followed by a noun, and within the adjective phrase you get a whole bunch of adjectives.
  • any difference in how tags are used, including how they have to agree between words.
An example of this might be subject-verb agreement, or gender agreement between adjectives and nouns. Any type of grammatical marking in one language but not another is fair game.
But don't worry about subcategorisation, like transitivity in verbs or gender in nouns. (Note that in many languages with noun classes, such as "gender" systems, these classes constitute subcategory tags for nouns, but grammatical tags for adjectives.)

The assignment

This assignment is due at the end of the 11th week of class (this semester: Friday, April 9th, 2026 at 23:59, i.e., by midnight)

Contrastive grammar

  1. Create a page on the wiki named "LanguageX and LanguageY/Contrastive Grammar". Add it to Category:Sp26_ContrastiveGrammars and the categories for the two languages. Add a link to the page under "Developed resources" on the main page.
  2. Using the ten sentences with all stems translated from the lexical transfer assignment, identify at least five differences between the two languages, trying to cover a range of phenomena (e.g., don't make everything about nouns).
    • These can be anything where the analyses of equivalent phrases look different when the roots are ignored: i.e., differences in tags used (will appear as # in full pipeline output), differences in basic word order, etc. It can also be where a word is added (e.g., adding a definite article in English where one doesn't occur in another language) or where a tag determines a new word (e.g., a negative morpheme on a verb being realised as "not" in English).
  3. Document these differences on the wiki.
    • You'll want on the order of two or three examples of each grammatical difference.
    • Make a section on the Contrastive Grammar page for "xyz-abc tests"
      • If you're doing two-way translation (i.e., you've joined forces with another group and each half of the group is working on a separate direction), then also add a section called "abc-xyz tests". In this case, each section will have equivalent tests, but in opposite directions.
    • Use the TransferMorphTest and TransferTest templates. For each example, use both templates. The use of these templates is demonstrated above and on the Transfer rules page. You'll scrape the content of these templates into a file later for testing, so make sure to use them correctly!