@@ -174,6 +174,49 @@ $ logica primes.l run Prime
174174+-------+
175175```
176176
177+ ### Cities with largest beer variety
178+
179+ Let's use beer variety dataset from [ plotly] ( https://github.com/plotly/datasets/blob/master/beers.csv ) .
180+
181+ Let us find top 5 states with largest variety of beers. In each state we will pick city with the largest
182+ variety in the state.
183+
184+ Program ` beer.l ` :
185+
186+ ```
187+ @Engine("duckdb");
188+
189+ @Ground(Beer);
190+ Beer(..r) :-
191+ `('https://github.com/plotly/datasets/blob/master/beers.csv?raw=true')`(..r);
192+
193+ BeersInState(state) += 1 :- Beer(state:);
194+ BeersInCity(state, city) += 1 :- Beer(state:, city:);
195+
196+ ArgMax5(x) = ArgMaxK(x, 5);
197+ BestCityForBeer(state:, city:,
198+ city_beers: BeersInCity(state, city),
199+ state_beers: BeersInState(state)) :-
200+ state in ArgMax5{s -> BeersInState(s)},
201+ city = ArgMax{c -> BeersInCity(state, c)};
202+ ```
203+
204+ Running ` beer.l ` :
205+
206+ ```
207+ # logica beer.l run BestCityForBeer
208+ +-------+--------------+------------+-------------+
209+ | state | city | city_beers | state_beers |
210+ +-------+--------------+------------+-------------+
211+ | IN | Indianapolis | 43 | 139 |
212+ | CO | Boulder | 41 | 265 |
213+ | CA | San Diego | 42 | 183 |
214+ | TX | Austin | 25 | 130 |
215+ | MI | Grand Rapids | 66 | 162 |
216+ +-------+--------------+------------+-------------+
217+ ```
218+
219+ <!--
177220### News mentions
178221
179222Who was mentioned in the news in 2020 the most?
@@ -211,7 +254,7 @@ $ logica mentions.l run Mentions
211254
212255Note that cities of Los Angeles and Las Vegas are mentioned in this table due to known
213256missclasification issue in the GDELT data analysis.
214-
257+ -->
215258## Feedback
216259
217260Feel free to create [ github issues] ( https://github.com/EvgSkv/logica/issues )
0 commit comments