Azure Cognitive Services offers preview of Azure Open AI Service

MicrosoftはOpenAIのGPT-3のAzure実装であるAzure OpenAI ServiceをIgnite 2021 Fallで発表した。当初はInvitation Only、すなわち招待した限定的な顧客にのみ提供される。 参考資料 Microsoft、自然言語処理モデルGPT-3がAzureで使える「Azure OpenAI Service」を発表 (https://atmarkit.itmedia.co.jp/ait/articles/2111/04/news053.html)

11月 4, 2021 · 1 分 · 11 文字 · Me

Azureに本好きを食わせる

Azureにも本好きを食わせてみた。 しかし、本の頻度分布多すぎ。 import codecs import configparser from azure.core.credentials import AzureKeyCredential from azure.ai.textanalytics import TextAnalyticsClient config = configparser.ConfigParser() config.read('azure.config') endpoint = config['AZURE']['azure_endpoint'] key = config['AZURE']['azure_ai_key'] client = TextAnalyticsClient(endpoint=endpoint, credential=AzureKeyCredential(key)) ifs = codecs.open('N4830BU-1.txt', 'r', 'utf-8') lines = ifs.readlines() documents = [''.join(lines)] response = client.recognize_entities(documents, language = "ja") result = [doc for doc in response if not doc.is_error] for doc in result: for entity in doc.entities: print(entity.text, entity.category) プロローグ Organization 本須 麗乃 Person もとすうら Person 22歳 Quantity 本 Product 誰か PersonType 筆者 PersonType 本 Product 本屋 Location 図書館 Location 写真集 Product 外国 Location 本 Product 百科事典 Product 文学全集 Product 紙 Product 専門誌 Product 雑誌 Product 小説 Product ライトノベル Product 絵本 Product 日本 Location 素人が PersonType 同人誌 Product パラ Quantity 美酒 Product 図書館 Location 本 Product 書庫 Location 本 Product 本 Product 紙 Product インク Product そこに Location 本 Product 本 Product 書庫 Location 本 Product 本 Product 本 Product 畳 Product ベッド Product 本 Product わたし PersonType 大地震 Event 本 Product ぇ Person 司書 PersonType 大学図書館 Location 神様 PersonType 転生 Event 次 Quantity 本 Product 図書館 Location 司書 PersonType 本 Product 司書 PersonType 本 Product 本 Product 本 Product 本 Product 紙 Product インク Product 本 Product 神様 PersonType わたし PersonType 本 Product ifs.close()

4月 1, 2021 · 1 分 · 201 文字 · Me

Azure Text AnalyticsをPythonから呼び出す

import configparser from azure.core.credentials import AzureKeyCredential from azure.ai.textanalytics import TextAnalyticsClient import seaborn as sns import pandas as pd sns.set_style('white') config = configparser.ConfigParser() config.read('azure.config') endpoint = config['AZURE']['azure_endpoint'] key = config['AZURE']['azure_ai_key'] client = TextAnalyticsClient(endpoint=endpoint, credential=AzureKeyCredential(key)) documents = [ "iPhoneのマップやばいよ" ] result = client.analyze_sentiment(documents) docs = [doc for doc in result if not doc.is_error] doc = docs[0] confidience_scores = {key:value for key, value in doc.confidence_scores.items()} sentiment = pd.Series(confidience_scores) sentiment positive 0.07 neutral 0.90 negative 0.03 dtype: float64 sentiment.plot.bar() <AxesSubplot:>

3月 22, 2021 · 1 分 · 76 文字 · Me

Cognitive Servicesのテキスト分析にPowerShellから投げてみる

PowerShellからCognitive Servicesのネガポジ分析をたたいてみました。 $apiKey = “************************” $texts = @(“ColorfulのSSDめっちゃヤバいwww Galaxy S6や廃棄品のSSDから剥がしたフラッシュやIntelの偽物が搭載されているのが確認されてるらしいwww 安価なNVMe CN600もリマークチップを使ってるとのこと、、、 最近めっちゃ秋葉原で売ってるけど買わない方が良さそうだな、、、”) $headers = @{ ‘Ocp-Apim-Subscription-Key’ = $apiKey } $endPoint = “https://eastasia.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment” $texts | ForEach-Object { $text = $_ $obj = @{ documents = @(@{ language = “ja” id = “1” text = $text }) } $json = ConvertTo-Json $obj $result = Invoke-RestMethod -Uri $endPoint -Headers $headers -Body $json -ContentType ‘application/json; charset=utf-8’ -Method Post $items = $result.documents $item = $items[0] $item.score }

6月 5, 2018 · 1 分 · 73 文字 · Me