Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NL] Implement query-type fallback #2225

Merged
merged 9 commits into from
Feb 11, 2023
11 changes: 11 additions & 0 deletions server/integration_tests/nlnext_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,14 @@ def test_demo_feb2023(self):
'Which counties in the USA have the highest levels of blood pressure',
'How does this correlate with income',
])

def test_demo_fallback(self):
self.run_sequence(
'demo_fallback',
[
# We have no stats on this, so we should return Palo Alto overview.
'Number of Shakespeare fans in Palo Alto',
# We have no crime at county-level in CA, so we should fall back as:
# RANKING_ACROSS_PLACES -> CONTAINED_IN -> SIMPLE
'counties in California with highest crime',
])
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"config": {
"categories": [
{
"blocks": [
{
"columns": [
{
"tiles": [
{
"type": "PLACE_OVERVIEW"
}
]
}
],
"title": "Palo Alto"
}
]
}
],
"metadata": {
"placeDcid": [
"geoId/0655282"
]
}
},
"context": {},
"debug": {},
"place": {
"dcid": "geoId/0655282",
"name": "Palo Alto",
"place_type": "City"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
{
"clustering_classification": "<None>",
"comparison_classification": "<None>",
"contained_in_classification": "<None>",
"correlation_classification": "<None>",
"counters": {
"failed_populate_main_place": [
"geoId/0655282"
],
"filtered_svs": [],
"num_chart_candidates": 1,
"num_populate_fallbacks": 1,
"processed_fulfillment_types": [
"simple",
"overview"
]
},
"data_spec": [
{
"classifications": [
{
"type": 11
}
],
"places": [
{
"dcid": "geoId/0655282",
"name": "Palo Alto",
"place_type": "City"
}
],
"query": "Number of Shakespeare fans in Palo Alto",
"query_type": 9,
"ranked_charts": [
{
"attr": {
"block_id": 1,
"chart_type": "",
"class": 0,
"description": "",
"include_percapita": false,
"place_type": null,
"ranking_types": [],
"source_topic": "",
"title": ""
},
"chart_type": 4,
"event": null,
"places": [
{
"dcid": "geoId/0655282",
"name": "Palo Alto",
"place_type": "City"
}
],
"svs": []
}
],
"svs": []
}
],
"event_classification": "<None>",
"main_place_dcid": "geoId/0655282",
"main_place_name": "Palo Alto",
"original_query": "Number of Shakespeare fans in Palo Alto",
"overview_classification": "<None>",
"places_detected": [
"palo alto"
],
"query_with_places_removed": "number of shakespeare fans",
"ranking_classification": "<None>",
"status": "",
"sv_matching": {
"CosineScore": [
0.3691325783729553,
0.29036542773246765,
0.2894546687602997,
0.2783313989639282,
0.272920161485672,
0.2691501975059509,
0.2653329074382782,
0.26523518562316895,
0.2610829472541809,
0.2539288103580475
],
"SV": [
"Count_HeavySnowEvent",
"Count_Person_Male",
"Count_CriminalIncidents_IsHateCrime",
"Count_EarthquakeEvent",
"Count_Person_5To9Years",
"Count_CriminalActivities_Robbery",
"Count_HeavyRainEvent",
"Count_Worker_NAICSArtsEntertainmentRecreation",
"Count_DroughtEvent",
"Count_FloodEvent"
],
"SV_to_Sentences": {
"Count_CriminalActivities_Robbery": [
"Number of heists (0.2691501975059509)"
],
"Count_CriminalIncidents_IsHateCrime": [
"Number of hate crimes (0.2894546687602997)",
"Number of Hate Crime Incidents (0.25507885217666626)",
"Number of hate crime incidents (0.25507885217666626)"
],
"Count_DroughtEvent": [
"Number of Droughts (0.2610829472541809)",
"Number of droughts (0.2610829174518585)"
],
"Count_EarthquakeEvent": [
"Number of tremors (0.2783313989639282)",
"Number of temblors (0.27476659417152405)",
"Number of quakes (0.27175652980804443)",
"Number of Earthquakes (0.25374898314476013)"
],
"Count_FloodEvent": [
"Number of Floods (0.2539288103580475)",
"Number of floods (0.2539288103580475)"
],
"Count_HeavyRainEvent": [
"Number of heavy rains (0.2653329074382782)",
"Number of Heavy Rains (0.2653329074382782)"
],
"Count_HeavySnowEvent": [
"Number of blizzards (0.3691325783729553)"
],
"Count_Person_5To9Years": [
"Number of 5 to 9 year old people (0.272920161485672)"
],
"Count_Person_Male": [
"Number of Males (0.29036542773246765)"
],
"Count_Worker_NAICSArtsEntertainmentRecreation": [
"Employment numbers in entertainment and recreation (0.26523518562316895)",
"number of arts, entertainment, and recreation workers (0.25554004311561584)",
"Population of Person: Arts, Entertainment, And Recreation (NAICS/71) (0.25426241755485535)"
]
}
},
"svs_to_sentences": {
"Count_CriminalActivities_Robbery": [
"Number of heists (0.2691501975059509)"
],
"Count_CriminalIncidents_IsHateCrime": [
"Number of hate crimes (0.2894546687602997)",
"Number of Hate Crime Incidents (0.25507885217666626)",
"Number of hate crime incidents (0.25507885217666626)"
],
"Count_DroughtEvent": [
"Number of Droughts (0.2610829472541809)",
"Number of droughts (0.2610829174518585)"
],
"Count_EarthquakeEvent": [
"Number of tremors (0.2783313989639282)",
"Number of temblors (0.27476659417152405)",
"Number of quakes (0.27175652980804443)",
"Number of Earthquakes (0.25374898314476013)"
],
"Count_FloodEvent": [
"Number of Floods (0.2539288103580475)",
"Number of floods (0.2539288103580475)"
],
"Count_HeavyRainEvent": [
"Number of heavy rains (0.2653329074382782)",
"Number of Heavy Rains (0.2653329074382782)"
],
"Count_HeavySnowEvent": [
"Number of blizzards (0.3691325783729553)"
],
"Count_Person_5To9Years": [
"Number of 5 to 9 year old people (0.272920161485672)"
],
"Count_Person_Male": [
"Number of Males (0.29036542773246765)"
],
"Count_Worker_NAICSArtsEntertainmentRecreation": [
"Employment numbers in entertainment and recreation (0.26523518562316895)",
"number of arts, entertainment, and recreation workers (0.25554004311561584)",
"Population of Person: Arts, Entertainment, And Recreation (NAICS/71) (0.25426241755485535)"
]
},
"temporal_classification": "<None>",
"time_delta_classification": "<None>"
}
Loading