CS267
Chris Pollett
Oct. 24, 2012
Exercise 5.4. Express the following queries in the region algebra.
(a) Find plays that contain "Birnam" followed by "Dunsinane".
Answer. ("<PLAY>" ... "</PLAY>") |> ("Birnam Dunsinane").
The above is immediately followed by. If you want that Dursiname occurs after Birnam could use "...". Note this returns the whole play.
(b) Find fragments of text that contain "Birnam" and "Dunsinane".
Answer. "Birnam" Δ "Dunsinane". I'll keep it this simple since it is unclear where exactly is meant by "fragments of text".
(c) Find plays in which the word "Birnam" is spoken by a witch.
Answer. ("<PLAY>" ... "</PLAY>") |> ("Birnam" <|("<LINE>" ... "</LINE>") < |
("<SPEECH>" ... "</SPEECH>") |> ("<SPEAKER>" ... "</SPEAKER>") |> "witch"
)
(d) Find speeches that contain "toil" or "trouble" in the first line, and do not contain "burn" or "bubble" in the second line.
Answer. This ones somewhat painful so am only giving an approximate solution ...
("<SPEECH>" ... "</SPEECH>") |>
(("<LINE>" ... "</LINE>" |> "toil" `grad` "touble") ... ("<LINE>" ... "</LINE>")) NOT |> "burn" `grad` "bubble".
(e) Find a speech by an apparition that contains "fife" and that appears in a scene along with the line "Something wicked this way comes".
Answer. (("<SPEECH>" ... "</SPEECH>" |> "fife") |> ("<SPEAKER>" ... "</SPEAKER>") |> "apparition") Δ ("<SCENE>" ... "</SCENE>") |> ("<LINE>" ... "</LINE>" |> "Something wicked this way comes")