Example 4: Simple HPSG grammar

The parser can be used by running:
java -jar stefs.jar
(or: java -classpath stefs.jar stefs.Interpreter).

Input:

// $Id: 04,v 1.1 2007/03/24 04:04:37 vlado Exp $
// test04: based on grammar2.pl from "HPSG Grammars in ALE" (public)

// Lexical entries

[cat:[head:[noun]
            subj:-     ]] -> sandy.   // Now "sandy" cannot have a subject

[cat:[head:[verb]
      subj:cat:head:[noun]]] -> snored.

// Grammar rules

[cat:head:[verb]] -> [cat:head:#Head] [cat:subj:cat:head:#Head].

tokenize <s>sandy snored</s>
parse;
println BestParse + "\n";

tokenize <s>snored sandy</s>  // this can not be parsed
parse

Output:

1 successful parse
parsing time:0.0020 seconds
[top
 cat: [top
       head: [verb]]
_from: 0
  _to: 12
_orth: 'sandy snored']

no successful parses
parsing time:0.0010 seconds


© 2000-2007 Vlado Keselj, last update: March 27, 2007.