Amazon Comprehend Medical 返回过滤后的值

Amazon Comprehend Medical returning FILTERED values

A​​mazon Comprehend Medical return 标记为 [已过滤] 的值。我有一个 rails 5.2 应用程序并安装了 aws-sdk gem。我现在正在尝试通过 rails 控制台进行 API 调用并获得 return JSON。但是大多数值被 returned 为 [FILTERED]。知道是什么原因造成的吗?

我已经搜索了 AWS 文档,但似乎找不到这个问题的答案。

class Comprehend 
 require 'aws-sdk-comprehendmedical'  

  client = Aws::ComprehendMedical::Client.new
  resp = client.detect_entities({
   text: "45 yr old male with chestpain and SOB BP 120/70", # required
    })
  puts(resp)

end

这是在控制台中 运行 this as Comprehend.new 时的结果。

{
    :entities=>[
        {
            :id=>"[FILTERED]",
            :begin_offset=>0,
            :end_offset=>2,
            :score=>0.9994971752166748,
            :text=>"[FILTERED]",
            :category=>"PROTECTED_HEALTH_INFORMATION",
            :type=>"[FILTERED]",
            :traits=>[],
            :attributes=>nil
        },
        {
            :id=>"[FILTERED]",
            :begin_offset=>20,
            :end_offset=>29,
            :score=>0.9164832830429077,
            :text=>"[FILTERED]",
            :category=>"MEDICAL_CONDITION",
            :type=>"[FILTERED]",
            :traits=>[],
            :attributes=>nil
        },
        {
            :id=>"[FILTERED]",
            :begin_offset=>34,
            :end_offset=>37,
            :score=>0.8974254131317139,
            :text=>"[FILTERED]",
            :category=>"MEDICAL_CONDITION",
            :type=>"[FILTERED]",
            :traits=>[],
            :attributes=>nil
        },
        {
            :id=>"[FILTERED]",
            :begin_offset=>38,
            :end_offset=>40,
            :score=>0.8211551904678345,
            :text=>"[FILTERED]",
            :category=>"TEST_TREATMENT_PROCEDURE",
            :type=>"[FILTERED]",
            :traits=>[],
            :attributes=>[
                {
                    :type=>"[FILTERED]",
                    :score=>0.9983691573143005,
                    :relationship_score=>1.0,
                    :id=>"[FILTERED]",
                    :begin_offset=>41,
                    :end_offset=>47,
                    :text=>"[FILTERED]",
                    :traits=>[]
                }
            ]
        }
    ],
    :unmapped_attributes=>[],
    :pagination_token=>nil
}

这是打印到 rails 控制台或在日志中使用时敏感信息的预期行为。

实际值在那里并且可以通过编程方式使用,但是 aws-sdk 有一个有趣的功能,称为日志过滤,它们用于隐藏日志和控制台中的敏感信息。 Rails 具有您可以使用的类似功能,下面是 rails 文档的链接以及 aws-sdk ruby gem 中用于过滤敏感信息的代码:

对于使用 aws api 遇到此问题的人,请改用 to_h

puts resp.to_h

如果您需要 json 就

puts resp.to_h.to_json