CS Example: Parsing a Sentence

Post on 27-May-2015

258 views 0 download

Tags:

description

A worked example of parsing a natural language sentence using syntax diagrams.

Transcript of CS Example: Parsing a Sentence

© K.Becker Cpsc 233 Parse a Sentence

Parsing a Sentence Using the Syntax Diagrams

"The bearded lady hides but the

elephant thinks this thought."

© K.Becker Cpsc 233 Parse a Sentence

Start with : <STATEMENT>

The bearded lady hides but the elephant thinks this thought.

<Sentence> PUNCT

- get the first string; - find it in the dictionary

© K.Becker Cpsc 233 Parse a Sentence

Start with : <STATEMENT>

<Sentence> PUNCT

- got the first string; - found it in the dictionary

"The"ARTICLE

"*"

The bearded lady hides but the elephant thinks this thought.

© K.Becker Cpsc 233 Parse a Sentence

BEGIN : <SENTENCE>

<Sentence> PUNCT

- get the first string; - find it in the dictionary

"The"ARTICLE

"*"

The bearded lady hides but the elephant thinks this thought.

© K.Becker Cpsc 233 Parse a Sentence

Now IN : <SENTENCE>

"The"ARTICLE

"*"

The bearded lady hides but the elephant thinks this thought.

CONJ <Sentence>

<NounPhrase> <VerbPhrase>

© K.Becker Cpsc 233 Parse a Sentence

EXPECTING : <NOUNPHRASE>

"The"ARTICLE

"*"

The bearded lady hides but the elephant thinks this thought.

CONJ <Sentence>

<NounPhrase> <VerbPhrase>

© K.Becker Cpsc 233 Parse a Sentence

Now IN : <NOUNPHRASE>

"The"ARTICLE

"*"

The bearded lady hides but the elephant thinks this thought.

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

EXPECTING : ProNoun, ProperNoun, Article,

or Noun

"The"ARTICLE

"*"

The bearded lady hides but the elephant thinks this thought.

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

MATCHED : Article

"The"ARTICLE

"*"

The bearded lady hides but the elephant thinks this thought.

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

MATCHED : Article

"The"ARTICLE

"*"The bearded lady hides but

the elephant thinks this thought.

Push TOKEN onto QUEUE.Get next symbol.Find in Dictionary.

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCHED : Article

"bearded"ADJECTIVE"baratus"

Push TOKEN onto QUEUE.Get next symbol.Find in Dictionary.

"The"ARTICLE

"*"

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Still IN : <NOUNPHRASE>

"bearded"ADJECTIVE"baratus"

"The"ARTICLE

"*"

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

EXPECTING : <ADJECTIVELIST>

"bearded"ADJECTIVE"baratus"

"The"ARTICLE

"*"

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Now IN : <ADJECTIVELIST>

"bearded"ADJECTIVE"baratus"

"The"ARTICLE

"*"

{nothing}

Adjective

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

EXPECTING : Adjective

"bearded"ADJECTIVE"baratus"

"The"ARTICLE

"*"

{nothing}

Adjective

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCHED : Adjective

"bearded"ADJECTIVE"baratus"

"The"ARTICLE

"*"

{nothing}

Adjective

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCHED : Adjective

"bearded"ADJECTIVE"baratus"

"The"ARTICLE

"*"

Push TOKEN onto QUEUE.Get next symbol.Find in Dictionary.

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCHED : Adjective

"lady"noun

"domina"

"The"ARTICLE

"*"

Push TOKEN onto QUEUE.Get next symbol.Find in Dictionary.

"bearded"ADJECTIVE"baratus"

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Still IN : <ADJECTIVELIST>

"lady"noun

"domina"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

{nothing}

Adjective

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Still EXPECTING : Adjective

"lady"noun

"domina"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

{nothing}

Adjective

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Adjective NOT FOUND, RETURN..

"lady"noun

"domina"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

{nothing}

Adjective

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Back IN : <NOUNPHRASE>

"lady"noun

"domina"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

EXPECTING : Noun

"lady"noun

"domina"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCHED : Noun

"lady"noun

"domina"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCHED : Noun

"lady"noun

"domina"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

Push TOKEN onto QUEUE.Get next symbol.Find in Dictionary.

© K.Becker Cpsc 233 Parse a Sentence

MATCHED : Noun

