sakamoto84 commited on
Commit
1fe7249
·
verified ·
1 Parent(s): 480d096

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +12 -13
  2. app.py +22 -0
  3. requirements.txt +4 -0
README.md CHANGED
@@ -1,14 +1,13 @@
1
- ---
2
- title: Test Model
3
- emoji: 🏃
4
- colorFrom: red
5
- colorTo: blue
6
- sdk: gradio
7
- sdk_version: 5.38.2
8
- app_file: app.py
9
- pinned: false
10
- license: mit
11
- short_description: test space
12
- ---
13
 
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
1
+ # 日本語コメント判定アプリ
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ Gradio + Transformers を使って、日本語のコメントを NGワードチェック & 感情分析します。
4
+
5
+ ## モデル
6
+ - 感情分析: `jarvisx17/japanese-sentiment-analysis`
7
+
8
+ ## 公開方法(Hugging Face Spaces)
9
+ 1. [https://huggingface.co/spaces](https://huggingface.co/spaces) にアクセス
10
+ 2. 「Create new Space」をクリック
11
+ 3. Repository type を「Gradio」に設定
12
+ 4. Space 名と公開範囲を決めて作成
13
+ 5. このZIPをアップロード
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # 感情分析モデルの読み込み
5
+ classifier = pipeline("sentiment-analysis", model="jarvisx17/japanese-sentiment-analysis")
6
+
7
+ # NGワードリスト
8
+ NG_WORDS = ["あほ", "ばか", "くそ", "死ね", "むかつく", "うざい", "しね", "バカ", "アホ"]
9
+
10
+ def classify_comment(comment):
11
+ if any(ng in comment for ng in NG_WORDS):
12
+ return "❌ 不適切なコメント(NGワード検出)"
13
+ result = classifier(comment)[0]
14
+ return f"判定結果: {result['label']} (スコア: {result['score']:.2f})"
15
+
16
+ gr.Interface(
17
+ fn=classify_comment,
18
+ inputs=gr.Textbox(lines=3, placeholder="コメントを入力"),
19
+ outputs="text",
20
+ title="日本語コメント判定(NGワード + 感情分析)",
21
+ description="NGワードを検出し、なければ感情分析結果を表示します"
22
+ ).launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio
2
+ transformers
3
+ torch
4
+ fugashi[unidic-lite]