persian 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,25 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ # Persian module
4
+ module Persian
5
+ # Persian Unicode class
6
+ class Url
7
+ def self.urlify(text)
8
+ # remove brackets
9
+ text = Text.remove_brackets(text)
10
+ # remove harekats
11
+ text = Text.remove_harekats(text)
12
+ # remove slash and backslash
13
+ text.gsub!(%r{(\/||\\)}, '')
14
+ # remove signs
15
+ text = Text.remove_signs(text, ' ')
16
+ # Remove extra spaces
17
+ text = Text.remove_extra_spaces(text)
18
+ # trim spaces from start and end of text
19
+ text = text.strip
20
+ # replace space with dash
21
+ text.gsub!(/\s/, '-')
22
+ text
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,6 @@
1
1
  # -*- coding: UTF-8 -*-
2
2
 
3
+ # Persian module
3
4
  module Persian
4
- VERSION = '0.1.0'
5
+ VERSION = '0.2.1'.freeze
5
6
  end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require 'persian/version'
7
+
8
+ Gem::Specification.new do |s|
9
+ s.name = 'persian'
10
+ s.version = Persian::VERSION
11
+ s.date = '2016-11-16'
12
+ s.summary = 'Persian language for ruby.'
13
+ s.description = 'A set of utilities for Persian language.'
14
+ s.authors = ['Dariush Abbasi']
15
+ s.email = 'poshtehani@gmail.com'
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
18
+ s.executables =
19
+ `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
20
+ s.require_paths = ['lib']
21
+ s.homepage =
22
+ 'http://github.com/negah/persian'
23
+ s.license = 'MIT'
24
+
25
+ s.add_development_dependency 'rspec', '3.4'
26
+ end
@@ -0,0 +1,47 @@
1
+ <p align="center">
2
+ <img src="https://upload.wikimedia.org/wikipedia/commons/a/a2/Farsi.svg"
3
+ height="130" alt="Persian">
4
+ </p>
5
+ <p align="center">
6
+ <a href="https://travis-ci.org/negah/persian">
7
+ <img src="https://travis-ci.org/negah/persian.svg?branch=master"
8
+ alt="Build Status">
9
+ </a>
10
+ <a href="https://rubygems.org/gems/persian">
11
+ <img src="https://img.shields.io/badge/gem-persian-orange.svg"
12
+ alt="Ruby Gems">
13
+ </a>
14
+
15
+ <a href="https://rubygems.org/gems/persian">
16
+ <img src="https://img.shields.io/gem/dv/persian/stable.svg?maxAge=2592000"
17
+ alt="Ruby Gems downloads">
18
+ </a>
19
+
20
+ <a href="https://codeclimate.com/github/negah/persian">
21
+ <img src="https://codeclimate.com/github/negah/persian/badges/gpa.svg"
22
+ alt="Code Climate">
23
+ </a>
24
+ </p>
25
+ <p align="center"><sup><strong> Ruby gem for working with Persian text. </strong></sup></p>
26
+
27
+
28
+
29
+ Install
30
+ -----
31
+ ```shell
32
+ gem install persian
33
+ ```
34
+
35
+ Usage
36
+ -----
37
+ ```ruby
38
+ require 'persian'
39
+ ```
40
+
41
+ Components
42
+ ----------
43
+ incomplete.
44
+
45
+ License
46
+ -------
47
+ Released under the MIT License.
@@ -0,0 +1,83 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'persian counter methods' do
6
+ it 'should return a hash of characters with their number of occurrence' do
7
+ before = 'من غلام قمرم غیر قمر هیچ مگو'
8
+ after = {
9
+ 'م' => 6,
10
+ 'ن' => 1,
11
+ ' ' => 6,
12
+ 'غ' => 2,
13
+ 'ل' => 1,
14
+ 'ا' => 1,
15
+ 'ق' => 2,
16
+ 'ر' => 3,
17
+ 'ی' => 2,
18
+ 'ه' => 1,
19
+ 'چ' => 1,
20
+ 'گ' => 1,
21
+ 'و' => 1
22
+ }
23
+ arg = 'غ'
24
+ after_with_arg = 2
25
+
26
+ expect(Persian::Counter.character(before)).to eq(after)
27
+ expect(Persian::Counter.character(before, arg)).to eq(after_with_arg)
28
+ end
29
+
30
+ it 'should return a hash of words as key and number of occurrence of word as value' do
31
+ before = 'پرچم دوران هخامنشی به احتمال زیاد عقابی با بال های گشوده با قرص خورشیدی در پشت سر عقاب بوده است'
32
+ after = {
33
+ 'پرچم' => 1,
34
+ 'دوران' => 1,
35
+ 'هخامنشی' => 1,
36
+ 'به' => 1,
37
+ 'احتمال' => 1,
38
+ 'زیاد' => 1,
39
+ 'عقابی' => 1,
40
+ 'با' => 2,
41
+ 'بال' => 1,
42
+ 'های' => 1,
43
+ 'گشوده' => 1,
44
+ 'قرص' => 1,
45
+ 'خورشیدی' => 1,
46
+ 'در' => 1,
47
+ 'پشت' => 1,
48
+ 'سر' => 1,
49
+ 'عقاب' => 1,
50
+ 'بوده' => 1,
51
+ 'است' => 1
52
+ }
53
+ arg = 'با'
54
+ after_with_arg = 2
55
+
56
+ expect(Persian::Counter.word(before)).to eq(after)
57
+ expect(Persian::Counter.word(before, arg)).to eq(after_with_arg)
58
+ end
59
+
60
+ it 'should return number of paragraphs' do
61
+ text = "
62
+ یوهانس برامس در سال ۱۸۳۳ در شهر هامبورگ آلمان در خانواده‌ای فقیر به دنیا آمد. تحصیلات ابتدایی موسیقی را نزد پدرش که نوازنده کنترباس بود فرا گرفت.
63
+ برامس با ویولونیست‌های مشهوری چون رمنی و یواخیم آشنا شد و در طول این آشنایی بود که رمنی موسیقی محلی مجارستان را به برامس معرفی کرد و تحت تأثیر آن برامس رقص‌های مجار خود را نوشت.
64
+ "
65
+ after = 2
66
+
67
+ expect(Persian::Counter.paragraph(text)).to eq(after)
68
+ end
69
+
70
+ it 'shoud count uniq characters' do
71
+ text = 'دوستت دارم'
72
+ size = 8
73
+
74
+ expect(Persian::Counter.uniq_character(text)).to eq(size)
75
+ end
76
+
77
+ it 'shoud return length of text' do
78
+ text = 'راهی بزن که آهی بر ساز آن توان زد'
79
+ size = 33
80
+
81
+ expect(Persian::Counter.character_counter(text)).to eq(size)
82
+ end
83
+ end
@@ -0,0 +1,6 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'persian dynamic methods methods' do
6
+ end
@@ -0,0 +1,17 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'persian number to character methods' do
6
+ it 'should convert english numbers to spelled persian character' do
7
+ before = 1234
8
+ after = 'یک هزار و دویست و سی و چهار'
9
+ expect(Persian::NumText.num_to_char(before)).to eq(after)
10
+ end
11
+
12
+ it 'should convert Persian numbers to spelled persian number' do
13
+ before = '۲۰۴۸۲۰۴۸'
14
+ after = 'بیست میلیون و چهارصد و هشتاد و دو هزار و چهل و هشت'
15
+ expect(Persian::NumText.num_to_char(before)).to eq(after)
16
+ end
17
+ end
@@ -0,0 +1,129 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'persian number methods' do
6
+ it 'should convert english numbers ( numeric ) to persian numbers' do
7
+ before = 1_000
8
+ after = '۱۰۰۰'
9
+ expect(Persian::Number.number(before)).to eq(after)
10
+ end
11
+
12
+ it 'should convert english numbers (string) to persian numbers' do
13
+ before = '1234567890'
14
+ after = '۱۲۳۴۵۶۷۸۹۰'
15
+ expect(Persian::Number.number(before)).to eq(after)
16
+ end
17
+
18
+ it 'should convert arabic numbers to persian numbers' do
19
+ before = '٠١٢٣٤٥٦٧٨٩'
20
+ after = '۰۱۲۳۴۵۶۷۸۹'
21
+ expect(Persian::Number.number(before)).to eq(after)
22
+ end
23
+
24
+ it 'should convert arabic and english numbers in strings to persian numbers' do
25
+ before = 'عدد 1 و ٥ دو عدد زیبا هستند'
26
+ after = 'عدد ۱ و ۵ دو عدد زیبا هستند'
27
+ expect(Persian::Number.number(before)).to eq(after)
28
+ end
29
+
30
+ it 'should convert english numbers ( numeric ) to arabic numbers' do
31
+ before = 1_000
32
+ after = '١٠٠٠'
33
+ expect(Persian::Number.number(before, lang: 'ar')).to eq(after)
34
+ end
35
+
36
+ it 'should convert english numbers (string) to arabic numbers' do
37
+ before = '1234567890'
38
+ after = '١٢٣٤٥٦٧٨٩٠'
39
+ expect(Persian::Number.number(before, lang: 'ar')).to eq(after)
40
+ end
41
+
42
+ it 'should convert persian numbers to arabic numbers' do
43
+ before = '۰۱۲۳۴۵۶۷۸۹'
44
+ after = '٠١٢٣٤٥٦٧٨٩'
45
+ expect(Persian::Number.number(before, lang: 'ar')).to eq(after)
46
+ end
47
+
48
+ it 'should convert persian and english numbers in strings to arabic numbers' do
49
+ before = 'عدد 1 و ۵ دو عدد زیبا هستند'
50
+ after = 'عدد ١ و ٥ دو عدد زیبا هستند'
51
+ expect(Persian::Number.number(before, lang: 'ar')).to eq(after)
52
+ end
53
+
54
+ it 'should convert english numbers ( numeric ) to english numbers (string)' do
55
+ before = 1_000
56
+ after = '1000'
57
+ expect(Persian::Number.number(before, lang: 'en')).to eq(after)
58
+ end
59
+
60
+ it 'should convert arabic numbers (string) to english numbers' do
61
+ before = '١٢٣٤٥٦٧٨٩٠'
62
+ after = '1234567890'
63
+ expect(Persian::Number.number(before, lang: 'en')).to eq(after)
64
+ end
65
+
66
+ it 'should convert persian numbers to english numbers' do
67
+ before = '۰۱۲۳۴۵۶۷۸۹'
68
+ after = '0123456789'
69
+ expect(Persian::Number.number(before, lang: 'en')).to eq(after)
70
+ end
71
+
72
+ it 'should convert persian and arabic numbers in strings to english numbers' do
73
+ before = 'عدد ۱ و ٥ دو عدد زیبا هستند'
74
+ after = 'عدد 1 و 5 دو عدد زیبا هستند'
75
+ expect(Persian::Number.number(before, lang: 'en')).to eq(after)
76
+ end
77
+
78
+ it 'should convert english numbers ( numeric ) to english numbers (int)' do
79
+ before = 1000
80
+ after = 1_000
81
+ expect(Persian::Number.number(before, lang: 'en', return: 'int')).to eq(after)
82
+ end
83
+
84
+ it 'should convert arabic numbers (string) to english numbers (int)' do
85
+ before = '١٢٣٤٥٦٧٨٩٠'
86
+ after = 1_234_567_890
87
+ expect(Persian::Number.number(before, lang: 'en', return: 'int')).to eq(after)
88
+ end
89
+
90
+ it 'should convert persian numbers to english numbers (int)' do
91
+ before = '۰۱۲۳۴۵۶۷۸۹'
92
+ after = 123_456_789
93
+ expect(Persian::Number.number(before, lang: 'en', return: 'int')).to eq(after)
94
+ end
95
+
96
+ it 'should convert any number to persian number' do
97
+ before = '1234567890'
98
+ after = '۱۲۳۴۵۶۷۸۹۰'
99
+
100
+ expect(Persian::Number.to_persian(before)).to eq(after)
101
+ end
102
+
103
+ it 'should convert any number to english number' do
104
+ before = '١٢٣٤٥٦٧٨٩٠'
105
+ after = '1234567890'
106
+
107
+ expect(Persian::Number.to_english(before)).to eq(after)
108
+ end
109
+
110
+ it 'should convert any number to arabic number' do
111
+ before = '1234567890'
112
+ after = '١٢٣٤٥٦٧٨٩٠'
113
+
114
+ expect(Persian::Number.to_arabic(before)).to eq(after)
115
+ end
116
+
117
+ it 'should return a random number in persian' do
118
+ range = 20
119
+
120
+ expect(Persian::Number.number(Persian::Number.random(range), lang: 'en', return: 'int')).to be <= range
121
+ end
122
+
123
+ it 'should return integer of any number' do
124
+ before = '۱۲۳۴۵۶۷۸۹۰'
125
+ after = 1_234_567_890
126
+
127
+ expect(Persian::Number.to_i(before)).to eq(after)
128
+ end
129
+ end
@@ -0,0 +1,7 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ require 'persian'
4
+
5
+ RSpec.configure do |config|
6
+ config.tty = true
7
+ end
@@ -0,0 +1,236 @@
1
+ # -*- coding: UTF-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'persian character methods' do
6
+ it 'should convert arbaic characters to persian characters' do
7
+ before = 'ملوك'
8
+ after = 'ملوک'
9
+ expect(Persian::Text.character(before)).to eq(after)
10
+ end
11
+
12
+ it 'should remove redundent spaces in strings' do
13
+ before = 'سلام من به تو یار قدیمی'
14
+ after = 'سلام من به تو یار قدیمی'
15
+ expect(Persian::Text.remove_extra_spaces(before)).to eq(after)
16
+ end
17
+
18
+ it 'should remove all arabic harekats from strings' do
19
+ before = 'مَتَی ما تَلْقَ مَنْ تَهْوَی دَعِ الدُّنیا وأهْْمِلْها'
20
+ after = 'متی ما تلق من تهوی دع الدنیا وأهملها'
21
+ expect(Persian::Text.remove_harekats(before)).to eq(after)
22
+ end
23
+
24
+ it 'should remove all brackets from text' do
25
+ before = 'سلام من به «تو»'
26
+ after = 'سلام من به تو'
27
+ expect(Persian::Text.remove_brackets(before)).to eq(after)
28
+ end
29
+
30
+ it 'should remove all signs from text' do
31
+ before = 'مسلمان و دروغ؟!'
32
+ after = 'مسلمان و دروغ'
33
+ expect(Persian::Text.remove_signs(before)).to eq(after)
34
+ end
35
+
36
+ it 'should replace [ & ], { & }, ( & ), " & " with « & »' do
37
+ before_first = 'اگر اراده ای نباشد عشقی نیست. "گاندی"'
38
+ after_first = 'اگر اراده ای نباشد عشقی نیست. «گاندی»'
39
+
40
+ before_second = 'اگر اراده ای نباشد عشقی نیست. [گاندی]'
41
+ after_second = 'اگر اراده ای نباشد عشقی نیست. «گاندی»'
42
+
43
+ before_third = 'اگر اراده ای نباشد عشقی نیست. (گاندی)'
44
+ after_third = 'اگر اراده ای نباشد عشقی نیست. «گاندی»'
45
+
46
+ before_forth = 'اگر اراده ای نباشد عشقی نیست. {گاندی}'
47
+ after_forth = 'اگر اراده ای نباشد عشقی نیست. «گاندی»'
48
+
49
+ expect(Persian::Text.general_brackets(before_first)).to eq(after_first)
50
+ expect(Persian::Text.general_brackets(before_second)).to eq(after_second)
51
+ expect(Persian::Text.general_brackets(before_third)).to eq(after_third)
52
+ expect(Persian::Text.general_brackets(before_forth)).to eq(after_forth)
53
+ end
54
+
55
+ it 'should replace "&" with ( & )' do
56
+ before = 'اگر اراده ای نباشد عشقی نیست. "گاندی"'
57
+ after = 'اگر اراده ای نباشد عشقی نیست. (گاندی)'
58
+ expect(Persian::Text.general_brackets(before, '(', ')')).to eq(after)
59
+ end
60
+
61
+ it 'should add ی after names that ends with ا, و, ه' do
62
+ before_first = 'داریوش'
63
+ after_first = 'داریوش'
64
+
65
+ before_second = 'حیفا'
66
+ after_second = 'حیفا‌ی'
67
+
68
+ before_third = 'الهه'
69
+ after_third = 'الهه‌ی'
70
+
71
+ expect(Persian::Text.fix_y_after_vowel(before_first)).to eq(after_first)
72
+ expect(Persian::Text.fix_y_after_vowel(before_second)).to eq(after_second)
73
+ expect(Persian::Text.fix_y_after_vowel(before_third)).to eq(after_third)
74
+ end
75
+
76
+ it 'should replace english characters with it\'s same key persian characters on keyboard' do
77
+ before = ';ajd k,p'
78
+ after = 'کشتی نوح'
79
+ expect(Persian::Text.english_to_persian_char(before)).to eq(after)
80
+ end
81
+
82
+ it 'should replace persian characters with it\'s same key english characters on keyboard' do
83
+ before = 'لخخلمث.زخپ'
84
+ after = 'google.com'
85
+ expect(Persian::Text.persian_to_english_char(before)).to eq(after)
86
+ end
87
+
88
+ it 'should replace space with zwnj after می and نمی' do
89
+ mi_before = 'بچه ها نگاه می کنند'
90
+ mi_after = 'بچه ها نگاه می‌کنند'
91
+
92
+ nmi_before = 'هنوز واژه‌ها درد را نمی فهمند.'
93
+ nmi_after = 'هنوز واژه‌ها درد را نمی‌فهمند.'
94
+
95
+ expect(Persian::Text.replace_zwnj_mi(mi_before)).to eq(mi_after)
96
+ expect(Persian::Text.replace_zwnj_mi(nmi_before)).to eq(nmi_after)
97
+ end
98
+
99
+ it 'should Resplace ست with \sاست if lastest character before \s is ا' do
100
+ first_before = 'امروز، فردا است.'
101
+ first_after = 'امروز، فرداست.'
102
+
103
+ second_before = 'نام او علی است.'
104
+ second_after = 'نام او علی است.'
105
+
106
+ expect(Persian::Text.ast(first_before)).to eq(first_after)
107
+ expect(Persian::Text.ast(second_before)).to eq(second_after)
108
+ end
109
+
110
+ it 'should remove keshide characters' do
111
+ before = 'سلـــــــــــــــــــام چطوری؟'
112
+ after = 'سلام چطوری؟'
113
+ expect(Persian::Text.keshide(before)).to eq(after)
114
+ end
115
+
116
+ it 'should replace ئ with ی if next character is ی' do
117
+ before = 'پائیز'
118
+ after = 'پاییز'
119
+ expect(Persian::Text.replace_e_y(before)).to eq(after)
120
+ end
121
+
122
+ it 'should replace 3 or more dots (.) with (…) character' do
123
+ before = 'خدانگهدار...'
124
+ after = 'خدانگهدار…'
125
+ expect(Persian::Text.three_dots(before)).to eq(after)
126
+ end
127
+
128
+ it 'should fix zwnj for تر - تری - ترین - ها - های suffixes' do
129
+ before = 'آن زیبا ترین رویا'
130
+ after = 'آن زیبا‌ترین رویا'
131
+ expect(Persian::Text.suffix(before)).to eq(after)
132
+ end
133
+
134
+ it 'should remove extra persian question marks' do
135
+ before = 'چی؟؟؟؟'
136
+ after = 'چی؟'
137
+ expect(Persian::Text.remove_extra_question_mark(before)).to eq(after)
138
+ end
139
+
140
+ it 'should add zero-width none-joiner to specific index in string' do
141
+ before = 'دوستهایم'
142
+ after = 'دوست‌هایم'
143
+ expect(Persian::Text.add_zwnj(before, 4)).to eq(after)
144
+ end
145
+
146
+ it 'should remove extra question and exclamation marks' do
147
+ before = 'نه بابا ؟؟!!!!!!!!!!!!!'
148
+ after = 'نه بابا ؟!'
149
+
150
+ expect(Persian::Text.remove_question_exclamation(before)).to eq(after)
151
+ end
152
+
153
+ it 'should remove stopwords from text' do
154
+ before = 'چوب در آب افتاد'
155
+ after = 'چوب آب افتاد'
156
+
157
+ expect(Persian::Text.remove_stopwords(before)).to eq(after)
158
+ end
159
+
160
+ it 'should remove space before noghtevirgool' do
161
+ before = 'تصور برخی از اعضای انجمن نسبت به تهران کاملا متفاوت با قبل شده است ؛ آنها فکر می‌کردند که تهران یک بیابان و منطقه‌ای بی امکانات است.'
162
+ after = 'تصور برخی از اعضای انجمن نسبت به تهران کاملا متفاوت با قبل شده است؛ آنها فکر می‌کردند که تهران یک بیابان و منطقه‌ای بی امکانات است.'
163
+
164
+ expect(Persian::Text.remove_space_noghtevirgool(before)).to eq(after)
165
+ end
166
+
167
+ it 'should remove extra persian signs after noghtevirgool' do
168
+ before = 'آهان این شد؛!'
169
+ after = 'آهان این شد؛'
170
+
171
+ expect(Persian::Text.remove_signs_after_noghtevirgool(before)).to eq(after)
172
+ end
173
+
174
+ it 'should add space after noghtevirgool' do
175
+ before = 'آهان این شد؛بیا بریم'
176
+ after = 'آهان این شد؛ بیا بریم'
177
+
178
+ expect(Persian::Text.space_after_noghtevirgool(before)).to eq(after)
179
+ end
180
+
181
+ it 'should replace noghtevirgool`s at the end of paragraphs with dot' do
182
+ before_first = 'این آخر کار است؛'
183
+ after_first = 'این آخر کار است.'
184
+
185
+ expect(Persian::Text.remove_noghtevirgool_para_end(before_first)).to eq(after_first)
186
+ end
187
+
188
+ it 'should remove noghtevirgool after brackets' do
189
+ before = 'این یک مثال(؛برای تست) است'
190
+ after = 'این یک مثال(برای تست) است'
191
+
192
+ expect(Persian::Text.remove_noghtevirgool_baz_start(before)).to eq(after)
193
+ end
194
+
195
+ it 'should remove spaces before virgool' do
196
+ before = 'لئوناردو یک نقاش پرکار نبود ، در حقیقت او پرکارترین نقشه‌کش و طراح بود.'
197
+ after = 'لئوناردو یک نقاش پرکار نبود، در حقیقت او پرکارترین نقشه‌کش و طراح بود.'
198
+
199
+ expect(Persian::Text.remove_space_before_virgool(before)).to eq(after)
200
+ end
201
+
202
+ it 'should remove extra signs after virgool' do
203
+ before = 'لئوناردو یک نقاش پرکار نبود، !در حقیقت او پرکارترین نقشه‌کش و طراح بود.'
204
+ after = 'لئوناردو یک نقاش پرکار نبود، در حقیقت او پرکارترین نقشه‌کش و طراح بود.'
205
+
206
+ expect(Persian::Text.remove_signs_after_virgool(before)).to eq(after)
207
+ end
208
+
209
+ it 'should add space after virgool if missing' do
210
+ before = 'لئوناردو یک نقاش پرکار نبود،در حقیقت او پرکارترین نقشه‌کش و طراح بود.'
211
+ after = 'لئوناردو یک نقاش پرکار نبود، در حقیقت او پرکارترین نقشه‌کش و طراح بود.'
212
+
213
+ expect(Persian::Text.space_after_virgool(before)).to eq(after)
214
+ end
215
+
216
+ it 'should remove specific character from every words in text' do
217
+ before = 'این برای پاک کردن نون است'
218
+ char = 'ن'
219
+ after = 'ای برای پاک کرد و است'
220
+
221
+ expect(Persian::Text.rm_char(before, char)).to eq(after)
222
+ end
223
+
224
+ it 'should replace end of line virgool with dot' do
225
+ text = 'جمله با ویرگول پایان نمیپذیرد،'
226
+ after = 'جمله با ویرگول پایان نمیپذیرد.'
227
+
228
+ expect(Persian::Text.rm_virgool_in_end(text)).to eq(after)
229
+ end
230
+
231
+ it 'should add space after dot\'s ends with no space character' do
232
+ text = 'سلام.اسپیس کو؟'
233
+ after = 'سلام. اسپیس کو؟'
234
+ expect(Persian::Text.space_after_dot(text)).to eq(after)
235
+ end
236
+ end