"hides"VERB

"abscondo"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

Push TOKEN onto QUEUE.Get next symbol.Find in Dictionary.

"lady"NOUN

"domina"

The bearded lady hides but the elephant thinks this

thought.

© K.Becker Cpsc 233 Parse a Sentence

Now Leaving : <NOUNPHRASE>

"hides"VERB

"abscondo"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

The bearded lady hides but the elephant thinks this

thought.

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

Back IN : <SENTENCE>

"hides"VERB

"abscondo"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

The bearded lady hides but the elephant thinks this

thought.

CONJ <Sentence>

<NounPhrase> <VerbPhrase>

© K.Becker Cpsc 233 Parse a Sentence

EXPECTING : <VERBPHRASE>

"hides"VERB

"abscondo"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

The bearded lady hides but the elephant thinks this

thought.

CONJ <Sentence>

<NounPhrase><Verb-

Phrase>

© K.Becker Cpsc 233 Parse a Sentence

Now IN : <VERBPHRASE>

"hides"VERB

"abscondo"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

The bearded lady hides but the elephant thinks this

thought.

<NounPhrase> <AdverbList>Verb

<AdverbList> Verb <NounPhrase>

© K.Becker Cpsc 233 Parse a Sentence

EXPECTING : <ADVERBLIST> or Verb

"hides"VERB

"abscondo"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

The bearded lady hides but the elephant thinks this

thought.

<NounPhrase> <AdverbList>Verb

<AdverbList> Verb <NounPhrase>

© K.Becker Cpsc 233 Parse a Sentence

MATCHED : Verb

"hides"VERB

"abscondo"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

The bearded lady hides but the elephant thinks this

thought.

<NounPhrase> <AdverbList>Verb

<AdverbList> Verb <NounPhrase>

© K.Becker Cpsc 233 Parse a Sentence

MATCHED : Verb

"hides"VERB

"abscondo"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

The bearded lady hides but the elephant thinks this

thought.

Push TOKEN onto QUEUE.Get next symbol.Find in Dictionary.

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCHED : Verb

"but"CONJ

"ceterum"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

Push TOKEN onto QUEUE.Get next symbol.Find in Dictionary.

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

EXPECTING : <NOUNPHRASE> OR <ADVERBLIST>

"but"CONJ

"ceterum"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

<NounPhrase> <AdverbList>Verb

<AdverbList> Verb <NounPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

FOUND : Conjunction instead

"but"CONJ

"ceterum"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

<NounPhrase> <AdverbList>Verb

<AdverbList> Verb <NounPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Now Leaving <VERBPHRASE>

"but"CONJ

"ceterum"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

<NounPhrase> <AdverbList>Verb

<AdverbList> Verb <NounPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Back IN : <SENTENCE>

"but"CONJ

"ceterum"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

CONJ <Sentence>

<NounPhrase> <VerbPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

EXPECTING : CONJUNCTION

"but"CONJ

"ceterum"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

CONJ <Sentence>

<NounPhrase> <VerbPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCHED : CONJUNCTION

"but"CONJ

"ceterum"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

CONJ <Sentence>

<NounPhrase> <VerbPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCHED : CONJUNCTION

"but"CONJ

"ceterum"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

Push TOKEN onto QUEUE.Get next symbol.Find in Dictionary.

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCHED : CONJUNCTION

"the"ARTICLE

"*"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

Push TOKEN onto QUEUE.Get next symbol.Find in Dictionary.

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Still IN : <SENTENCE>

"the"ARTICLE

"*"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

CONJ <Sentence>

<NounPhrase> <VerbPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Now INTO : <SENTENCE> ** AGAIN**

"the"ARTICLE

"*"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

CONJ <Sentence>

<NounPhrase> <VerbPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Now IN : <SENTENCE> ** AGAIN**

"the"ARTICLE

"*"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

CONJ <Sentence>

<NounPhrase> <VerbPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

EXPECTING : <NOUNPHRASE>

"the"ARTICLE

"*"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

CONJ <Sentence>

<Noun-Phrase>

<VerbPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Now IN : <NOUNPHRASE>

"the"ARTICLE

"*"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

EXPECTING : ProNoun, ProperNoun, Article,

or Noun

"the"ARTICLE

"*"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCH : Article

"the"ARTICLE

"*"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCH : Article

