npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

persian-swear-words

v2.1.0

Published

A comprehensive list of Persian swear words and phrases, provided in JSON format with a JavaScript helper function for easy integration.

Downloads

10

Readme

Persian-Swear-Words

Persian (Farsi) Swear Words + ‍.json Datasets

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 به زبان‌های برنامه‌نویسی مختلف با استفاده از این دیتاست وجود دارد.

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

موارد بیشتر:

  • CONTRIBUTING.md: دستورالعمل‌هایی برای مشارکت در مخزن این پروژه
  • CODE_OF_CONDUCT.md: کد اخلاقی برای مشارکت‌کنندگان در مخزن این پروژه

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

نصب با composer

composer require amirshnll/persian-swear-words

نصب با npm

npm i persian-swear-words

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

Java | جاوا

Code link: 🔗 Class

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("تو هیز هستی", "&"); // تو & هستی

PHP | پی‌اچ‌پی

Code link: 🔗 Class

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 | پایتون

Code link: 🔗 Class

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 | جاواسکریپت

Code link: 🔗 Function

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 | تایپ‌اسکریپت

Code link: 🔗 Function

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 | سی‌شارپ

Code link: 🔗 Helper

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

  • 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.

Swift | سوئیفت

Code link: 🔗 Classes and Protocol

// 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<PersianSwear.Words, Error>) -> 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 |‌ لینک‌های مرتبط با پروژه

  • https://jadi.net/2020/11/mondays-99-08/
  • https://awesomeopensource.com/projects/persian
  • https://twitter.com/SamadiPour/status/1362702419252178945?s=20
  • https://packagist.org/packages/amirshnll/persian-swear-words
  • https://www.npmjs.com/package/persian-swear-words
  • https://github.com/mmdbalkhi/Sansorchi
  • https://matnbaz.net/github/amirshnll/Persian-Swear-Words