IP Library Granted Patent US 12,259,879
Granted Patent B2
US 12,259,879 · App. 17/883,955 · Granted Mar 25, 2025

Mapping natural language to queries using a query grammar

Inventors: Nikhil Yadav (Sunnyvale, CA); Ravi Tandon (San Jose, CA)
Assignee: Thoughtspot, Inc.
G06F16/2428G06F16/245G06F16/248G06F16/9024
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,259,879
App. No.
17/883,955
Granted
Mar 25, 2025
Kind
B2
Abstract

Systems and methods for mapping natural language to queries using a query grammar are described. For example, methods may include generating, based on a string, a set of tokens of a database syntax; generating a query graph for the set of tokens from a finite state machine representing a query grammar, wherein nodes of the finite state machine represent token types, directed edges of the finite state machine represent valid transitions between token types in the query grammar, vertices of the query graph correspond to respective tokens of the set of tokens, and directed edges of the query graph represent a transition between two tokens in a sequencing of the tokens; determining, based on a tour of the query graph, a sequence of the tokens in the set of tokens, forming a database query; and invoking a search of a database using a query based on the database query to obtain search results.

Claims (60)

1. A system for providing a search interface for databases, comprising:

a network interface,

a processor, and

a memory, wherein the memory stores instructions executable by the processor to:

generate, based on a string, a set of tokens of a database syntax, wherein the tokens are each matched to a respective fragment of the string;

generate a query graph for the set of tokens from a finite state machine representing a query grammar, wherein nodes of the finite state machine represent token types, directed edges of the finite state machine represent valid transitions between token types in the query grammar, vertices of the query graph correspond to respective tokens of the set of tokens, and directed edges of the query graph represent a transition between two tokens in a sequencing of the tokens;

remove one or more directed edges from the query graph to form an acyclic query graph;

determine, based on a tour of the acyclic query graph, a sequence of the tokens in the set of tokens to form a database query; and

invoke a search of the database using a query based on the database query to obtain search results.

2. The system of claim 1 , wherein the memory stores instructions executable by the processor to:

determine a weight for a directed edge from a source vertex of the query graph corresponding to a first token of the set of tokens to a destination vertex of the query graph corresponding to a second token of the set of tokens, wherein the weight is determined based on a grammar weight of a directed edge from a node of the finite state machine representing a token type of the first token to a node of the finite state machine representing a token type of the second token.

3. The system of claim 1 , wherein the memory stores instructions executable by the processor to:

determine a weight for a directed edge from a source vertex of the query graph corresponding to a first token of the set of tokens to a destination vertex of the query graph corresponding to a second token of the set of tokens, wherein the weight is determined based on grammar weights of directed edges along a path from a node of the finite state machine representing a token type of the first token to a node of the finite state machine representing a token type of the second token.

4. The system of claim 1 , wherein the memory stores instructions executable by the processor to:

apply an Eades algorithm to the query graph.

5. The system of claim 1 , wherein the memory stores instructions executable by the processor to:

identify a valid start token and a valid end token from the set of tokens based on the query grammar; and

determine a tour of the vertices in the query graph that starts at a vertex corresponding to the valid start token and ends at a vertex corresponding to the valid end token.

6. The system of claim 1 , wherein the memory stores instructions executable by the processor to:

determine tours of the vertices in the query graph; and

select one of the tours that has a largest sum of weights for directed edges of the tour.

7. The system of claim 1 , wherein the memory stores instructions executable by the processor to:

determine that the string and the set of tokens matches a pattern; and

responsive to the match, set a weight of a directed edge of the query graph based on a pattern score associated with the pattern.

8. A method comprising:

receiving a string entered via a user interface;

generating, based on the string, a set of tokens of a database syntax, wherein the tokens are each matched to a respective fragment of the string;

generating a query graph for the set of tokens from a finite state machine representing a query grammar, wherein nodes of the finite state machine represent token types, directed edges of the finite state machine represent valid transitions between token types in the query grammar, vertices of the query graph correspond to respective tokens of the set of tokens, and directed edges of the query graph represent a transition between two tokens in a sequencing of the tokens;

determining, based on a tour of the query graph, a sequence of the tokens in the set of tokens to form a database query, wherein determining the sequence of the tokens comprises:

