Practical Grammar 2: Difference between revisions

From English Grammar
Jump to navigation Jump to search
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 13: Line 13:


# Choose Workshops|All Workshops.
# Choose Workshops|All Workshops.
# Look for the workshop "Syntax 1 in WiSe 2022".
# Look for the workshop "Syntax 1" for the current semester.
# In the column "Action", click the button "Consult the workshop".
# In the column "Action", click the button "Consult the workshop".


Line 41: Line 41:


(1) John [disappeared].<br>
(1) John [disappeared].<br>
(2) The bottle [broke].<br>
(2) the bottle [broke].<br>
(3) Martha [stayed at the hospital].<br>
(3) Martha [stayed at the hospital].<br>
(4) Fred [talks about Chicago].<br>
(4) Fred [talked about Chicago].<br>
(5) Robert [went to the hospital].<br>
(5) Robert [went to the hospital].<br>
(6) Alice [moved into the room].<br>
(6) Alice [moved into the room].<br>
(7) Joe [saw Fred].<br>
(7) Joe [saw Fred].<br>
(8) Alice [broke the bottle].<br>
(8) Alice [broke the bottle].<br>
(9) We [moved it into the room].<br>
(9) we [moved it into the room].<br>
(10) Fred [took Alice to the hospital].<br>
(10) Fred [took Alice to the hospital].<br>
(11) John [sent Martha a check].<br>
(11) John [sent Martha a check].<br>
(12) We [gave Fred a wastebasket].
(12) we [gave Fred a wastebasket].


=== Syntactic Categories ===
=== Syntactic Categories ===
Line 62: Line 62:
* Click on "Test suite".
* Click on "Test suite".


You see all the test sentences for the grammar. Our first example sentence is already listed. Eventually, you will have to enter the other example sentences as well.
You see all the test sentences for the grammar. Our test sentences are already listed.  


The example sentence is "John disappeared" and on the right we have told the program that this sentence is grammatical in English.
The first example sentence is "John disappeared" and on the right we have told the program that this sentence is grammatical in English.


We will now test this example against our grammar. To this end,  
We will now test this example against our grammar. To this end,  
Line 127: Line 127:
<font size="2">
<font size="2">
<div align="center">
<div align="center">
     [[Practical_Grammar|'''Main page''']]  '''Week 2'''  [[Practical_Grammar_3|'''Week 3''']]  [[Practical_Grammar_4|'''Week 4''']]  [[Practical_Grammar_5|'''Week 5''']]  [[Practical_Grammar_6|'''Week 6''']]  [[Practical_Grammar_7|'''Week 7''']]  [[Practical_Grammar_8|'''Week 8''']]  [[Practical_Grammar_9|'''Week 9''']]   
     [[Practical_Grammar|'''Main page''']]  '''Week 2'''  [[Practical_Grammar_3|'''Week 3''']]  [[Practical_Grammar_4|'''Week 4''']]  [[Practical_Grammar_5|'''Week 5''']]  [[Practical_Grammar_6|'''Week 6''']]  [[Practical_Grammar_7_new|'''Week 7''']]  [[Practical_Grammar_8|'''Week 8''']]  [[Practical_Grammar_9|'''Week 9''']]   
</div>
</div>

Latest revision as of 06:15, 1 April 2025

Your first grammar in xlfg

Please do the following:

You first log onto xlfg:

  1. Go to https://xlfg.labri.fr/ and log in.

Then you locate our workshop:

  1. Choose Workshops|All Workshops.
  2. Look for the workshop "Syntax 1" for the current semester.
  3. In the column "Action", click the button "Consult the workshop".

Now you find a project of the workshop:

  1. On the right side of the screen is the list of projects of our workshop.
  2. Look for "Grammar 1" and click on "Create your own version".
  3. Now click on "Edit your version".

You have now arrived in the grammar editor for the grammar "Grammar 1", where you can make changes to the grammar.

Look around a bit, but leave the button "Output Parameters" alone for now.

