PHPackages                             amirshnll/persian-swear-words - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. amirshnll/persian-swear-words

ActiveDataset[Utility &amp; Helpers](/categories/utility)

amirshnll/persian-swear-words
=============================

This is a to-be-complete list of Persian Swears you can use in your production to filter unwanted content. Wordlist is available in JSON format and there is also a helper class written in PHP to assist you how to use this datas.

3.1.0(2mo ago)30818335[2 PRs](https://github.com/amirshnll/Persian-Swear-Words/pulls)Apache-2.0C#PHP &gt;=5.2.0CI passing

Since Feb 23Pushed 1mo ago3 watchersCompare

[ Source](https://github.com/amirshnll/Persian-Swear-Words)[ Packagist](https://packagist.org/packages/amirshnll/persian-swear-words)[ Fund](https://ashokri.com/donate/)[ RSS](/packages/amirshnll-persian-swear-words/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)DependenciesVersions (20)Used By (0)

Persian-Swear-Words
===================

[](#persian-swear-words)

Persian (Farsi) Swear Words + ‍`.json` Datasets

- Functions Availabe:
    - [Java](#java)
    - [Go](#go)
    - [PHP](#php)
    - [Python](#python)
    - [JavaScript](#javascript)
    - [TypeScript](#typescript)
    - [C#](#csharp)
    - [Swift](#swift)
- Contribute: Fork and Push Requests :)
- DOI : `10.34740/kaggle/dsv/2094967`
- [`CONTRIBUTING.md`](CONTRIBUTING.md): Guidelines for contributing to the repository.
- [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md): The code of conduct for participants in the repository.

**Note:** This is a to-be-complete list of Persian Swears you can use in your production to filter unwanted content. Wordlist is available in JSON format.

**یادداشت‌ها:**

این دیتاست شامل کلماتی است که ممکن است در برخی موارد نیاز به فیلترینگ داشته باشند. کاربران برای استفاده‌های خاص باید دیتاست را متناسب با نیازهای خود شخصی‌سازی کنند. تشویق می‌شود علاقه‌مندان در تکمیل این دیتاست مشارکت کنند و برای پروژه‌های خود از آن استفاده نمایند تا متون پاک و مناسبی داشته باشند. به جای ارسال PRهای کوچک، مشارکت‌های ارزشمندتری انجام دهید. همچنین، امکان اضافه کردن class یا function به زبان‌های برنامه‌نویسی مختلف با استفاده از این دیتاست وجود دارد.

در حال حاضر توابع مربوط به زبان های زیر موجود است:

- [Java](#java)
- [Go](#go)
- [PHP](#php)
- [Python](#python)
- [JavaScript](#javascript)
- [TypeScript](#typescript)
- [C#](#csharp)
- [Swift](#swift)

موارد بیشتر:

- [`CONTRIBUTING.md`](CONTRIBUTING.md): دستورالعمل‌هایی برای مشارکت در مخزن این پروژه
- [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md): کد اخلاقی برای مشارکت‌کنندگان در مخزن این پروژه

### Installation | دستورالعمل‌های نصب

[](#installation--دستورالعمل‌های-نصب)

#### نصب با composer

[](#نصب-با-composer)

```
composer require amirshnll/persian-swear-words

```

#### نصب با npm

[](#نصب-با-npm)

```
npm i persian-swear-words

```

### Usage | روش‌های استفاده

[](#usage--روش‌های-استفاده)

#### java

[](#java)

Code link: [ 🔗 Class ](PersianSwear.java)

```
var persianSwear = new PersianSwear();

// add word(s) to DataSet
persianSwear.addWord("word");
persianSwear.addWords(new String[]{"word1", "word2"});

// remove word(s) from DataSet
persianSwear.removeWord("word");
persianSwear.removeWords(new String[]{"word1", "word2"});

// check single word
persianSwear.isBad("الا.غ "); // true
persianSwear.isBad("امروز"); // false

// check existing bad word in text
persianSwear.hasSwear("تو هیز هستی");     // true
persianSwear.hasSwear("تو دوست من هستی"); // false

// replace bad words in text
persianSwear.filterWords("تو هیز هستی");      // تو * هستی
persianSwear.filterWords("تو هیز هستی", "&"); // تو & هستی
```

#### go

[](#go)

Code link: [ 🔗 Function ](PersianSwear.go)

```
persianswear := NewPersianSwear()

// add word(s) to DataSet
persianswear.AddWord("word")
persianswear.AddWords([]string{"word1", "word2"})

// remove word(s) from DataSet
persianswear.RemoveWord("word")
persianswear.RemoveWords([]string{"word1", "word2"})

// check single word
persianswear.IsBad("الا.غ ") // true
persianswear.IsBad("امروز") // false

// check existing bad word in text
persianswear.HasSwear("تو هیز هستی")     // true
persianswear.HasSwear("تو دوست من هستی") // false

// replace bad words in text
persianswear.FilterWords("تو هیز هستی")      // تو * هستی
persianswear.FilterWords("تو هیز هستی", "&") // تو & هستی
```

#### php

[](#php)

Code link: [ 🔗 Class ](PersianSwear.php)

```
require('PersianSwear.php');
$persianswear = new PersianSwear();

// is bad
if($persianswear->is_bad('خر'))
	echo 'is bad';
else
	echo 'not bad';

// not bad
if($persianswear->is_bad('امروز'))
	echo 'is bad';
else
	echo 'not bad';

// not bad
if($persianswear->is_bad('چرت و پرت'))
	echo 'is bad';
else
	echo 'not bad';

$persianswear->add_word('چرت و پرت');
// is bad

if($persianswear->is_bad('چرت و پرت'))
	echo 'is bad';
else
	echo 'not bad';

// is bad
if($persianswear->is_bad('گاو'))
	echo 'is bad';
else
	echo 'not bad';

$persianswear->remove_word('گاو');

// not bad
if($persianswear->is_bad('گاو'))
	echo 'is bad';
else
	echo 'not bad';

// not bad
if($persianswear->has_swear('تو دوست من هستی'))
	echo 'is bad';
else
	echo 'not bad';

// is bad
if($persianswear->has_swear('تو هیز هستی'))
	echo 'is bad';
else
	echo 'not bad';

echo $persianswear->filter_words('تو دوست من هستی'); // تو دوست من هستی
echo $persianswear->filter_words('تو هیز هستی'); // تو * هستی
echo $persianswear->filter_words('تو هیز هستی', "&"); // تو & هستی

echo $persianswear->tostring(); // show all swear words
```

#### python

[](#python)

Code link: [ 🔗 Class ](PersianSwear.py)

```
persianswear = PersianSwear()

print(persianswear.is_bad('خر',ignoreOT=False )) # True

print(persianswear.is_bad('امروز',ignoreOT=False )) # False

print(persianswear.is_bad('چرت و پرت',ignoreOT=False )) # False

persianswear.add_word('چرت و پرت')
print(persianswear.is_bad('چرت و پرت' , ignoreOT=False )) # True

print(persianswear.has_swear('تو دوست من هستی' , ignoreOT=False )) # False

print(persianswear.has_swear('تو هیز هستی' , ignoreOT=False )) # True

print(persianswear.filter_words('تو دوست من هستی' , ignoreOT=False )) # تو دوست من هستی

print(persianswear.filter_words('تو هیز هستی' , ignoreOT=False )) # تو * هستی

print(persianswear.filter_words('تو هیز هستی', '&' , ignoreOT=False )) # تو & هستی

print(persianswear.is_bad('خ.ر' , ignoreOT=True )) # True

print(persianswear.is_bad( 'ام.روز' , ignoreOT=True )) # False

print(persianswear.has_swear('تو دو.ست من هستی' , ignoreOT=True )) # False

print(persianswear.has_swear('تو اسک.ل هستی' , ignoreOT=True )) # True

print(persianswear.filter_words('تو دو.ست من هستی',ignoreOT=True )) # تو دو.ست من هستی

print(persianswear.filter_words('تو هی.ز هستی',ignoreOT=True )) # تو * هستی

print(persianswear.filter_words('تو هی.ز هس.تی' , ignoreOT=True )) # تو * هس.تی

print(persianswear.tostring()) # show all swear words
```

#### javaScript

[](#javascript)

Code link: [ 🔗 Function ](PersianSwear.js)

```
import PersianSwear from './PersianSwear.js';

const text1 = 'تو دوست من هستی';
console.log(PersianSwear.hasSwear(text1)); // Output: false

const text2 = 'تو هیز هستی';
console.log(PersianSwear.hasSwear(text2)); // Output: true

const text3 = 'تو هیز هستی';
const filteredText = PersianSwear.filterWords(text3);
console.log(filteredText); // Output: تو * هستی

const word = 'خر';
console.log(PersianSwear.isBad(word)); // Output: true
```

#### typeScript

[](#typescript)

Code link: [ 🔗 Function ](/PersianSwear-TypeScript/dist/)

```
import { test, expect } from "@jest/globals";

import { PersianSwear } from "../src";

test("test check bad word", () => {
  expect(PersianSwear.isBad("آشغال")).toBe(true);
});
test("test check not bad word", () => {
  expect(PersianSwear.isBad("سلام")).toBe(false);
});

test("test check text no has bad word", () => {
  expect(PersianSwear.hasSwear("سلام عزیزم")).toBe(false);
});
test("test check text has bad word", () => {
  expect(PersianSwear.hasSwear("سلام کصافت")).toBe(true);
});
test("test check text has bad word and replace with symbol", () => {
  expect(PersianSwear.filterWords("سلام کصافت خوبی", "*")).toBe("سلام * خوبی");
});
```

#### csharp

[](#csharp)

Code link: [ 🔗 Helper ](PersianSwear-CSharp)

### Create Filter

[](#create-filter)

First of All You Need To Create Instance of **FilterPersianWords**

`var filter  = new FilterPersianWords();`

if you have any optional json file path you can pass it down to constructor.

### Use Functions

[](#use-functions)

- Is a **single word** bad? `var isBadWord = filter.IsBadWord("yourWord");`
- Is a **multi line string** bad? `var isBadSentence = filter.IsBadSentence("your long sentence");`
- **Get all bad words** inside of string

> `var badList = filter.GetBadWords("your long sentence");`

- **Remove All Bad words** From String `var clearedString = filter.RemoveBadWords("your bad sentence");`

This Method Will not change any data from string except the bad words.

#### wwift

[](#wwift)

Code link: [ 🔗 Classes and Protocol ](PersianSwear.swift)

کلاس اصلی `PersianSwear` هست، که متدها داخل آن پیاده‌سازی شده است:
```
// add word(s) to DataSet
PersianSwear.shared.addWord("bad-word")
PersianSwear.shared.addWords(["bad-word-1", "bad-word-2"])

// remove word(s) from DataSet
PersianSwear.shared.removeWord("bad-word")
PersianSwear.shared.removeWords(["bad-word-1", "bad-word-2"])

// check single word
let isBadWord = PersianSwear.shared.isBadWord("single word")

// check existing bad word in text
let hasBadWord = PersianSwear.shared.hasBadWord("long text")

// existing bad word in text
let badWords = PersianSwear.shared.badWords(in: "long text")

// replace bad words in text
let newText = PersianSwear.shared.replaceBadWords(in: "long text", with: "****")
```

یک پروتکل با اسم `PersianSwearDataLoader` که کارایی آن لود کردن کلمات هست وجود دارد:

```
protocol PersianSwearDataLoader {
	func loadWords(
		_ completion: @escaping (Result) -> Void
	)
}
```

برای نمونه، تایپ لود کننده کلمات از روی گیت‌هاب پیاده‌سازی شده. نمونه استفاده هم بصورت زیر هست:

```
let loader = GithubPersianSwearDataLoader()
PersianSwear.shared.loadWords(using: loader) { result in
	switch result {
	case .failure(let error):
		print("Error:", error.localizedDescription)
	case .success(let words):
		print("Words:", words.count)
	}
}
```

### Related Link |‌ لینک‌های مرتبط با پروژه

[](#related-link-‌-لینک‌های-مرتبط-با-پروژه)

-
-
-
-
-
-
-

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance88

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~121 days

Recently: every ~212 days

Total

16

Last Release

81d ago

Major Versions

1.6 → 2.0.02022-07-10

2.2.0 → 3.0.02024-09-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/492cfcfd3d922fd1b0c55f20b4fede216f6a46593102cb38d77881baedbd5e68?d=identicon)[amirshnll](/maintainers/amirshnll)

---

Top Contributors

[![amirshnll](https://avatars.githubusercontent.com/u/209900376?v=4)](https://github.com/amirshnll "amirshnll (98 commits)")[![AdolfMacro](https://avatars.githubusercontent.com/u/87756378?v=4)](https://github.com/AdolfMacro "AdolfMacro (6 commits)")[![armanyazdi](https://avatars.githubusercontent.com/u/43717886?v=4)](https://github.com/armanyazdi "armanyazdi (4 commits)")[![MrAliSalehi](https://avatars.githubusercontent.com/u/36738510?v=4)](https://github.com/MrAliSalehi "MrAliSalehi (3 commits)")[![amirhp-com](https://avatars.githubusercontent.com/u/18598809?v=4)](https://github.com/amirhp-com "amirhp-com (3 commits)")[![omidgolparvar](https://avatars.githubusercontent.com/u/5128342?v=4)](https://github.com/omidgolparvar "omidgolparvar (1 commits)")[![Revisto](https://avatars.githubusercontent.com/u/60847212?v=4)](https://github.com/Revisto "Revisto (1 commits)")[![sherafat79](https://avatars.githubusercontent.com/u/61517381?v=4)](https://github.com/sherafat79 "sherafat79 (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![ErfanBahramali](https://avatars.githubusercontent.com/u/77061285?v=4)](https://github.com/ErfanBahramali "ErfanBahramali (1 commits)")[![mahdisml](https://avatars.githubusercontent.com/u/1758504?v=4)](https://github.com/mahdisml "mahdisml (1 commits)")[![Nimaw](https://avatars.githubusercontent.com/u/66498830?v=4)](https://github.com/Nimaw "Nimaw (1 commits)")

---

Tags

datasetdatasetsfarsifarsiswearfarsiswearwordnlpnlp-datasetpersianpersiandatasetpersianswearwordswearsweardatasetswearword

### Embed Badge

![Health badge](/badges/amirshnll-persian-swear-words/health.svg)

```
[![Health](https://phpackages.com/badges/amirshnll-persian-swear-words/health.svg)](https://phpackages.com/packages/amirshnll-persian-swear-words)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