identifying a valid start token and a valid end token from the set of tokens based on the query grammar; and

determining the tour of the vertices in the query graph that starts at a vertex corresponding to the valid start token and ends at a vertex corresponding to the valid end token;

invoking a search of a database using a query based on the database query to obtain search results; and

presenting data based on the search results in the user interface.

9. The method of claim 8 , wherein generating the query graph comprises:

determining a weight for a directed edge from a source vertex of the query graph corresponding to a first token of the set of tokens to a destination vertex of the query graph corresponding to a second token of the set of tokens, wherein the weight is determined based on a grammar weight of a directed edge from a node of the finite state machine representing a token type of the first token to a node of the finite state machine representing a token type of the second token.

10. The method of claim 8 , wherein generating the query graph comprises:

determining a weight for a directed edge from a source vertex of the query graph corresponding to a first token of the set of tokens to a destination vertex of the query graph corresponding to a second token of the set of tokens, wherein the weight is determined based on grammar weights of directed edges along a path from a node of the finite state machine representing a token type of the first token to a node of the finite state machine representing a token type of the second token.

11. The method of claim 8 , wherein determining, based on the query graph, the sequence of the tokens in the set of tokens comprises:

removing one or more directed edges from the query graph to form an acyclic query graph; and

determining, based on the acyclic query graph, the sequence of the tokens in the set of tokens.

12. The method of claim 11 , wherein removing one or more directed edges from the query graph to form the acyclic query graph comprises:

applying an Eades algorithm to the query graph.

13. The method of claim 8 , wherein determining, based on the query graph, the sequence of the tokens in the set of tokens comprises:

determining tours of the vertices in the query graph; and

selecting one of the tours that has a largest sum of weights for directed edges of the tour.

14. The method of claim 8 , comprising:

determining that the string and the set of tokens matches a pattern; and

responsive to the match, setting a weight of a directed edge of the query graph based on a pattern score associated with the pattern.

15. A non-transitory computer-readable storage medium that includes instructions that, when executed by a processor, facilitate performance of operations comprising:

generating, based on a string, a set of tokens of a database syntax, wherein the tokens are each matched to a respective fragment of the string;

generating a query graph for the set of tokens from a finite state machine representing a query grammar, wherein nodes of the finite state machine represent token types, directed edges of the finite state machine represent valid transitions between token types in the query grammar, vertices of the query graph correspond to respective tokens of the set of tokens, and directed edges of the query graph represent a transition between two tokens in a sequencing of the tokens;

determining, based on a tour of the query graph, a sequence of the tokens in the set of tokens to form a database query, wherein determining the sequence of the tokens comprises:

removing one or more directed edges from the query graph to form an acyclic query graph; and

determining, based on the acyclic query graph, the sequence of the tokens; and

invoking a search of a database using a query based on the database query to obtain search results.

16. The non-transitory computer-readable storage medium of claim 15 , wherein generating the query graph comprises:

determining a weight for a directed edge from a source vertex of the query graph corresponding to a first token of the set of tokens to a destination vertex of the query graph corresponding to a second token of the set of tokens, wherein the weight is determined based on a grammar weight of a directed edge from a node of the finite state machine representing a token type of the first token to a node of the finite state machine representing a token type of the second token.

17. The non-transitory computer-readable storage medium of claim 15 , wherein determining, based on the query graph, the sequence of the tokens in the set of tokens comprises:

identifying a valid start token and a valid end token from the set of tokens based on the query grammar; and

determining a tour of the vertices in the query graph that starts at a vertex corresponding to the valid start token and ends at a vertex corresponding to the valid end token.