Click on the buttons in the row beginning with "Test suite". Whenever you do, a window will open where you can enter or change information. Do not make any changes yet. To get to a different input window, just click on its button.

The four input buttons have the following functions:

  • Test suite: here you can type in example sentences that you want to test.
  • Declarations: here you can enter information that determines the behavior of the program.
  • Grammar: this is where you add phrase structure rules.
  • Lexicon: the place to write lexical entries.

Exercise 2.1

We are now going to write a first grammar. The goal of the grammar is to recognize all the sentences from Exercise 1.1. Here they are one more time, together with the syntactic categories we want to use in the exercise:

Sentences

(1) John [disappeared].
(2) the bottle [broke].
(3) Martha [stayed at the hospital].
(4) Fred [talked about Chicago].
(5) Robert [went to the hospital].
(6) Alice [moved into the room].
(7) Joe [saw Fred].
(8) Alice [broke the bottle].
(9) we [moved it into the room].
(10) Fred [took Alice to the hospital].
(11) John [sent Martha a check].
(12) we [gave Fred a wastebasket].

Syntactic Categories

S, NP, N, VP, V, PP, P, AP, A, D

The first example sentence

  • Go to the xlfg window.
  • Click on "Test suite".

You see all the test sentences for the grammar. Our test sentences are already listed.

The first example sentence is "John disappeared" and on the right we have told the program that this sentence is grammatical in English.

We will now test this example against our grammar. To this end,

  • Click on the blue "Parse the whole test suite" button right below the name of our project. "to parse" in German means "Daten analysieren".

This instructs xlfg to inspect all test sentences to see whether the grammar licenses them.

The result is diappointing: a new window opens and we read the following in the first line:

  • Unknown word: disappeared

The grammar can only parse a sentence, if it knows all the words in the sentence. This problem is easy to fix:

  • Click on "Input" to get back to the editor window. Let us inspect the grammar!
  • Click on "Lexicon". There is only one line:
 John N;

This says that there is a lexical entry spelled "John" and that its syntactic category is "N". This makes sense.

It is easy to add more words to the lexicon:

  • Enter the following into the second line of the "Lexicon" editor:
 disappeared V;

Make sure that you end every lexical entry with a semicolon. Otherwise, xlfg will create an error message. It needs to know where one lexical entry ends and the next one starts.

  • Click on "Save this version" to save your new grammar!

Now that the grammar knows both words of our sentence, we parse the sentence again:

  • Click on "Parse the whole test suite".

The output window opens again: we see our example sentence in depressing red: the grammar still does not recognize our sentence! It tells you that in two ways:

  • It doesn't draw a tree in the box labeled "Constituent Structure".
  • At the righthand side of the line that contains our test sentence, it says 0 CS, which means that the sentence is compatible with no constituent structures that the grammar licenses.

Let us find out what the problem is this time.

  • Click on "Input" to get back to the editor. When you click on "Grammar", you will see immediately why the sentence is not recognized: the grammar does not have all the phrase structure rules needed to draw a complete tree for the sentence!

Let's fix this problem next.

  • Add the following PS rules, one per line, making sure that you end each rule with a semicolon:
 NP -> N;
 VP -> V;

Use the button labeled "->" above line 1 to enter the arrow! Do not enter any arrows from your keyboard, as xlfg will throw an error.

  • Parse.

Now, the output window should open. Our test sentence "John disappears" should appear in green and the box labeled "Constituent Structure" should contain a phrase structure tree of our sentence, which is xlfg's way of saying that our grammar recognizes the string "John disappears" as grammatical!

Exercise 2.2

  • If you aren't there already, then click on "Input" to go back to the editors.

For every remaining example sentence (2)-(12), do the following:

  • Click on "+ Add a sentence".
  • Enter the sentence into the textbox that opens.
  • Test the sentence! If it parses, then move on to the next sentence.
  • If the sentence does not parse yet, then add the lexical entries and phrase structure rules needed to parse it.
  • Make sure to save your grammar each time you have made a change!