パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v2.0.0

profanity_filter

不適切な言葉や露骨な単語に対して文字列をチェックおよび検閲する簡単なフィルターです。デフォルトの英語語彙リスト(LDNOOBW)が提供されています。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
1.7万
いいね数
119
Pub ポイント
160

パッケージをインストール

flutter pub add profanity_filter

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

組み込みの英語ワードリスト(LDNOOBW)を使用して、文字列の不適切な表現をチェックおよび検閲する軽量なFlutter/Dartパッケージです。攻撃的な言葉を特定し、置き換えることで、アプリ内での礼儀正しいコミュニケーションを維持します。ユーザー生成コンテンツのモデレーションやチャットアプリ、テキストフィルタリングが必要なあらゆるシナリオに最適です。このパッケージは簡単に統合でき、モバイル、Web、デスクトップなど複数のプラットフォームをサポートしています。

用途

  • ユーザー コメントのモデレーション
  • チャットアプリのフィルタリング
  • フォームにおけるコンテンツの安全性
  • リアルタイムメッセージスクリーニング
  • 自動テキストクリーンアップ

主な機能

  • 組み込み英語の不適切な表現リスト
  • シンプルな文字列チェックとセンシング
  • カスタマイズ可能な単語リスト
  • クロスプラットフォーム対応
  • Flutter との簡単な統合

適している対象

  • コンテンツの安全性を最優先に考えるアプリ開発者
  • チャットやソーシャルメディアアプリ
  • ユーザー入力用のモデレーションツール
  • 教育用または家族向けのアプリ
  • 公開コメントセクション付きのアプリ

注意事項

  • デフォルトでは英語に制限されています
  • カスタムワードリストの更新が必要になる場合があります
  • 検閲の正確さは語彙リストの完全さに依存する
  • カスタマイズなしではマルチリンガルコンテンツには適していません
  • 文脈に敏感な単語による誤検出の可能性

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

profanity_filter

Dart CI

Pub Version

Simple Dart class to create filters with methods to check and censor strings against profanity. A default English words list is provided (from LDNOOBW on GitHub).

You can also use the filters to filter out a custom set of words, by using the ProfanityFilter.filterOnly() constructor.

Usage

To use this plugin, add profanity_filter as a dependency in your pubspec.yaml file.

Note: The latest version of the package is null-safe. The last package version that wasn't null-safe is 1.0.4

Example
import 'package:profanity_filter/profanity_filter.dart';

void main() {
  //Create the filter with the default constructor.
  //The default constructor uses the default list of words provided by [LDNOOBW on GitHub](
  //https://github.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words)
  //Other constructors are available, see [README.md](https://pub.dev/packages/profanity_filter).
  final filter = ProfanityFilter();

  //This string contains the profanity 'ass'
  String badString = 'You are an ass';

  //Check for profanity - returns a boolean (true if profanity is present)
  bool hasProfanity = filter.hasProfanity(badString);
  print('The string $badString has profanity: $hasProfanity');

  //Get the profanity used - returns a List<String>
  List<String> wordsFound = filter.getAllProfanity(badString);
  print('The string contains the words: $wordsFound');

  //Censor the string - returns a 'cleaned' string.
  String cleanString = filter.censor(badString);
  print('Censored version of "$badString" is "$cleanString"');
}

Methods

hasProfanity - Detect if a string contains profanity

Use the hasProfanity() method of the filter instance. Pass in the string to be tested.

Example
final filter = ProfanityFilter();
String badString = 'you are an ass';
filter.hasProfanity(badString); //Returns true.
getAllProfanity - Get a list of all profane words found

Use the getAllProfanity() method of the filter instance. Pass in the string to be tested.

Example

final filter = ProfanityFilter();
String badString = 'you are an ass';
List<String> wordsFound = filter.getAllProfanity(badString); //Returns ['ass']
censor - Censor a string (replace profanity with something clean)

Use the censor() method of the filter instance. Pass in the string to be censored.

Example
final filter = ProfanityFilter();
String badString = 'you are an ass';
String cleanString = filter.censor('you are an ass'); //cleanString: 'you are an ***'

Optionally, you can provide your own clean replacement word to the replaceWith named parameter. filter.censor(string, replaceWith:'[censored]') will replace any profanity in string with [censored]

Default Profanity List

The default profanity list is taken from the LDNOOBW list, licensed under a Creative Commons Attribution 4.0 International License.

To create a filter with the default list, use the default constructor ProfanityFilter()

Variations
To include custom words alongside default list

Use ProfanityFilter.filterAdditionally() constructor and pass your list of custom words.

This will use a list which is equivalent to Default List + Custom List

To filter only custom words (default list is ignored)

Use ProfanityFilter.filterOnly() constructor and pass a list containing your custom set of words.

This will use a list which is equivalent to Custom List

To filter with a few exclusions from default list

Use ProfanityFilter.ignore() constructor and pass your list of custom words. Those words will be removed from the default list if they exist there.

This will use a list which is equivalent to Default List - Custom List

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト