Skip to content

Commit 5a258ba

Browse files
committed
Implement uniq before sort
1 parent c2ca952 commit 5a258ba

File tree

4 files changed

+41
-34
lines changed

4 files changed

+41
-34
lines changed

src/edu/stanford/nlp/semgraph/semgrex/SemgrexParser.java

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ final public SemgrexPattern Root() throws ParseException {// Root pattern for th
5252
List<SemgrexPattern> children = new ArrayList<SemgrexPattern>();
5353
Token startToken = null;
5454

55-
List<String> sortKeys = null;
55+
List<String> uniqKeys = null;
5656
Token nextIdentifier = null;
5757
// a local variable
5858

@@ -105,12 +105,12 @@ final public SemgrexPattern Root() throws ParseException {// Root pattern for th
105105
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
106106
case 12:{
107107
jj_consume_token(12);
108-
jj_consume_token(SORT);
109-
sortKeys = new ArrayList<>();
108+
jj_consume_token(UNIQ);
109+
uniqKeys = new ArrayList<>();
110110
label_2:
111111
while (true) {
112112
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
113-
case SORT:
113+
case UNIQ:
114114
case IDENTIFIER:{
115115
;
116116
break;
@@ -120,7 +120,7 @@ final public SemgrexPattern Root() throws ParseException {// Root pattern for th
120120
break label_2;
121121
}
122122
nextIdentifier = identifier();
123-
sortKeys.add(nextIdentifier.image);
123+
uniqKeys.add(nextIdentifier.image);
124124
}
125125
break;
126126
}
@@ -140,7 +140,7 @@ final public SemgrexPattern Root() throws ParseException {// Root pattern for th
140140
result = SubNode(r);
141141
jj_consume_token(14);
142142
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
143-
case SORT:
143+
case UNIQ:
144144
case RELATION:
145145
case ALIGNRELN:
146146
case IDENTIFIER:
@@ -168,7 +168,7 @@ final public SemgrexPattern Root() throws ParseException {// Root pattern for th
168168
case 28:{
169169
result = ModNode(r);
170170
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
171-
case SORT:
171+
case UNIQ:
172172
case RELATION:
173173
case ALIGNRELN:
174174
case IDENTIFIER:
@@ -228,7 +228,7 @@ final public SemgrexPattern Root() throws ParseException {// Root pattern for th
228228
label_4:
229229
while (true) {
230230
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
231-
case SORT:
231+
case UNIQ:
232232
case RELATION:
233233
case ALIGNRELN:
234234
case IDENTIFIER:
@@ -267,7 +267,7 @@ final public SemgrexPattern Root() throws ParseException {// Root pattern for th
267267
final public SemgrexPattern ModRelation() throws ParseException {SemgrexPattern child;
268268
boolean startUnderNeg;
269269
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
270-
case SORT:
270+
case UNIQ:
271271
case RELATION:
272272
case ALIGNRELN:
273273
case IDENTIFIER:
@@ -307,7 +307,7 @@ final public SemgrexPattern Root() throws ParseException {// Root pattern for th
307307
jj_consume_token(20);
308308
break;
309309
}
310-
case SORT:
310+
case UNIQ:
311311
case RELATION:
312312
case ALIGNRELN:
313313
case IDENTIFIER:{
@@ -333,11 +333,11 @@ final public SemgrexPattern Root() throws ParseException {// Root pattern for th
333333
SemgrexPattern node;
334334
boolean pC = false;
335335
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
336-
case SORT:
336+
case UNIQ:
337337
case RELATION:
338338
case IDENTIFIER:{
339339
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
340-
case SORT:
340+
case UNIQ:
341341
case IDENTIFIER:{
342342
numArg = identifier();
343343
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
@@ -358,11 +358,11 @@ final public SemgrexPattern Root() throws ParseException {// Root pattern for th
358358
}
359359
rel = jj_consume_token(RELATION);
360360
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
361-
case SORT:
361+
case UNIQ:
362362
case IDENTIFIER:
363363
case REGEX:{
364364
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
365-
case SORT:
365+
case UNIQ:
366366
case IDENTIFIER:{
367367
relnType = identifier();
368368
break;
@@ -569,8 +569,9 @@ final public SemgrexPattern Root() throws ParseException {// Root pattern for th
569569
Token attrType = null;
570570
boolean negated = false;
571571
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
572+
case UNIQ:
572573
case IDENTIFIER:{
573-
attr = jj_consume_token(IDENTIFIER);
574+
attr = identifier();
574575
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
575576
case 11:
576577
case 24:{
@@ -589,8 +590,9 @@ final public SemgrexPattern Root() throws ParseException {// Root pattern for th
589590
throw new ParseException();
590591
}
591592
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
593+
case UNIQ:
592594
case IDENTIFIER:{
593-
value = jj_consume_token(IDENTIFIER);
595+
value = identifier();
594596
break;
595597
}
596598
case REGEX:{
@@ -611,8 +613,9 @@ final public SemgrexPattern Root() throws ParseException {// Root pattern for th
611613
case 25:{
612614
jj_consume_token(25);
613615
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
616+
case UNIQ:
614617
case IDENTIFIER:{
615-
key = jj_consume_token(IDENTIFIER);
618+
key = identifier();
616619
break;
617620
}
618621
case REGEX:{
@@ -639,8 +642,9 @@ final public SemgrexPattern Root() throws ParseException {// Root pattern for th
639642
throw new ParseException();
640643
}
641644
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
645+
case UNIQ:
642646
case IDENTIFIER:{
643-
value = jj_consume_token(IDENTIFIER);
647+
value = identifier();
644648
break;
645649
}
646650
case REGEX:{
@@ -671,8 +675,9 @@ final public SemgrexPattern Root() throws ParseException {// Root pattern for th
671675
}
672676
jj_consume_token(26);
673677
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
678+
case UNIQ:
674679
case IDENTIFIER:{
675-
key = jj_consume_token(IDENTIFIER);
680+
key = identifier();
676681
break;
677682
}
678683
case REGEX:{
@@ -699,8 +704,9 @@ final public SemgrexPattern Root() throws ParseException {// Root pattern for th
699704
throw new ParseException();
700705
}
701706
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
707+
case UNIQ:
702708
case IDENTIFIER:{
703-
value = jj_consume_token(IDENTIFIER);
709+
value = identifier();
704710
break;
705711
}
706712
case REGEX:{
@@ -752,6 +758,7 @@ final public SemgrexPattern Root() throws ParseException {// Root pattern for th
752758
NodePattern pat;
753759
jj_consume_token(28);
754760
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
761+
case UNIQ:
755762
case IDENTIFIER:
756763
case EMPTY:
757764
case ROOT:{
@@ -803,8 +810,8 @@ final public SemgrexPattern Root() throws ParseException {// Root pattern for th
803810

804811
final public Token identifier() throws ParseException {Token t ;
805812
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
806-
case SORT:{
807-
t = jj_consume_token(SORT);
813+
case UNIQ:{
814+
t = jj_consume_token(UNIQ);
808815
break;
809816
}
810817
case IDENTIFIER:{
@@ -835,7 +842,7 @@ final public SemgrexPattern Root() throws ParseException {// Root pattern for th
835842
jj_la1_init_0();
836843
}
837844
private static void jj_la1_init_0() {
838-
jj_la1_0 = new int[] {0x800,0x100a2010,0x24,0x1000,0xe003c,0xe003c,0x100a2000,0x8000,0xf003c,0x10000,0xe003c,0x8003c,0x200000,0x24,0x224,0x224,0x400000,0x800000,0x3c,0x100a2000,0x8000,0x100b0000,0x10000,0x100a0000,0x10080000,0x1000800,0x220,0x220,0x1000800,0x220,0x4000000,0x220,0x1000800,0x220,0x3000800,0x1a0,0x4000000,0x1a0,0x800000,0x24,};
845+
jj_la1_0 = new int[] {0x800,0x100a2010,0x24,0x1000,0xe003c,0xe003c,0x100a2000,0x8000,0xf003c,0x10000,0xe003c,0x8003c,0x200000,0x24,0x224,0x224,0x400000,0x800000,0x3c,0x100a2000,0x8000,0x100b0000,0x10000,0x100a0000,0x10080000,0x1000800,0x224,0x224,0x1000800,0x224,0x4000000,0x224,0x1000800,0x224,0x3000800,0x1a4,0x4000000,0x1a4,0x800000,0x24,};
839846
}
840847

841848
/** Constructor with InputStream. */

src/edu/stanford/nlp/semgraph/semgrex/SemgrexParser.jj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ SPECIAL_TOKEN:
6262

6363
TOKEN:
6464
{
65-
< SORT: "sort" >
65+
< UNIQ: "uniq" >
6666
}
6767

6868
TOKEN:
@@ -83,7 +83,7 @@ SemgrexPattern Root() : {
8383
List<SemgrexPattern> children = new ArrayList<SemgrexPattern>();
8484
Token startToken = null;
8585

86-
List<String> sortKeys = null;
86+
List<String> uniqKeys = null;
8787
Token nextIdentifier = null;
8888
// a local variable
8989
} {
@@ -110,7 +110,7 @@ SemgrexPattern Root() : {
110110
}
111111
}
112112
(
113-
("::" <SORT> { sortKeys = new ArrayList<>(); } (nextIdentifier = identifier() { sortKeys.add(nextIdentifier.image); })* )?
113+
("::" <UNIQ> { uniqKeys = new ArrayList<>(); } (nextIdentifier = identifier() { uniqKeys.add(nextIdentifier.image); })* )?
114114
)
115115
{
116116
return node;
@@ -356,5 +356,5 @@ Token identifier() : {
356356
Token t ;
357357
}
358358
{
359-
( t = < SORT > | t = < IDENTIFIER > ) { return t; }
359+
( t = < UNIQ > | t = < IDENTIFIER > ) { return t; }
360360
}

src/edu/stanford/nlp/semgraph/semgrex/SemgrexParserConstants.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface SemgrexParserConstants {
1313
/** RegularExpression Id. */
1414
int WHITESPACE = 1;
1515
/** RegularExpression Id. */
16-
int SORT = 2;
16+
int UNIQ = 2;
1717
/** RegularExpression Id. */
1818
int RELATION = 3;
1919
/** RegularExpression Id. */
@@ -36,7 +36,7 @@ interface SemgrexParserConstants {
3636
String[] tokenImage = {
3737
"<EOF>",
3838
"<WHITESPACE>",
39-
"\"sort\"",
39+
"\"uniq\"",
4040
"<RELATION>",
4141
"\"@\"",
4242
"<IDENTIFIER>",

src/edu/stanford/nlp/semgraph/semgrex/SemgrexParserTokenManager.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private int jjMoveStringLiteralDfa0_0(){
9696
return jjStopAtPos(0, 19);
9797
case 93:
9898
return jjStopAtPos(0, 20);
99-
case 115:
99+
case 117:
100100
return jjMoveStringLiteralDfa1_0(0x4L);
101101
case 123:
102102
return jjStopAtPos(0, 28);
@@ -124,7 +124,7 @@ private int jjMoveStringLiteralDfa1_0(long active0){
124124
else if ((active0 & 0x1000000L) != 0L)
125125
return jjStopAtPos(1, 24);
126126
break;
127-
case 111:
127+
case 110:
128128
return jjMoveStringLiteralDfa2_0(active0, 0x4L);
129129
case 123:
130130
if ((active0 & 0x2000000L) != 0L)
@@ -145,7 +145,7 @@ private int jjMoveStringLiteralDfa2_0(long old0, long active0){
145145
}
146146
switch(curChar)
147147
{
148-
case 114:
148+
case 105:
149149
return jjMoveStringLiteralDfa3_0(active0, 0x4L);
150150
default :
151151
break;
@@ -162,7 +162,7 @@ private int jjMoveStringLiteralDfa3_0(long old0, long active0){
162162
}
163163
switch(curChar)
164164
{
165-
case 116:
165+
case 113:
166166
if ((active0 & 0x4L) != 0L)
167167
return jjStartNfaWithStates_0(3, 2, 8);
168168
break;
@@ -424,7 +424,7 @@ else if (curChar < 128)
424424

425425
/** Token literal values. */
426426
public static final String[] jjstrLiteralImages = {
427-
"", null, "\163\157\162\164", null, "\100", null, null, "\43", "\44", null,
427+
"", null, "\165\156\151\161", null, "\100", null, null, "\43", "\44", null,
428428
"\12", "\72", "\72\72", "\50", "\51", "\174", "\46", "\41", "\77", "\133", "\135",
429429
"\54", "\176", "\75", "\41\72", "\72\173", "\73", "\175", "\173", };
430430
protected Token jjFillToken()

0 commit comments

Comments
 (0)