!45190 修复节点复用时AI识别结果显示异常的问题

Merge pull request !45190 from 范盼/AI_Cache_Reusable
This commit is contained in:
openharmony_ci 2024-10-09 02:50:49 +00:00 committed by Gitee
commit 9148cb8f4e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -167,7 +167,7 @@ void DataDetectorAdapter::SetTextDetectTypes(const std::string& types)
bool DataDetectorAdapter::ParseOriText(const std::unique_ptr<JsonValue>& entityJson, std::string& text)
{
TAG_LOGI(AceLogTag::ACE_TEXT, "Parse origine text entry");
TAG_LOGI(AceLogTag::ACE_TEXT, "Parse origin text entry");
auto runtimeContext = Platform::AceContainer::GetRuntimeContext(Container::CurrentId());
CHECK_NULL_RETURN(runtimeContext, false);
if (runtimeContext->GetBundleName() != entityJson->GetString("bundleName")) {
@ -182,6 +182,9 @@ bool DataDetectorAdapter::ParseOriText(const std::unique_ptr<JsonValue>& entityJ
return false;
}
aiSpanMap_.clear();
aiSpanRects_.clear();
detectTexts_.clear();
AISpan aiSpan;
for (int32_t i = 0; i < aiSpanArray->GetArraySize(); ++i) {
auto item = aiSpanArray->GetArrayItem(i);
@ -194,6 +197,7 @@ bool DataDetectorAdapter::ParseOriText(const std::unique_ptr<JsonValue>& entityJ
aiDetectInitialized_ = true;
text = entityJson->GetString("content");
textForAI_ = text;
lastTextForAI_ = textForAI_;
if (textDetectResult_.menuOptionAndAction.empty()) {
GetAIEntityMenu();
}