2017-04-13 334 views
9

免責聲明:以前可能會被問到,但找不到可以適合賬單的東西。我最接近的是Automatic SQL query formulation from natural language input自然語言轉換爲sql(來自示例),從示例學習sql

我解決問題的方式稍有不同。

我有一個非常大的自然語言語句和它涉及到的(sql)查詢字典。所有這些都在我的「域名」中。 例如,下面的(虛擬)語句可以作爲一個例子:

("How many managers on the first floor?") -> 
     SELECT count(*) from tbl.managers where desk_floor = 1; 

("How many people in today?", 
"What is the attendance today?", 
"How many people walked in the door today") -> 
     SELECT count(*) from tbl.checkins where date={today}; 

("When is the next bank holiday?" 
    "When will the office be closed for the next bank holiday") -> 
     SELECT top 1 holiday_on from tbl.holidays where holiday_on > {today} order by 1; 

等。現在,我可以坐下來喝一杯非常大的咖啡,並開始設置語法,查找和域方法(如quepy中所做的),以允許變化或嘗試回答不屬於訓練集的查詢,但可以從部分現有的數據集。所以鑑於上面的數據集可以問,有些東西是這樣的:

"How many managers on the first floor are in today?" 

我們不能訓練一個「解釋器」來爲我們做這個。有沒有任何例子或出版物暗示這一點?

ps:如果它幫助我使用python的任何人,但我不是特別尋找代碼。

回答

2