gpt4 book ai didi

java - 将自然语言问题转换为 SQL 查询

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:46:42 24 4
gpt4 key购买 nike

<分区>

我想使用 opennlp Java 库将自然语言问题转换为 SQL 查询,即

Who won women figure skating in Sochi?

应转换为

select name from winners where event='skating_woman'

有人知道哪些类有用以及如何实现吗?

同时粘贴我试过的代码。
我已将问题转换为陈述,然后再转换为标记。

/////////1st part

String paragraph = "Did Matt win the men slalom?";
InputStream is1 = new FileInputStream("bins/en-sent.bin");
SentenceModel model1 = new SentenceModel(is1);
SentenceDetectorME sdetector = new SentenceDetectorME(model1);
String sentences[] = sdetector.sentDetect(paragraph);
System.out.println(sentences[0]);
is1.close();

////////2nd part
InputStream is2 = new FileInputStream("bins/en-token.bin");
TokenizerModel model2 = new TokenizerModel(is2);
Tokenizer tokenizer = new TokenizerME(model2);
String tokens[] = tokenizer.tokenize(sentences[0]);
for (String a : tokens)
System.out.println(a);
is2.close();

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com