1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Power BIでCognitive APIを使用して日本語を分析する方法(文字化け対策)

Last updated at Posted at 2016-12-26

ハマったところ

英語を分析する場合このページの通りにすればOK。しかし日本語を分析しようとするとCognitive Serviceから返ってくる文字が文字化けしているので、少し変える必要がある。

変えるところ

Cognitive Serviceを呼び出すクエリ

(Source) =>
let
    JsonRecords = Text.FromBinary(Json.FromValue(Source)),
    JsonRequest = "{""documents"": " & JsonRecords & "}",
 
    JsonContent = Text.ToBinary(JsonRequest, TextEncoding.Ascii),
    Response =
        Web.Contents("https://westus.api.cognitive.microsoft.com/text/analytics/v2.0/keyPhrases?",
            [
                Headers = [#"Ocp-Apim-Subscription-Key"= APIKey,
                           #"Content-Type"="application/json", Accept="application/json"],
                Content=JsonContent
            ]),
    JsonResponse = Json.Document(Response,1252)
in
    JsonResponse

の中の

JsonContent = Text.ToBinary(JsonRequest, TextEncoding.Ascii),

JsonResponse = Json.Document(Response,1252)

の2ヶ所を

JsonContent = Text.ToBinary(JsonRequest, TextEncoding.Utf8),

JsonResponse = Json.Document(Response,TextEncoding.Utf8)

のように変えるといけた。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?