Skip to content

Commit

Permalink
キーワード抽出とテキストペア類似度API
Browse files Browse the repository at this point in the history
  • Loading branch information
3w36zj6 committed Oct 26, 2021
1 parent 5830b0f commit e0c4115
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion app.py
Expand Up @@ -2,8 +2,14 @@
from flask_sqlalchemy import SQLAlchemy

import json

import random
import requests
import os

# 環境変数
from dotenv import load_dotenv

load_dotenv()

app = Flask(__name__, static_folder="static")

Expand Down Expand Up @@ -114,6 +120,45 @@ def get_comment_parents(comment_id):
return jsonify(parents)


# キーワード抽出
def get_keywords():
item_data = {
"app_id": os.environ["GOO_LAB_APP_ID"],
"title": "",
"body": "",
"max_num": 10,
}
try:
response = requests.post("https://labs.goo.ne.jp/api/keyword", json=item_data)
response.raise_for_status()
except requests.exceptions.RequestException as e: # エラーの場合のみ
print(e)
else: # 正常に処理された場合のみ
response_json = json.loads(response.text)
print(response_json)
finally: # 常に実行
pass


# テキストペア類似度
def get_textpair():
item_data = {
"app_id": os.environ["GOO_LAB_APP_ID"],
"text1": "",
"text2": "",
}
try:
response = requests.post("https://labs.goo.ne.jp/api/textpair", json=item_data)
response.raise_for_status()
except requests.exceptions.RequestException as e: # エラーの場合のみ
print(e)
else: # 正常に処理された場合のみ
response_json = json.loads(response.text)
print(response_json)
finally: # 常に実行
pass


# CLI用 DB初期化
@app.cli.command("init-db")
def init_db():
Expand Down

0 comments on commit e0c4115

Please sign in to comment.