prekladatelj 0.1.1 → 0.1.2

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.
data/lib/prekladatelj.rb CHANGED
@@ -34,6 +34,23 @@ module Prekladatelj
34
34
 
35
35
  end
36
36
  =end
37
+ class Helper
38
+ def self.smart_split(string)
39
+ a = []
40
+ last = ''
41
+ (0..string.length-1).each do |l|
42
+ if string[l]==' '
43
+ a.append last unless last.empty?
44
+ a.append string[l]
45
+ last = ''
46
+ else
47
+ last = last + string[l]
48
+ end
49
+ a.append last if l==string.length-1
50
+ end
51
+ a
52
+ end
53
+ end
37
54
 
38
55
  class Cyrillic
39
56
  UPPER = %w[А Б Ц Ч Д Е Є Ф Г Х И Ј К Л Љ М Н Њ О П Р С Ш Т У В Ы З Ж]
@@ -58,7 +75,7 @@ module Prekladatelj
58
75
  EASTERN = {
59
76
  "ju" => "ю",
60
77
  "ja" => "я",
61
- "ě" => "е",
78
+ "ě" => "є",
62
79
  "je" => "е",
63
80
  "lj" => "ль",
64
81
  "nj" => "нь",
@@ -71,19 +88,25 @@ module Prekladatelj
71
88
  str = String line[0..-1]
72
89
 
73
90
  if args.any? :eastern
74
- line = str.split.to_a
91
+ line = Helper::smart_split str
75
92
  line.each do |word|
76
- if word.start_with? "je"
77
- word["je"] = "е"
93
+ while word =~ /[eě](je)/
94
+ word["eje"] = "ее" if word.include? 'eje'
95
+ word["ěje"] = "єе" if word.include? 'ěje'
96
+ end
97
+ while word =~ /[^aiueoyj](je)/
98
+ word["je"] = "ье"
78
99
  end
79
- if word.gsub(/\W+/, '') == "se"
80
- word["se"] = "ся"
100
+ while word =~ /(ji)/
101
+ word["ji"] = "и"
81
102
  end
103
+ word["je"] = "е" if word.start_with? "je"
104
+ word["se"] = "ся" if word.gsub(/\W+/, '') == "se"
82
105
  while word =~ /[^aiueoyj](je)/
83
106
  word["je"] = "ье"
84
107
  end
85
108
  end
86
- str = line.join " "
109
+ str = line.join ""
87
110
 
88
111
  EASTERN.each_pair do |k, v|
89
112
  str.gsub! k, v
@@ -1,3 +1,3 @@
1
1
  module Prekladatelj
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prekladatelj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - bikeroleg
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-01 00:00:00.000000000 Z
11
+ date: 2021-07-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'This gem helps to convert a text from one writing system to another
14
14
  using Interslavic standards, with option to specify one. Also works as a standalone
@@ -32,6 +32,7 @@ files:
32
32
  - ".travis.yml"
33
33
  - Gemfile
34
34
  - Gemfile.lock
35
+ - LICENSE
35
36
  - README.md
36
37
  - README_isl_cy.md
37
38
  - README_isl_la.md
@@ -63,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
64
  - !ruby/object:Gem::Version
64
65
  version: '0'
65
66
  requirements: []
66
- rubygems_version: 3.1.4
67
+ rubygems_version: 3.2.21
67
68
  signing_key:
68
69
  specification_version: 4
69
70
  summary: Convert Interslavic sentences from latin to cyrillic and vice versa