Guest User

Untitled

a guest
Apr 23rd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. DT The NP cat VB ate DT a NP rat
  2.  
  3. fragment TOKEN : (('A'..'Z') | ('a'..'z'))+;
  4. fragment WS : (' ' | 't')+;
  5. WSX : WS;
  6. DTTOK : ('DT' WS TOKEN);
  7. NPTOK : ('NP' WS TOKEN);
  8. nounPhrase: (DTTOK WSX NPTOK);
  9. chunker : nounPhrase {System.out.println("chunk found "+"("+$nounPhrase+")");};
  10.  
  11. WS : (' '|'t')+;
  12. TOKEN : (('A'..'Z') | ('a'..'z'))+;
  13. dttok : 'DT' WS TOKEN;
  14. nntok : 'NN' WS TOKEN;
  15. nounPhrase : (dttok WS nntok);
  16. chunker : nounPhrase ;
  17.  
  18. chunker : nounPhrase {System.out.println("chunk found "+"("+$nounPhrase.text+")");};
  19.  
  20. multiple_names returns [List<Name> names]
  21. @init {
  22. names = new ArrayList<Name>(4);
  23. }
  24. : a=fullname ' AND ' b=fullname { names.add($a.value); names.add($b.value); };
  25.  
  26. multiple_names returns [List<Name> names]
  27. @init {
  28. names = new ArrayList<Name>(4);
  29. }
  30. : a=fullname ' AND ' b=fullname { names.add($a); names.add($b); };
  31.  
  32. public final List<Name> multiple_names() throws RecognitionException {
  33. List<Name> names = null; // based on "returns" clause of rule definition
  34. Name a = null; // based on scopes declared in rule definition
  35. Name b = null; // based on scopes declared in rule definition
  36. names = new ArrayList<Name>(4); // snippet inserted from `@init` block
  37.  
  38. try {
  39. pushFollow(FOLLOW_fullname_in_multiple_names42);
  40. a=fullname();
  41. state._fsp--;
  42. match(input,189,FOLLOW_189_in_multiple_names44);
  43. pushFollow(FOLLOW_fullname_in_multiple_names48);
  44. b=fullname();
  45. state._fsp--;
  46. names.add($a); names.add($b);// code inserted from {...} block
  47. }
  48. catch (RecognitionException re) {
  49. reportError(re);
  50. recover(input,re);
  51. }
  52. finally {
  53. // do for sure before leaving
  54. }
  55. return names; // based on "returns" clause of rule definition
  56. }
  57.  
  58. multiple_names returns [List<Name> names]
  59. @init {
  60. names = new ArrayList<Name>(4);
  61. }
  62. : a=fullname ' AND ' b=fullname { names.add(a); names.add(b); };
Add Comment
Please, Sign In to add comment