| With the deepening of informatization in all walks of life,database technology is widely used to store and manage the growing business data.At present,the relational database of the public security department has accumulated a large amount of population and public security data.The database not only has a large amount of data in a single table,but also has a large number of tables,and the relationship between tables is also very complex.In addition,public security personnel have a variety of flexible query needs in dealing with daily business.For nonprofessional technicians,it is extremely difficult to use structured query language to query data from traditional database systems without being familiar with database structure and SQL statement usage.Therefore,it is of great practical value to provide a special database natural language query interface for public security users.The purpose of natural language query interface is to automatically convert queries expressed in natural language into SQL statements,so that users can query the required information in the database through the interface.However,the existing natural language query interface technologies lack domain knowledge understanding,are difficult to generate complex queries involving multiple tables,and are difficult to deal with semantic ambiguity,synonymous ellipsis and other grammatical phenomena in natural language.In order to solve the above problems,this paper proposes a natural language query interface based on ontology.Based on ontology learning technology,this paper semi automatically converts the structured data in the public security population database into domain ontology,and then combines the domain ontology to syntactically analyze the natural language query statements to generate an intermediate language,and proposes an association path algorithm based on BFS to solve the problem of multi table connection when generating complex SQL statements.The main contributions and innovations of this paper are as follows:(1)Based on ontology learning technology,the structured data in the public security population database is semi automatically transformed into domain ontology,and the domain ontology is expanded in combination with synonym forest to deal with semantic similarity problems.The generated domain ontology and knowledge base are well integrated with domain knowledge to assist transformation.(2)Combined with the syntactic analysis of domain ontology,the intermediate language is generated.Firstly,Chinese word segmentation is performed on natural language query statements through Jieba word segmentation tool,and the corresponding sentence pattern array and sentence object array are generated by combining domain ontology and knowledge base.Then the target phrase and condition phrase are extracted by query target extraction algorithm and query condition extraction algorithm.Finally,the query target and query condition are extracted by rule matching and syntax analysis,and the intermediate language in the form of array is generated.(3)An association path algorithm based on BFS is proposed to solve the multi table join problem in complex queries.The efficiency of path finding is optimized based on Steiner tree combination optimization scheme,and then a complete SQL statement is generated.(4)A natural language query system for public security population is designed and implemented.The system uses Vue.js and Flask framework development,with user management,database management,dictionary management,data preprocessing,natural language query and display,speech recognition,full-text retrieval and other functional modules.The experimental results on the Shanghai public security population data set show that the accuracy of the ontology based natural language query interface technology in single table query,multi table query and complex query sentences is 83.3%,68.8% and 51.9% respectively,which can better meet the daily query needs of the public security population department police on the population database. |