The application relates to a Chinese
natural language generation
SQL sentence and cross-
database query method, which comprises the following steps: pre-
processing a
natural language sentence, obtaining a
phrase segment, and dividing the
phrase segment into multiple alternative segments; if the alternative segment is surrounded by a symbol, the alternative segment is marked as a value; then, according to a preset dictionary, the synonyms of the remaining alternative segments are obtained; the alternative segments and the synonyms are matched with table annotations, field annotations and
label metadata in a preset
metadata database; according to the table annotations, the field annotations or the
label metadata matched by the alternative segments, the
database name is obtained, and the alternative segments and the synonyms are marked as table names, field names or values; then, a new string is generated; through encoding and decoding of the string, the
SQL is generated according to the
SQL syntax rules in combination with the value. The application can improve the accuracy of the SQL
sentence when the SQL sentence is applied to in-depth query in the corresponding field, and can reduce the situation that the query result does not match the real intention of the user query.