Skip to content

Commit 8c10e94

Browse files
committed
adding datasets and python files
1 parent 0c84320 commit 8c10e94

14 files changed

+494210
-3
lines changed

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
# SpaceNLI
2-
Natural Language Inference problems specialized for spatial semantics & reasoning
2+
Natural Language Inference problems specialized for spatial semantics & reasoning.
3+
4+
The NLI problem patterns and automatically generated NLI sample problems are under `dataset/`.
5+
6+
# Generating data
7+
The dataset of NLI sample problems is generated from the patterns (using the mini world with selection restrictions and a toy grammar) with the following command:
38

49
```
5-
More details will be added
10+
python/generate_nli.py --sr config/selection_restriction.yaml --gr python/base_grammar.fcfg dataset/problem_patterns.xml -v --out dataset/160x200.json --out-max-seed 200
611
```
12+
Note that changes to the selection restriction file can result in a different sample dataset as the fixed number of problems (e.g., 200) per pattern are randomly drawn from the all possible samples per pattern.
13+
14+
715

816
# Paper
9-
The work will be presented at NALOMA workshop.
17+
18+
Abzianidze, L., Zwarts, J., Winter, Y. (2023). **SpaceNLI: Evaluating the Consistency of Predicting Inferences In Space.** In Proceedings of the 4th Natural Logic Meets Machine Learning Workshop (NALOMA IV).