"the"ARTICLE

"*"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

Push TOKEN onto QUEUE.Get next symbol.Find in Dictionary.

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCH : Article

"elephant"NOUN

"barrus"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

Push TOKEN onto QUEUE.Get next symbol.Find in Dictionary.

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Still IN : <NOUNPHRASE>

"elephant"NOUN

"barrus"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

EXPECTING : <ADJECTIVELIST>

"elephant"NOUN

"barrus"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

<Adjective-List>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Now IN : <ADJECTIVELIST>

"elephant"NOUN

"barrus"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

{nothing}

Adjective

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

EXPECTING : Adjective

"elephant"NOUN

"barrus"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

{nothing}

Adjective

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Adjective NOT FOUND, RETURN..

"elephant"NOUN

"barrus"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

{nothing}

Adjective

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Back IN : <NOUNPHRASE>

"elephant"NOUN

"barrus"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

EXPECTING : Noun

"elephant"NOUN

"barrus"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCH : Noun

"elephant"NOUN

"barrus"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCH : Noun

"elephant"NOUN

"barrus"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

Push TOKEN onto QUEUE.Get next symbol.Find in Dictionary.

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCH : Noun

"thinks"VERB

"cogito"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

Push TOKEN onto QUEUE.Get next symbol.Find in Dictionary.

"elephant"NOUN

"barrus"

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Leaving : <NOUNPHRASE>

"thinks"VERB

"cogito"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Back IN : <SENTENCE>

"thinks"VERB

"cogito"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"CONJ <Sentence>

<NounPhrase> <VerbPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

EXPECTING : <VERBPHRASE>

"thinks"VERB

"cogito"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"CONJ <Sentence>

<NounPhrase><Verb-

Phrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Now IN : <VERBPHRASE>

"thinks"VERB

"cogito"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"<NounPhrase> <AdverbList>Verb

<AdverbList> Verb <NounPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

EXPECTING : <ADVERBLIST> or Verb

"thinks"VERB

"cogito"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"<NounPhrase> <AdverbList>Verb

<AdverbList> Verb <NounPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCH : Verb

"thinks"VERB

"cogito"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"<NounPhrase> <AdverbList>Verb

<AdverbList> Verb <NounPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCH : Verb

"thinks"VERB

"cogito"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

Push TOKEN onto QUEUE.Get next symbol.Find in Dictionary.

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCH : Verb

"this"ARTICLE"addo"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

Push TOKEN onto QUEUE.Get next symbol.Find in Dictionary.

"thinks"VERB

"cogito"

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Still IN : <VERBPHRASE>

"this"ARTICLE"addo"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

<NounPhrase> <AdverbList>Verb

<AdverbList> Verb <NounPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

EXPECTING : <NOUNPHRASE> OR <ADVERBLIST>

"this"ARTICLE"addo"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

<NounPhrase> <AdverbList>Verb

<AdverbList> Verb <NounPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

FOUND : Article GOTO <NOUNPHRASE>

"this"ARTICLE"addo"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

<NounPhrase> <AdverbList>Verb

<AdverbList> Verb <NounPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Now IN : <NOUNPHRASE>

"this"ARTICLE"addo"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

EXPECTING : ProNoun, ProperNoun, Article,

or Noun

"this"ARTICLE"addo"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCH : Article

"this"ARTICLE"addo"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCH : Article "this"ARTICLE"addo"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

Push TOKEN onto QUEUE.Get next symbol.Find in Dictionary.

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCH : Article

"thought"NOUN

"cogitatus"

Push TOKEN onto QUEUE.Get next symbol.Find in Dictionary.

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Still IN : <NOUNPHRASE>

"thought"NOUN

"cogitatus"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

EXPECTING : <ADJECTIVELIST>

"thought"NOUN

"cogitatus"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

<Adjective-List>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Now IN : <ADJECTIVELIST>

"thought"NOUN

"cogitatus"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

{nothing}

Adjective

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

EXPECTING : Adjective

"thought"NOUN

"cogitatus"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

{nothing}

Adjective

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Adjective NOT FOUND, RETURN..

"thought"NOUN

"cogitatus"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

{nothing}

Adjective

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Back IN : <NOUNPHRASE>

"thought"NOUN

"cogitatus"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

EXPECTING : Noun

"thought"NOUN