Assignments (2)
SECURITY INTEREST Recorded Mar 7, 2025
From: THOUGHTSPOT, INC.; THOUGHTSPOT, LLC
To: TRIPLEPOINT CAPITAL LLC
Reel/Frame 070442/0499 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 9, 2022
From: YADAV, NIKHIL; TANDON, RAVI
To: THOUGHTSPOT, INC.
Reel/Frame 060757/0993 →
Continuity (2)
Continuation 16512674 · Jul 16, 2019
Related Publication 20220382752A1 · Dec 1, 2022
References Cited (70)
US 5987409A · Tran et al. · 1999 [cited by applicant]
US 8275803B2 · Brown et al. · 2012 [cited by applicant]
US 8370821B2 · Haber et al. · 2013 [cited by applicant]
US 8577913B1 · Hansson et al. · 2013 [cited by applicant]
US 8738617B2 · Brown et al. · 2014 [cited by applicant]
US 9116948B2 · Cheng · 2015 [cited by examiner]
US 9275132B2 · Roberts et al. · 2016 [cited by applicant]
US 9405794B2 · Prakash et al. · 2016 [cited by applicant]
US 10394802B1 · Porath et al. · 2019 [cited by applicant]
US 11386158B1 · Bourbie et al. · 2022 [cited by applicant]
US 20040267730A1 · Dumais et al. · 2004 [cited by applicant]
US 20050027717A1 · Koudas et al. · 2005 [cited by applicant]
US 20050289124A1 · Kaiser et al. · 2005 [cited by applicant]
US 20070192300A1 · Reuther et al. · 2007 [cited by applicant]
US 20070192306A1 · Papakonstantinou et al. · 2007 [cited by applicant]
US 20070219974A1 · Chickering et al. · 2007 [cited by applicant]
US 20080109422A1 · Dedhia · 2008 [cited by applicant]
US 20090019019A1 · Jones et al. · 2009 [cited by applicant]
US 20090019022A1 · Schallert et al. · 2009 [cited by applicant]
US 20110113048A1 · Njemanze · 2011 [cited by applicant]
US 20120066217A1 · Eder · 2012 [cited by applicant]
US 20120078890A1 · Fan et al. · 2012 [cited by applicant]
US 20120079464A1 · De Smet et al. · 2012 [cited by applicant]
US 20120330990A1 · Chen et al. · 2012 [cited by applicant]
US 20130077033A1 · Li et al. · 2013 [cited by applicant]
US 20130339370A1 · Holstege et al. · 2013 [cited by applicant]
US 20140201241A1 · Wood et al. · 2014 [cited by applicant]
US 20140337371A1 · Li · 2014 [cited by applicant]
US 20170176613A1 · Burnett et al. · 2017 [cited by applicant]
US 20170193095A1 · Ben-Tzur et al. · 2017 [cited by applicant]
US 20170242913A1 · Tijssen et al. · 2017 [cited by applicant]
US 20170270159A1 · Wang et al. · 2017 [cited by applicant]
US 20170322983A1 · Anderson · 2017 [cited by applicant]
US 20170364593A1 · Busey et al. · 2017 [cited by applicant]
US 20180004751A1 · Vikhe et al. · 2018 [cited by applicant]
US 20180032930A1 · Kolb · 2018 [cited by examiner]
US 20180039693A1 · Singh et al. · 2018 [cited by applicant]
US 20180367557A1 · Brown et al. · 2018 [cited by applicant]
US 20190163745A1 · Beller et al. · 2019 [cited by applicant]
US 20190171646A1 · Chu-Carroll et al. · 2019 [cited by applicant]
US 20190213601A1 · Hackman et al. · 2019 [cited by applicant]
US 20210406260A1 · Sharifi et al. · 2021 [cited by applicant]
US 20220121656A1 · Zheng et al. · 2022 [cited by applicant]
EP 268367A2 · 1988 [cited by applicant]
EP 1587011A1 · 2005 [cited by applicant]
EP 2202658A2 · 2010 [cited by applicant]
EP 2207106A2 · 2010 [cited by applicant]
WO 0141002A1 · 2001 [cited by applicant]
WO 2015009353A1 · 2015 [cited by applicant]
Eades, Peter, et al., “A Fast & Effective Heuristic for the Feedback Arc Set Problem,” Information Processing Letters, vol. 47, Issue 6, Oct. 18, 1993, pp. 319-323. [cited by applicant]
Wikipedia, “Dijkstra's algorithm”, Date Unknown, downloaded Jul. 16, 2019, https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm (11 pp). [cited by applicant]
Sayyadian et al., “Efficient Keyword Search Across Heterogeneous Relational Databases”, 2007, IEEE, 346-355 (10 pp). [cited by applicant]
Wu et al: “Towards Keyword-Driven Analytical Processing”, Proceedings of the 2007 ACM Sigmod International Conference on Management of Data, Sigmo '07, Jun. 12, 2007, (12 pp). [cited by applicant]
Anonymous: “File System Permission—Wikipedia, The Free Encyclopedia.” Jun. 11, 2013 (Jun. 11, 2013); URL: http://en.wikipedia.org/w/index/php?title.sub.-File.sub.-system.sub.-p- ermissions&oldid=559455322 [retrieved… [cited by applicant]
Shi et al.: “50x Faster: Speeding Up An SQL-Based Legacy System With Few Changes”, Oct. 4, 2011 Retrieved from Internet: URL: http://www.user.tu-berline.de/komm/CD/paper/040221.pdf [retrieved on Jun. 11, 2014]. (12 pp). [cited by applicant]
Li et al: “Efficient Type-Ahead Search on Relational Data: a Tastier Approach”, Sigmod-Pods '09: Compilation Proceedings of the International Conference on Management Data & 28th Symposium on Principles of Database … [cited by applicant]
Blunschi et al: “SODA: Generating SQL for Business Users”, Proceedings of the VLDB Endowment, vol. 5, No. 10, Aug. 27, 2012 pp. 932-935 (12 pp). [cited by applicant]
Baid et al: “Toward Scalable Keyword Search over Relational Data”, Proceedings of the VLDS Endowment, vol. 3, No. 1-2, Sep. 1, 2010, pp. 140-149 (10 pp). [cited by applicant]
Jajodia et al., “Flexible Support for Multiple Access Control Policies”, ACM Transactions on Database Systems, ACM New York, NY, USA, vol. 26, No. 2, Jun. 1, 2001, pp. 217-228 (48 pp). [cited by applicant]
Anonymous, “Natural Language Processing”, Wikipedia, Downloaded Jan. 30, 2019, https://en.wikipedia.org/wiki/Natural_language_processing, (8 pp). [cited by applicant]
Seif, G., “An Easy Introduction to Natural Language Processing—Using Computers to Understand Human Language”. Oct. 1, 2018 (Downloaded Jan. 30, 2019), https://towardsdatascience.com/an-easy-introduction-to-natural-langu… [cited by applicant]
Extended European Search Report received in co-pending Application No. EP 19160657.3 dated Apr. 4, 2019 (11 pp). [cited by applicant]
International Search Report and Written Opinion for PCT/US14/39230; Date of mailing Nov. 24, 2014 (16 pp). [cited by applicant]
Avrach, A., thoughtspot.com, “What the Bleep is a Chasm Trap?”, https://www.thoughtspot.com/fact-and-dimension/what-bleep-chasm-trap 9/, Date Unknown, Downloaded Apr. 2, 2019 (9 pp). [cited by applicant]
Sisense, “Chasm and Fan Traps”, https://documentation.sisense.com/latest/managing-data/working-with-data/chasm-fan-traps.htm, Date Unknown, Downloaded Apr. 2, 2019 (8 pp). [cited by applicant]
Thoughtspot, “Chasm Traps”, https://docs.thoughtspot.com/4.4/admin/loading/chasm-trap.html, Version 4.4 Guides, Date Unknown, Downloaded Apr. 2, 2019 (4 pp). [cited by applicant]
Morton, K., et al., “Dynamic Workload Driven Data Integration in Tableau”, Proceedings of the 2012 International Conference on Management of Data, SIGMOD '12, Jan. 1, 2012, p. 807 (9 pp). [cited by applicant]
Extended European Search Report dated Jul. 26, 2019, issued in co-pending EP Application No. 19166422.6 (11 pp). [cited by applicant]
Wikipedia, “Consistent hashing”, https://en.wikipedia.org/wiki/Consistent_hashing, Date Unknown, Downloaded Aug. 15, 2019, (5 pp). [cited by applicant]
Sonewar, D. K. et al., “Algorithm for Finding Shortest Path in All Tours of a TSP Using Pheromone Genetic Factor”, Jul. 2017, IJIRSET, vol. 6, Issue 7, http://www.ijirset.com/upload/2017/july/73_dinesh%20sonewar%20_ 1_.… [cited by applicant]