# Profanity Detection and Cleaning API

APIエンドポイント: **`https://events-front.mixeder.net/v2/wordetect/`**

***

#### **API概要**

Profanity Detection and Cleaning APIは、テキストから不適切な単語を検出し、指定の文字やパターンで置換する機能を提供します。ユーザーは、簡単なAPIコールで不適切な表現の除去や検出を行うことができます。以下は具体的な利用手順とサンプルコードです。

***

### **APIの使い方**

#### **1. API キーの提供方法**

APIを利用するには、**有効なAPIキー**を以下のいずれかの方法で渡してください。

* **GETパラメータ**: `?key=<API_KEY>`
* **POSTパラメータ**: `api-key=<API_KEY>`
* **HTTPヘッダー**: `api-key: <API_KEY>`

***

### **パラメータ一覧**

| **パラメータ名**  | **型**  | **必須** | **説明**                                                |
| ----------- | ------ | ------ | ----------------------------------------------------- |
| `key`       | string | 必須     | APIキー。GET/POSTまたはヘッダーで提供可能。                           |
| `text`      | string | 必須     | 不適切単語を検出・置換する対象テキスト。                                  |
| `add`       | string | 任意     | カンマ区切りで追加する不適切単語リスト。                                  |
| `fill_text` | string | 任意     | 置換時に使用する文字列（デフォルト: `*`）。                              |
| `fill_char` | string | 任意     | 置換時、単語長に応じて使う文字（例: `#`）。                              |
| `method`    | string | 任意     | 実行モード: `json` / `xml` / `plain` / `containsprofanity` |

***

### **モードの説明**

1. **containsprofanity**
   * テキスト内に不適切な単語があるかどうかを検出します。
   * **戻り値**: `true` / `false` (JSON形式)
2. **json**
   * 入力テキストと置換後のクリーンなテキストをJSONで返します。
3. **xml**
   * テキストの置換結果をXML形式で返します。
4. **plain**
   * 置換後のクリーンなテキストをプレーンテキスト形式で返します。

***

### **サンプルコード**

#### **1. JSON形式のクリーンテキスト取得**

**リクエスト**

```bash
curl "https://events-front.mixeder.net/v2/wordetect/?key=YOUR_API_KEY&text=This is a bad word&method=json"
```

**レスポンス**

```json
{
  "original": "This is a bad word",
  "cleaned": "This is a *** word"
}
```

***

#### **2. XML形式での出力**

**リクエスト**

```bash
curl "https://events-front.mixeder.net/v2/wordetect/?key=YOUR_API_KEY&text=This is ugly&method=xml"
```

**レスポンス**

```xml
<?xml version="1.0" encoding="UTF-8"?>
<response>
  <original>This is bad</original>
  <cleaned>This is ****</cleaned>
</response>
```

***

#### **3. プレーンテキスト形式の出力**

**リクエスト**

```bash
curl "https://events-front.mixeder.net/v2/wordetect/?key=YOUR_API_KEY&text=Bad example&method=plain"
```

**レスポンス**

```
*** example
```

***

#### **4. 不適切単語検出 (containsprofanity モード)**

**リクエスト**

```bash
curl "https://events-front.mixeder.net/v2/wordetect/?key=YOUR_API_KEY&text=Bad words here&method=containsprofanity"
```

**レスポンス**

```json
"true"
```

***

#### **5. カスタムの追加単語と置換文字の指定**

**リクエスト**

```bash
curl "https://events-front.mixeder.net/v2/wordetect/?key=YOUR_API_KEY&text=Special bad words&add=special&fill_char=#&method=json"
```

**レスポンス**

```json
{
  "original": "Special bad words",
  "cleaned": "####### bad words"
}
```

***

#### **6. HTTPヘッダーでのAPIキー提供例**

**PHPサンプルコード**

```php
$apiUrl = "https://events-front.mixeder.net/v2/wordetect/";
$text = "This is inappropriate content.";
$headers = [
    "api-key: YOUR_API_KEY"
];

$options = [
    'http' => [
        'header' => implode("\r\n", $headers),
        'method' => 'GET',
        'content' => http_build_query(['text' => $text, 'method' => 'json'])
    ]
];

$context = stream_context_create($options);
$response = file_get_contents($apiUrl, false, $context);
echo $response;
```

***

#### **7. POSTメソッドの利用例**

**リクエスト**

```bash
curl -X POST "https://events-front.mixeder.net/v2/wordetect/" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "api-key=YOUR_API_KEY" \
-d "text=Some bad words here" \
-d "method=json"
```

**レスポンス**

```json
{
  "original": "Some bad words here",
  "cleaned": "Some *** words here"
}
```

***

### **エラーハンドリング**

#### **1. APIキーが未提供の場合**

```json
"API Key not provided."
```

#### **2. 無効なAPIキーの場合**

```json
"API key is wrong"
```

***

### **不適切単語の管理**

* **基本の不適切単語リスト**はMIXEDERによってリストされたベース学習リストから取得されます。
* **カスタム追加単語**は、`add` パラメータで指定します。\
  例: `&add=dummy,offensive`

***

### **まとめ**

このAPIは、不適切な表現の検出およびフィルタリングを効率的に行います。多彩な出力形式やカスタム単語の追加機能により、柔軟な対応が可能です。ぜひ、Profanity Detection and Cleaning APIを活用して、ユーザーフレンドリーなテキスト管理を実現してください。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.mixeder.net/mixederpublicapis/apirifarensu/profanity-detection-and-cleaning-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