"cogitatus"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCH : Noun

"thought"NOUN

"cogitatus"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCH : Noun "thought"NOUN

"cogitatus"

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"Push TOKEN onto QUEUE.

Get next symbol.Find in Dictionary.

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCH : Noun

"."??""

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"Push TOKEN onto QUEUE.

Get next symbol.Find in Dictionary.

"thought"NOUN

"cogitatus"

NOT FOUND....---but we don't know or

care yet---

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Leaving : <NOUNPHRASE>

"."??""

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

"thought"NOUN

"cogitatus"

<AdjectiveList>

ProNoun

ProperNoun

Article

Noun

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Still IN : <VERBPHRASE>

"."??""

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

"thought"NOUN

"cogitatus"

<NounPhrase> <AdverbList>Verb

<AdverbList> Verb <NounPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

EXPECTING : <ADVERBLIST> OR NOT

"."??""

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

"thought"NOUN

"cogitatus"

<NounPhrase> <AdverbList>Verb

<AdverbList> Verb <NounPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

FOUND : NOT, RETURN..

"."??""

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

"thought"NOUN

"cogitatus"

<NounPhrase> <AdverbList>Verb

<AdverbList> Verb <NounPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Back TO : <SENTENCE> ** AGAIN**

"."??""

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

"thought"NOUN

"cogitatus"

CONJ <Sentence>

<NounPhrase> <VerbPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

EXPECTING : CONJUNCTION or NOT

"."??""

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

"thought"NOUN

"cogitatus"

CONJ <Sentence>

<NounPhrase> <VerbPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

FOUND : NOT, RETURN..

"."??""

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

"thought"NOUN

"cogitatus"

CONJ <Sentence>

<NounPhrase> <VerbPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Back TO : <SENTENCE>

"."??""

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

"thought"NOUN

"cogitatus"

CONJ <Sentence>

<NounPhrase> <VerbPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Now Leaving : <SENTENCE>

"."??""

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

"thought"NOUN

"cogitatus"

CONJ <Sentence>

<NounPhrase> <VerbPhrase>

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Finally Back TO : <STATEMENT>

"."??""

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

"thought"NOUN

"cogitatus"

<Sentence> PUNCT

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

EXPECTING : PUNCTUATION

"."??""

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

"thought"NOUN

"cogitatus"

<Sentence> PUNCT

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCH : PUNCTUATION

"."??""

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

"thought"NOUN

"cogitatus"

<Sentence> PUNCT

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCH : PUNCTUATION"." / ?? / ""

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

"thought"NOUN

"cogitatus"

Push TOKEN onto QUEUE.Get next symbol.Find in Dictionary.

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

MATCH : PUNCTUATION

EOLN

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

"thought"NOUN

"cogitatus"

Push TOKEN onto QUEUE.Get next symbol.END-OF-LINE

"." / ?? / ""

© K.Becker Cpsc 233 Parse a Sentence

The bearded lady hides but the elephant thinks this

thought.

Now Leaving : <STATEMENT>

EOLN

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

"thought"NOUN

"cogitatus"

"." / ?? / ""

© K.Becker Cpsc 233 Parse a Sentence

--DONE PARSING--

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

"thought"NOUN

"cogitatus"

"." / ?? / ""

on to the next phase,but first.....

© K.Becker Cpsc 233 Parse a Sentence

What the QUEUE ACTUALLY Looks Like

(with TOKENS rather than WORDS)

© K.Becker Cpsc 233 Parse a Sentence

What the QUEUE ACTUALLY Looks Like

"The"ARTICLE

"*"

"bearded"ADJECTIVE"baratus"

"lady"NOUN

"domina"

"hides"VERB

"abscondo"

"but"CONJ

"ceterum"

"the"ARTICLE

"*"

"elephant"NOUN

"barrus"

"thinks"VERB

"cogito"

"this"ARTICLE"addo"

"thought"NOUN

"cogitatus"

"." / ?? / ""

the queue

tokens

© K.Becker Cpsc 233 Parse a Sentence

What remains is to pull off the TOKENS,

one by one,if it is a WORD

then print out the translation,if it is NOT

then print IT out.

© K.Becker Cpsc 233 Parse a Sentence

AND TA-DA!!!!

A ten-word nonsense statement gets translated into

equally non-sensical Latin using a mere few hundred

lines of code.