config/selection_restriction.yaml

Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
# yaml file for encoding selection restrictions for verbs
2+
3+
us_city_pn: &US_CITY {Los Angeles, San Diego, San Jose, San Francisco, Fresno, Sacramento, Las Vegas, Henderson, Reno, Sparks, Carson City, Fernley}
4+
eu_city_pn: &EU_CITY {Amsterdam, Utrecht, Tilburg, Rotterdam, Groningen, Nijmegen, Antwerp, Ghent, Charleroi, Brussels, Bruges, Leuven, Berlin, Hamburg, Munich, Cologne, Stuttgart, Frankfurt, Paris, Marseille, Lyon, Toulouse, Nice, Nantes}
5+
city_pn: &CITY {<<: *US_CITY, <<: *EU_CITY}
6+
7+
us_state_pn: &US_STATE {California, Nevada}
8+
eu_state_pn: &EU_STATE {the Netherlands, Belgium, Germany, France}
9+
state_pn: &STATE {<<: *US_STATE, <<: *EU_STATE}
10+
11+
city_state_pn: &CIT_STA {<<: *CITY, <<: *STATE}
12+
13+
# John, Mary
14+
name_pn: &PER_NAM { John, Mary, Cindi, Bill, Taylor, Ann, Kate }
15+
16+
generic_person_n: &GENERIC_PERSON { person, man, woman, boy, girl, adult, teenager, kid, child, teacher, student, professor, doctor, driver }
17+
# nurse, patient, actor, singer, wrter, artist, athlete, musician
18+
19+
person_n: &PER { <<: *PER_NAM, <<: *GENERIC_PERSON }
20+
# person_n: &PER { boy, girl, man, woman, <<: *PER_NAM }
21+
22+
# animal_n: &ANIMAL { cat, cow, dog, horse, poodle, tiger }
23+
animal_n: &ANIMAL { cat, dog, pig, goat, sheep }
24+
person_animal_n: &PER_ANM { <<: *PER, <<: *ANIMAL }
25+
food_n: &FOOD { watermelon, pumpkin, cabbage, potatoe, orange, beet, aubergine, apple }
26+
27+
crossable_n: &CROSS { road, street, line, border, river, bridge }
28+
29+
cloth_n: &CLOTH { t-shirt, jeans, sweater, hoodie, shorts, pants, jacket, coat, suit, cardigan, poncho, blazer, kimono, sweatshirt, sweatpants, costume }
30+
31+
# building_n: &BUILDING { building, church, house, hut, room }
32+
building_n: &BUILDING { building, house, school, hospital, museum, store, tower, station, church }
33+
construction_n: &CONSTRUCTION { bridge }
34+
35+
enter_in_n: &ENTER_IN { room, market, forest, tunnel, <<: *BUILDING }
36+
run_in_n: &RUN_IN { garden, forest, park, street }
37+
vehicle_n: &VEHICLE { car, helicopter, bus, truck, train, tram, plane }
38+
be_in_n: &BE_IN { <<: *VEHICLE, <<: *ENTER_IN, <<: *RUN_IN }
39+
be_on_n: &BE_ON { mountain, rooftop, hill, bridge, playground, rug, stage }
40+
be_at_n: &BE_AT { house, building, street, garden, forest, park, market, store, bridge, meeting }
41+
per_be_at_n: &PER_BE_AT {party}
42+
see_from_n: &SEE_FROM { hill, rooftop, mountain, tower, tree, <<: *BE_IN }
43+
landmark_n: &LANDMARK { hill, mountain, tree, fence, forest, park, garden, street, market, bridge, <<: *BUILDING }
44+
on_ground_n: &ON_GROUND { hill, mountain, forest, park, garden }
45+
46+
see_through_n: &SEE_THR { tunnel, window, door, fence }
47+
body_of_water_n: &WATER { lake, sea, water, river, ocean, pool }
48+
49+
throwable_n: &THROW { ball, key, pencil, stone, toy, watch, pen, dice, book, glasses }
50+
into_n: &INTO { box, cup, bowl, bucket, container, pot, bin, trash can, glass, barrel }
51+
fridge_n: &FRIDGE { fridge, cabinet, locker, wardrobe, cupboard, closet }
52+
53+
size_S_n: &SIZE_S { <<: *THROW, <<: *INTO, <<: *ANIMAL, <<: *FOOD }
54+
size_M_n: &SIZE_M { <<: *PER, <<: *FRIDGE }
55+
size_L_n: &SIZE_L { <<: *VEHICLE }
56+
57+
physical_object_n: &PHYOBJ { <<: *PER_ANM, <<: *BE_IN, <<: *BE_ON, <<: *SEE_FROM, <<: *INTO, <<: *THROW }
58+
has_front_back_n: { <<: *PER_ANM, <<: *VEHICLE, <<: *FRIDGE, building, house, school, hospital, store, station, room, window, door }
59+
60+
# >= person & animal, see 98g
61+
measure_pn: &MEASURE { 6 feet, 6 meters, 10 meters, 10 feet }
62+
floor_n: &FLOOR { first floor, second floor, ground floor, basement }
63+
64+
# better to model via string constraint
65+
apos_s_n: *PHYOBJ
66+
67+
# modifier-head combinations
68+
#little_a: &LITTLE { <<: *PER_ANM, <<: *SEE_FROM, <<: *SEE_THR, <<: *CROSS }
69+
#big_a: { <<: *LITTLE }
70+
71+
color_a: &COLOR { red, green, blue, yellow, black, white, pink, purple, violet }
72+
73+
# converted into sig['old_mod'] = {<<*PER_ANM}
74+
MOD_2:
75+
# - [ {old, young, lonely, fat, thin, blind}, <<: *PER_ANM ]
76+
# - [ {deaf, skinny, clever, stupid, dark-haired, pink-haired, blond, rich, poor, brave, scared, angry, smiling, laughing, crying, sad, unhappy, happy, funny}, <<: *PER ]
77+
- [ {narrow, broad, long, short}, <<: *CROSS ]
78+
# - [ {new, old, renovated, small, ugly, beautiful, large, empty, abandoned, unused, huge}, <<: *BUILDING ]
79+
# - [ {new, old, small, huge, large, beautiful, empty}, <<: *RUN_IN ]
80+
- [ {national, public}, {park, forest} ]
81+
- [ <<: *COLOR, {car, box, cup, bowl, bucket, toy, pencil, ball, house, building} ]
82+
83+
84+
# n-ary predicates where the last digit shows the arity
85+
walk_across_v2:
86+
- [ *PER_ANM, *CROSS ]
87+
walk_into_v2: &WALK_INTO_V2
88+
- [ *PER_ANM, *ENTER_IN ]
89+
walk_out_of_v2: *WALK_INTO_V2
90+
enter_v2: *WALK_INTO_V2
91+
outside_p2: *WALK_INTO_V2
92+
leave_v2: *WALK_INTO_V2
93+
walk_to_v2: &WALK_TO_V2
94+
- [ *PER_ANM, {<<: *PER_ANM, <<: *BE_IN, <<: *BE_ON, <<: *FRIDGE, <<: *LANDMARK} ]
95+
walk_v1: &WALK_V1
96+
- [ *PER_ANM ]
97+
walk_away_from_v2: *WALK_TO_V2
98+
walk_towards_v2: *WALK_TO_V2
99+
100+
drive_around_by_through_v1:
101+
- [ { tunnel, city, park, garden, forest } ]
102+
- [ *CIT_STA ]
103+
104+
meet_v2:
105+
- [ *PER_ANM, *PER_ANM ]
106+
107+
run_in_v2:
108+
- [ *PER_ANM, *ENTER_IN ]
109+
- [ *PER_ANM, *RUN_IN ]
110+
want_v1:
111+
- [ *PER ]
112+
stand_v1:
113+
- [ *PER_ANM ]
114+
- [ { house, building, tower, tree } ]
115+
- [ *VEHICLE ]
116+
be_with_v2:
117+
- [ *PER_ANM, *PER_ANM ]
118+
# - [ *PER_ANM, *SIZE_S ]
119+
- [ *SIZE_S, *PER_ANM ]
120+
121+
be_at_v2:
122+
- [ *PER_ANM, *BE_AT ]
123+
124+
hug_v2:
125+
- [ *PER, *PER_ANM ]
126+
mention_v2:
127+
- [ *PER, *PHYOBJ ]
128+
criticize_v2:
129+
- [ *PER, *PER ]
130+
see_v2:
131+
- [ *PER_ANM, *PHYOBJ ]
132+
see_from_v3:
133+
- [ *PER_ANM, *PHYOBJ, *SEE_FROM ]
134+
see_through_v3:
135+
- [ *PER_ANM, *PHYOBJ, *SEE_THR ]
136+
# see_in3:
137+
# - prod1: [ <<: *PER_ANM, <<: *PHYOBJ, <<: *BE_IN ]
138+
invisible_to_v2:
139+
- [ *PHYOBJ, *PER_ANM ]
140+
in_p2: &BE_IN_P2
141+
- [ *PER_ANM, *BE_IN ]
142+
- [ { car, church, house, hut, tree, tower, building }, { forest, park } ]
143+
- [ { garden }, { church, park } ]
144+
- [ { church }, { garden, forest } ]
145+
- [ *THROW, {<<: *INTO, <<: *FRIDGE } ] # big can be thrown into small
146+
- [ *INTO, *FRIDGE ]
147+
inside_p2: *BE_IN_P2
148+
out_of_p2: *BE_IN_P2
149+
on_top_of_p2: &ON_TOP_OF
150+
- [ *PER_ANM, {<<: *BE_ON, <<: *BUILDING, car, bus, truck, tree, bridge} ]
151+
- [ {car}, *PER ]
152+
- [ *VEHICLE, {bridge} ]
153+
- [ *THROW, { <<: *INTO, <<: *FRIDGE } ]
154+
- [ *INTO, {<<: *FRIDGE, <<: *THROW} ]
155+
- [ *ANIMAL, *ANIMAL ]
156+
on_p2: &ON
157+
- [ *PER_ANM, {<<: *BE_ON, car, bus, truck} ]
158+
- [ *VEHICLE, {bridge} ]
159+
- [ *THROW, { <<: *INTO, <<: *FRIDGE } ]
160+
- [ *INTO, {<<: *FRIDGE, <<: *THROW} ]
161+
under_p2: &UNDER_P2
162+
- [ *SIZE_S, {<<: *INTO, <<: *FRIDGE, bridge, <<: *VEHICLE } ]
163+
- [ *PER, {car, bus, truck, tree, bridge} ]
164+
- [ *SIZE_L, { bridge } ]
165+
- [ *INTO, *THROW ]
166+
# below_p2: *UNDER_P2
167+
at_p2:
168+
- [ *PER_ANM, *BE_AT ]
169+
- [ *PER, *PER_BE_AT ]
170+
absent_in_v2: *BE_IN_P2
171+
abandon_v2:
172+
- [ *PER, *PER_ANM ]
173+
- [ *PER, *THROW ]
174+
live_near_v2:
175+
- [ *PER, { <<: *LANDMARK, <<: *WATER } ]
176+
take_v2: &TAKE_V2
177+
- [ *PER, *PER_ANM ]
178+
- [ *PER, *SIZE_S ]
179+
put_v2: *TAKE_V2
180+
bring_from_v3: #3rd arg should be smth you entre/are inside
181+
- [ *PER, *SIZE_S, {<<: *ENTER_IN, <<: *RUN_IN, <<: *BE_AT} ]
182+
leave_through_v3:
183+
- [ *PER_ANM, *BUILDING, {door, window} ]
184+
opposite_side_of_p1:
185+
- [ *SEE_THR ]
186+
187+
# takes into account that Ground shoudln't be too small comapred to the Figure
188+
# e.g., "behind/front_of(hospital,locker)" is blocked
189+
behind_of_p2: &BEHIND_OF_P2
190+
- [ {<<: *SIZE_S, <<: *SIZE_M, <<: *SIZE_L}, {window, door} ]
191+
- [ {<<: *SIZE_S, <<: *SIZE_M, <<: *SIZE_L, <<: *PER_ANM},
192+
{<<: *SIZE_S, <<: *SIZE_M, <<: *SIZE_L, <<: *PER_ANM, <<: *BUILDING} ]
193+
- [ *BUILDING, {<<: *SIZE_M, <<: *SIZE_L, <<: *BUILDING} ]
194+
front_of_p2: *BEHIND_OF_P2
195+
196+
between_of_p2: &BETWEEN_OF_P2
197+
# - [ {<<: *PER_ANM}, {<<: *PER_ANM} ]
198+
# - [ {<<: *SIZE_S}, {<<: *SIZE_S} ]
199+
# - [ {<<: *SIZE_M}, {<<: *SIZE_M} ]
200+
- [ {tree, fence, trash can, <<: *BUILDING, <<: *PER_ANM, <<: *VEHICLE},
201+
{tree, fence, trash can, <<: *BUILDING, <<: *PER_ANM, <<: *VEHICLE} ]
202+
203+
near_p2:
204+
- *BE_IN_P2 # preds_from_yaml script unpacks the alias and unifies with other items
205+
- *BETWEEN_OF_P2
206+
207+
part_of_p2:
208+
- [ {door, window}, *BUILDING ]
209+
k_above_p2: # k_X extension is automatically included in X too
210+
- [ {first floor, second floor}, {ground floor, basement} ]
211+
- [ {second floor}, {first floor} ]
212+
- [ {ground floor}, {basement} ]
213+
- [ {rooftop}, {door, window} ]
214+
above_p2:
215+
- [ {window}, {door} ]
216+
- [ {tunnel, helicopter}, *WATER ]
217+
- [ {helicopter}, {rooftop, door, window, <<: *BUILDING} ]
218+
- [ { <<: *FOOD, <<: *THROW, <<: *INTO }, { <<: *FOOD, <<: *THROW, <<: *INTO } ]
219+
- [ { <<: *FOOD, <<: *THROW, <<: *FRIDGE }, { <<: *FOOD, <<: *THROW, <<: *FRIDGE } ]
220+
# - [ *PER_ANM, { <<: *VEHICLE, <<: *FRIDGE } ]
221+
# - [ { <<: *VEHICLE, <<: *FRIDGE }, *PER_ANM ]
222+
# reflexive cases are prevented with NP1 != NP2 assumption
223+
far_from_p2: &FAR_FROM_P2
224+
- [ { <<: *VEHICLE, <<: *BE_IN }, { <<: *VEHICLE, <<: *BE_IN } ]
225+
- [ { <<: *SIZE_S, <<: *SIZE_M }, { <<: *SIZE_S, <<: *SIZE_M } ]
226+
- [ { <<: *SIZE_L, <<: *SIZE_M }, { <<: *SIZE_L, <<: *SIZE_M } ]
227+
opposite_p2: *FAR_FROM_P2
228+
throw_into_v3:
229+
- [ *PER, *THROW, *INTO ]
230+
throw_at_v3:
231+
- [ *PER, *THROW, *INTO ]
232+
take_away_from_v3:
233+
- [ *PER, *SIZE_S, *PER ]
234+
- [ *PER, *THROW, *PER_ANM ]
235+
hide_v2:
236+
- [ *PER, *SIZE_S ]
237+
go_into_v2:
238+
- [ *THROW, *INTO ]
239+
fall_out_of_IMP_be_inside_v2:
240+
- [ *PER_ANM, {window, boat, bed, hammock, <<: *VEHICLE} ]
241+
fall_out_of_IMP_be_in_v2:
242+
- [ *PER_ANM, {window, boat, tree, bed, hammock, <<: *VEHICLE} ]
243+
244+
245+
k_city_in_state_p2: # k_X extension is automatically included in X too
246+
- [ {Los Angeles, San Diego, San Jose, San Francisco, Fresno, Sacramento}, {California} ]
247+
- [ {Las Vegas, Henderson, Reno, Sparks, Carson City, Fernley}, {Nevada} ]
248+
- [ {Amsterdam, Utrecht, Tilburg, Rotterdam, Groningen, Nijmegen}, {the Netherlands} ]
249+
- [ {Antwerp, Ghent, Charleroi, Brussels, Bruges, Leuven}, {Belgium} ]
250+
- [ {Berlin, Hamburg, Munich, Cologne, Stuttgart, Frankfurt}, {Germany} ]
251+
- [ {Paris, Marseille, Lyon, Toulouse, Nice, Nantes}, {France} ]

0 commit comments

Comments
 (0)