我正在处理一个需要使用AWS Texextract的Spring Boot 项目。我想使用查询功能。但我不知道在哪里包含查询。
我查阅了aws文档,并使用了他们的java sdk v2示例代码。但我不知道在哪里添加查询?例如“客户的名字是什么”。我应该在哪里添加查询文档。
下面是我使用的代码
public static void analyzeDoc(TextractClient textractClient, String sourceDoc) {
try {
InputStream sourceStream = new FileInputStream(new File(sourceDoc));
SdkBytes sourceBytes = SdkBytes.fromInputStream(sourceStream);
// Get the input Document object as bytes
Document myDoc = Document.builder()
.bytes(sourceBytes)
.build();
List<FeatureType> featureTypes = new ArrayList<>();
featureTypes.add(FeatureType.QUERIES);
AnalyzeDocumentRequest analyzeDocumentRequest = AnalyzeDocumentRequest.builder()
.featureTypes(featureTypes)
.document(myDoc)
.build();
AnalyzeDocumentResponse analyzeDocument = textractClient.analyzeDocument(analyzeDocumentRequest);
List<Block> docInfo = analyzeDocument.blocks();
Iterator<Block> blockIterator = docInfo.iterator();
while(blockIterator.hasNext()) {
Block block = blockIterator.next();
System.out.println("The block type is " + block.blockType().toString());
}
} catch (TextractException | FileNotFoundException e) {
System.err.println(e.getMessage());
System.exit(1);
}
}
字符串
1条答案
按热度按时间3htmauhk1#
在花了很多时间之后,我终于找到了一种方法来包含查询。希望这能帮助像我一样被卡住的人。
字符串