();
17 | }
18 |
19 | public EffectManager Apply(Effect effect)
20 | {
21 | var location = new SubstringLocation(0, this.SourceText.Length - 1);
22 | var change = new TextChange(effect, location);
23 | this.Changes.Add(change);
24 | return this;
25 | }
26 |
27 | public EffectManager Apply(Effect effect, int startIndex, int endIndex)
28 | {
29 | var location = new SubstringLocation(startIndex, endIndex);
30 | var change = new TextChange(effect, location);
31 | this.Changes.Add(change);
32 | return this;
33 | }
34 |
35 | public string GetResult()
36 | {
37 | var resultText = string.Copy(this.SourceText);
38 |
39 | foreach (var change in this.Changes)
40 | {
41 | var substringFinder = new SubstringFinder(resultText);
42 |
43 | var substringBeforeSelectedLocation = substringFinder.GetSubstringBefore(change.Location);
44 | var substringFromSelectedLocation = substringFinder.GetSubstringFrom(change.Location);
45 | var substringAfterSelectedLocation = substringFinder.GetSubstringAfter(change.Location);
46 |
47 | var filteredSubstringFromSelectedLocation = change.Effect.GetFilteredText(substringFromSelectedLocation);
48 |
49 | resultText = substringBeforeSelectedLocation
50 | + filteredSubstringFromSelectedLocation
51 | + substringAfterSelectedLocation;
52 | }
53 |
54 | return resultText;
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Wordy/Demo/MainForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace Demo
2 | {
3 | partial class MainForm
4 | {
5 | ///
6 | /// Обязательная переменная конструктора.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Освободить все используемые ресурсы.
12 | ///
13 | /// истинно, если управляемый ресурс должен быть удален; иначе ложно.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Код, автоматически созданный конструктором форм Windows
24 |
25 | ///
26 | /// Требуемый метод для поддержки конструктора — не изменяйте
27 | /// содержимое этого метода с помощью редактора кода.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.titleLabel = new System.Windows.Forms.Label();
32 | this.SuspendLayout();
33 | //
34 | // titleLabel
35 | //
36 | this.titleLabel.Dock = System.Windows.Forms.DockStyle.Fill;
37 | this.titleLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
38 | this.titleLabel.Location = new System.Drawing.Point(0, 0);
39 | this.titleLabel.Name = "titleLabel";
40 | this.titleLabel.Size = new System.Drawing.Size(800, 450);
41 | this.titleLabel.TabIndex = 0;
42 | this.titleLabel.Text = "Title";
43 | this.titleLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
44 | //
45 | // MainForm
46 | //
47 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
48 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
49 | this.ClientSize = new System.Drawing.Size(800, 450);
50 | this.Controls.Add(this.titleLabel);
51 | this.Name = "MainForm";
52 | this.Text = "Wordy Demo";
53 | this.ResumeLayout(false);
54 |
55 | }
56 |
57 | #endregion
58 |
59 | private System.Windows.Forms.Label titleLabel;
60 | }
61 | }
62 |
63 |
--------------------------------------------------------------------------------
/Wordy/Demo/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Этот код создан программным средством.
4 | // Версия среды выполнения: 4.0.30319.42000
5 | //
6 | // Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если
7 | // код создан повторно.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Demo.Properties
12 | {
13 |
14 |
15 | ///
16 | /// Класс ресурсов со строгим типом для поиска локализованных строк и пр.
17 | ///
18 | // Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder
19 | // класс с помощью таких средств, как ResGen или Visual Studio.
20 | // Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen
21 | // с параметром /str или заново постройте свой VS-проект.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Возврат кэшированного экземпляра ResourceManager, используемого этим классом.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Demo.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Переопределяет свойство CurrentUICulture текущего потока для всех
56 | /// подстановки ресурсов с помощью этого класса ресурсов со строгим типом.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Wordy/Wordy/Wordy.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {F7ADB621-7426-45C1-8720-5A74651C7262}
8 | Library
9 | Properties
10 | Wordy
11 | Wordy
12 | v4.6.1
13 | 512
14 | true
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/Wordy/Wordy/Tools/TransliterationManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Wordy.Data.Transliteration;
7 | using Wordy.Effects;
8 | using Wordy.Types;
9 |
10 | namespace Wordy.Tools
11 | {
12 | public class TransliterationManager
13 | {
14 | protected Language SourceLanguage { get; private set; }
15 |
16 | protected Language TargetLanguage { get; private set; }
17 |
18 | public TransliterationManager(Language sourceLanguage, Language targetLanguage)
19 | {
20 | this.SourceLanguage = sourceLanguage;
21 | this.TargetLanguage = targetLanguage;
22 | }
23 |
24 | public string GetText(string sourceText)
25 | {
26 | var rules = new TransliterationStore()
27 | .GetRules(this.SourceLanguage, this.TargetLanguage);
28 | var resultText = string.Copy(sourceText);
29 |
30 | foreach (var rule in rules)
31 | {
32 | if (rule.Replaceable.Length == 1)
33 | {
34 | resultText = resultText.Replace
35 | (
36 | new EffectManager(rule.Replaceable)
37 | .Apply(new CaseEffect(TextCase.AllUpper))
38 | .GetResult(),
39 | new EffectManager(rule.Replacement)
40 | .Apply(new CaseEffect(TextCase.FirstUpperNextLower))
41 | .GetResult()
42 | );
43 | }
44 | else
45 | {
46 | resultText = resultText.Replace
47 | (
48 | new EffectManager(rule.Replaceable)
49 | .Apply(new CaseEffect(TextCase.AllUpper))
50 | .GetResult(),
51 | new EffectManager(rule.Replacement)
52 | .Apply(new CaseEffect(TextCase.AllUpper))
53 | .GetResult()
54 | );
55 |
56 | resultText = resultText.Replace
57 | (
58 | new EffectManager(rule.Replaceable)
59 | .Apply(new CaseEffect(TextCase.FirstUpperNextLower))
60 | .GetResult(),
61 | new EffectManager(rule.Replacement)
62 | .Apply(new CaseEffect(TextCase.FirstUpperNextLower))
63 | .GetResult()
64 | );
65 |
66 | resultText = resultText.Replace
67 | (
68 | new EffectManager(rule.Replaceable)
69 | .Apply(new CaseEffect(TextCase.FirstLowerNextUpper))
70 | .GetResult(),
71 | new EffectManager(rule.Replacement)
72 | .Apply(new CaseEffect(TextCase.FirstLowerNextUpper))
73 | .GetResult()
74 | );
75 | }
76 |
77 | resultText = resultText.Replace
78 | (
79 | new EffectManager(rule.Replaceable)
80 | .Apply(new CaseEffect(TextCase.AllLower))
81 | .GetResult(),
82 | new EffectManager(rule.Replacement)
83 | .Apply(new CaseEffect(TextCase.AllLower))
84 | .GetResult()
85 | );
86 | }
87 |
88 | return resultText;
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/Wordy/Wordy/Effects/RotationEffect.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 | using Wordy.Data.Rotation;
3 | using Wordy.Types;
4 |
5 | namespace Wordy.Effects
6 | {
7 | public class RotationEffect : Effect
8 | {
9 | protected TextRotation Rotation { get; private set; }
10 |
11 | protected bool CaseSensitive { get; private set; }
12 |
13 | public RotationEffect(TextRotation rotation) : base()
14 | {
15 | this.Rotation = rotation;
16 | this.CaseSensitive = true;
17 | }
18 |
19 | public RotationEffect(TextRotation rotation, bool caseSensitive)
20 | {
21 | this.Rotation = rotation;
22 | this.CaseSensitive = caseSensitive;
23 | }
24 |
25 | public override string GetFilteredText(string sourceText)
26 | {
27 | var filteredTextBuilder = new StringBuilder();
28 | var textLength = sourceText.Length;
29 |
30 | var rotationStore = new RotationStore();
31 | var ruleCount = rotationStore.Count;
32 |
33 | for (int letterIndex = 0; letterIndex < textLength; letterIndex++)
34 | {
35 | var sourceLetter = sourceText.Substring(letterIndex, 1);
36 |
37 | var isUppercase = char.IsUpper(sourceLetter[0]);
38 | var filteredLetter = string.Copy(sourceLetter);
39 |
40 | for (int ruleIndex = 0; ruleIndex < ruleCount; ruleIndex++)
41 | {
42 | var rule = rotationStore[ruleIndex];
43 | var isNormal = string.Equals(sourceLetter.ToLower(), rule.Normal.ToLower());
44 | var isRotated = string.Equals(sourceLetter.ToLower(), rule.Rotated.ToLower());
45 | var ruleContainsLetter = isNormal || isRotated;
46 |
47 | if (!ruleContainsLetter)
48 | {
49 | continue;
50 | }
51 |
52 | switch (this.Rotation)
53 | {
54 | case TextRotation.Normal:
55 | if (isRotated)
56 | {
57 | filteredLetter = rule.Normal;
58 | }
59 | break;
60 | case TextRotation.UpsideDown:
61 | if (isNormal)
62 | {
63 | filteredLetter = rule.Rotated;
64 | }
65 | break;
66 | case TextRotation.Inverted:
67 | if (isNormal)
68 | {
69 | filteredLetter = rule.Rotated;
70 | }
71 | else if(isRotated)
72 | {
73 | filteredLetter = rule.Normal;
74 | }
75 | break;
76 | }
77 |
78 | var foundAppropriateRule = ruleContainsLetter;
79 |
80 | if (foundAppropriateRule)
81 | {
82 | break;
83 | }
84 | }
85 |
86 | if (this.CaseSensitive)
87 | {
88 | filteredLetter = isUppercase
89 | ? filteredLetter.ToUpper()
90 | : filteredLetter.ToLower();
91 | }
92 |
93 | filteredTextBuilder.Append(filteredLetter);
94 | }
95 |
96 | return filteredTextBuilder.ToString();
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/Wordy/Demo/Demo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {0B72EE3D-C3FD-45EE-86BF-88180608CD59}
8 | WinExe
9 | Demo
10 | Demo
11 | v4.6.1
12 | 512
13 | true
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | Form
51 |
52 |
53 | MainForm.cs
54 |
55 |
56 |
57 |
58 | MainForm.cs
59 |
60 |
61 | ResXFileCodeGenerator
62 | Resources.Designer.cs
63 | Designer
64 |
65 |
66 | True
67 | Resources.resx
68 |
69 |
70 | SettingsSingleFileGenerator
71 | Settings.Designer.cs
72 |
73 |
74 | True
75 | Settings.settings
76 | True
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | {f7adb621-7426-45c1-8720-5a74651c7262}
85 | Wordy
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/Wordy/Wordy/Effects/CaseEffect.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Wordy.Types;
7 |
8 | namespace Wordy.Effects
9 | {
10 | public class CaseEffect : Effect
11 | {
12 | protected TextCase TextCase { get; private set; }
13 |
14 | public CaseEffect(TextCase textCase) : base()
15 | {
16 | this.TextCase = textCase;
17 | }
18 |
19 | public override string GetFilteredText(string sourceText)
20 | {
21 | switch (this.TextCase)
22 | {
23 | case TextCase.AllUpper:
24 | return this.GetAllUpper(sourceText);
25 | case TextCase.AllLower:
26 | return this.GetAllLower(sourceText);
27 | case TextCase.FirstUpperNextLower:
28 | return this.GetFirstUpperNextLower(sourceText);
29 | case TextCase.FirstLowerNextUpper:
30 | return this.GetFirstLowerNextUpper(sourceText);
31 | case TextCase.AlternatingFirstUpperCase:
32 | return this.GetAlternatingFirstUpperCase(sourceText);
33 | case TextCase.AlternatingFirstLowerCase:
34 | return this.GetAlternatingFirstLowerCase(sourceText);
35 | default:
36 | return string.Copy(sourceText);
37 | }
38 | }
39 |
40 | private string GetAllUpper(string sourceText)
41 | {
42 | return sourceText.ToUpper();
43 | }
44 |
45 | private string GetAllLower(string sourceText)
46 | {
47 | return sourceText.ToLower();
48 | }
49 |
50 | private string GetFirstUpperNextLower(string sourceText)
51 | {
52 | if (string.IsNullOrEmpty(sourceText))
53 | {
54 | return string.Empty;
55 | }
56 | else
57 | {
58 | var firstLetter = sourceText.Substring(0, 1);
59 | var otherText = sourceText.Length > 1 ? sourceText.Substring(1) : string.Empty;
60 | return firstLetter.ToUpper()
61 | + otherText.ToLower();
62 | }
63 | }
64 |
65 | private string GetFirstLowerNextUpper(string sourceText)
66 | {
67 | if (string.IsNullOrEmpty(sourceText))
68 | {
69 | return string.Empty;
70 | }
71 | else
72 | {
73 | var firstLetter = sourceText.Substring(0, 1);
74 | var otherText = sourceText.Length > 1 ? sourceText.Substring(1) : string.Empty;
75 | return firstLetter.ToLower()
76 | + otherText.ToUpper();
77 | }
78 | }
79 |
80 | private string GetAlternating(string sourceText, bool firstSymbolUppercased)
81 | {
82 | var sourceSymbols = sourceText.ToCharArray();
83 | var resultBuilder = new StringBuilder();
84 |
85 | for (int symbolIndex = 0; symbolIndex < sourceSymbols.Length; symbolIndex++)
86 | {
87 | var sourceSymbol = sourceSymbols[symbolIndex];
88 | var isEvenSymbolIndex = symbolIndex % 2 == 0;
89 | var shouldMakeSymbolUppercased = (isEvenSymbolIndex && firstSymbolUppercased)
90 | || (!isEvenSymbolIndex && !firstSymbolUppercased);
91 | var resultSymbol = shouldMakeSymbolUppercased
92 | ? char.ToUpper(sourceSymbol)
93 | : char.ToLower(sourceSymbol);
94 | resultBuilder.Append(resultSymbol);
95 | }
96 |
97 | return resultBuilder.ToString();
98 | }
99 |
100 | private string GetAlternatingFirstUpperCase(string sourceText)
101 | {
102 | return this.GetAlternating(sourceText, true);
103 | }
104 |
105 | private string GetAlternatingFirstLowerCase(string sourceText)
106 | {
107 | return this.GetAlternating(sourceText, false);
108 | }
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/Wordy/Demo/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/Wordy/Demo/MainForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | ## At a Glance
18 |
19 | `Wordy` is a powerful text processor that provides an easy way to manage content in `String` object.
20 |
21 | ## How to Get Started
22 |
23 | Use `NuGet`.
24 |
25 | ## Requirements
26 |
27 | .NET Framework 4.6.1.
28 |
29 | ## Usage
30 |
31 | Everything starts with `UseWordyTo` prefix. This is your entry point to all tools provided by the library.
32 |
33 | ### Text Effects
34 |
35 | Let's start with a very simple example of text effect:
36 |
37 | ```c#
38 | string filteredText = UseWordyTo.MakeEffects("Hi!")
39 | .Apply(new InversionEffect())
40 | .GetResult();
41 |
42 | Console.WriteLine(filteredText); // "!iH"
43 | ```
44 |
45 | This is how it works: `UseWordyTo.MakeEffects(...)` gives you an `EffectManager` instance configured for your source text. Then, you can apply some effects and retrieve the final text by `.GetResult()` call.
46 |
47 | In the example above, the `InversionEffect` will be applied to the entire string. The same time, you can apply effect to a particular substring:
48 |
49 | ```c#
50 | String filteredText = UseWordyTo.MakeEffects("Hi!")
51 | .Apply(new InversionEffect(), 0, 1) // Start index is 0, end index is 1
52 | .GetResult();
53 |
54 | Console.WriteLine(filteredText); // "iH!"
55 | ```
56 |
57 | You can add as many effects as you want:
58 |
59 | ```c#
60 | String filteredText = UseWordyTo.MakeEffects("This text will be rotated")
61 | .Apply(new RotationEffect(TextRotation.Inverted))
62 | .Apply(new InversionEffect())
63 | .GetResult();
64 |
65 | Console.WriteLine(filteredText); // "рǝʇɐʇоɹ ǝq llıм ʇxǝʇ sıɥʇ"
66 | ```
67 |
68 | #### Case Effect
69 |
70 | Represented by `CaseEffect` class. Changes case for the entire text or letters at particular positions.
71 |
72 | Constructor example:
73 |
74 | ```c#
75 | new CaseEffect(TextCase.FirstUpperNextLower)
76 | ```
77 |
78 | [`TextCase`](#text-case) is the only setting that defines `CaseEffect`'s behavior.
79 |
80 | #### Rotation Effect
81 |
82 | Represented by `RotationEffect` class. Rotates letters. For example,
83 |
84 | `p` becomes `d`
85 |
86 | and
87 |
88 | `h` becomes `ɥ`.
89 |
90 | `RotationEffect` has two available constructors. The most detailed version of constructor:
91 |
92 | ```c#
93 | new RotationEffect(TextRotation.Inverted, true)
94 | ```
95 |
96 | The first parameter is a [`TextRotation`](#text-rotation) value that defines the way to rotate symbols.
97 |
98 | The second parameter of boolean type defines whether the rotation alrorithm should be case sensitive. If it equals to `false`, some uppercased symbols might become lowercased as a result of rotation.
99 |
100 | The second constructor is a simplified version of the first one:
101 |
102 | ```c#
103 | new RotationEffect(TextRotation.Inverted)
104 | ```
105 |
106 | It's case sensitive by default. Usually, it's enough to use the second constructor excepting cases when you need more flexibility.
107 |
108 | #### Inversion Effect
109 |
110 | Represented by `InversionEffect` class. Flips text from right to left, so
111 |
112 | `Hi!`
113 |
114 | turns into
115 |
116 | `!iH`
117 |
118 | `InversionEffect`'s constructor is very simple and doesn't require any parameters:
119 |
120 | ```c#
121 | new InversionEffect()
122 | ```
123 |
124 | ### Transliteration
125 |
126 | Example of transliteration:
127 |
128 | ```c#
129 | String transliterated = UseWordyTo.Transliterate
130 | (
131 | Language.Russian, // from Russian
132 | Language.English // to English
133 | ).GetText("Привет!");
134 |
135 | Console.WriteLine(transliterated); // "Privet!", which means "Hi!"
136 | ```
137 |
138 | Currently supported languages are:
139 |
140 | - English
141 | - Russian
142 |
143 | ### Options
144 |
145 | #### Text Case
146 |
147 | `TextCase` is used as a setting for `CaseEffect` instance. Available values are:
148 |
149 | - `AllUpper`: Makes the entire text uppercased.
150 | - `AllLower`: Makes the entire text lowercased.
151 | - `FirstUpperNextLower`: First symbol is uppercased, other text is lowercased.
152 | - `FirstLowerNextUpper`: First symbol is lowercased, other text is uppercased.
153 | - `AlternatingFirstUpperCase`: Odd symbols are uppercased, even symbols are lowercased.
154 | - `AlternatingFirstLowerCase`: Odd symbols are lowercased, even symbols are uppercased.
155 |
156 | #### Text Rotation
157 |
158 | `TextRotation` defines the conditions of symbol rotation. Available values:
159 |
160 | - `Normal`: Forces all symbols to be rotated to normal position. It means that `ʎ` would become `y` and `h` would stay `h`.
161 | - `UpsideDown`: Forces all symbols to be rotated upside down. In this case, `y` would turn into `ʎ`, but `ɥ` wouldn't change at all.
162 | - `Inverted`: Normal symbols are forced to be rotated meanwhile rotated symbols become normal. So, `y` becomes `ʎ` and `ɥ` turns into `h`.
163 |
164 | #### Language
165 |
166 | The `Language` type is used for transliterations. Possible values:
167 |
168 | - `English`
169 | - `Russian`
170 |
171 | ### Plugins
172 |
173 | You can extend the functionality of `Wordy` without making changes to the library. Instead of sending pull request, simply create your own plugin.
174 |
175 | Each plugin is a subclass of the abstract class named `Plugin`. Take a look at the example below:
176 |
177 | ```c#
178 | class Repeat : Plugin
179 | {
180 | public Repeat(string sourceText) : base(sourceText)
181 | {
182 | }
183 |
184 | public override string GetResult()
185 | {
186 | return this.SourceText + this.SourceText;
187 | }
188 | }
189 | ```
190 |
191 | This is a plugin that repeats the source text two times. All that you need to implement is:
192 |
193 | - overrided constructor that takes `sourceText` parameter of `String` type;
194 | - `GetResult()` method that returns `String` with filtered text.
195 |
196 | The core of your plugin's implementation is the `GetResult()` method, inside of which you can implement any logic. To access the source text, simply use `this.SourceText`.
197 |
198 | Now let's try to use the plugin:
199 |
200 | ```c#
201 | String repeatedText = UseWordyTo.IntegratePlugin("Test.")
202 | .GetResult();
203 | Console.WriteLine(repeatedText); // "Test.Test."
204 | ```
205 |
206 | As you can see, creating and using plugins for `Wordy` is quite easy. You can publish your plugins as separate library or send as a pull request if you want it to be included in the library after reviewal process.
207 |
208 | ## License
209 |
210 | `Wordy` is available under the Apache 2.0 license. See the [LICENSE](./LICENSE) file for more info.
211 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015/2017 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # Visual Studio 2017 auto generated files
33 | Generated\ Files/
34 |
35 | # MSTest test Results
36 | [Tt]est[Rr]esult*/
37 | [Bb]uild[Ll]og.*
38 |
39 | # NUNIT
40 | *.VisualState.xml
41 | TestResult.xml
42 |
43 | # Build Results of an ATL Project
44 | [Dd]ebugPS/
45 | [Rr]eleasePS/
46 | dlldata.c
47 |
48 | # Benchmark Results
49 | BenchmarkDotNet.Artifacts/
50 |
51 | # .NET Core
52 | project.lock.json
53 | project.fragment.lock.json
54 | artifacts/
55 | **/Properties/launchSettings.json
56 |
57 | # StyleCop
58 | StyleCopReport.xml
59 |
60 | # Files built by Visual Studio
61 | *_i.c
62 | *_p.c
63 | *_i.h
64 | *.ilk
65 | *.meta
66 | *.obj
67 | *.iobj
68 | *.pch
69 | *.pdb
70 | *.ipdb
71 | *.pgc
72 | *.pgd
73 | *.rsp
74 | *.sbr
75 | *.tlb
76 | *.tli
77 | *.tlh
78 | *.tmp
79 | *.tmp_proj
80 | *.log
81 | *.vspscc
82 | *.vssscc
83 | .builds
84 | *.pidb
85 | *.svclog
86 | *.scc
87 |
88 | # Chutzpah Test files
89 | _Chutzpah*
90 |
91 | # Visual C++ cache files
92 | ipch/
93 | *.aps
94 | *.ncb
95 | *.opendb
96 | *.opensdf
97 | *.sdf
98 | *.cachefile
99 | *.VC.db
100 | *.VC.VC.opendb
101 |
102 | # Visual Studio profiler
103 | *.psess
104 | *.vsp
105 | *.vspx
106 | *.sap
107 |
108 | # Visual Studio Trace Files
109 | *.e2e
110 |
111 | # TFS 2012 Local Workspace
112 | $tf/
113 |
114 | # Guidance Automation Toolkit
115 | *.gpState
116 |
117 | # ReSharper is a .NET coding add-in
118 | _ReSharper*/
119 | *.[Rr]e[Ss]harper
120 | *.DotSettings.user
121 |
122 | # JustCode is a .NET coding add-in
123 | .JustCode
124 |
125 | # TeamCity is a build add-in
126 | _TeamCity*
127 |
128 | # DotCover is a Code Coverage Tool
129 | *.dotCover
130 |
131 | # AxoCover is a Code Coverage Tool
132 | .axoCover/*
133 | !.axoCover/settings.json
134 |
135 | # Visual Studio code coverage results
136 | *.coverage
137 | *.coveragexml
138 |
139 | # NCrunch
140 | _NCrunch_*
141 | .*crunch*.local.xml
142 | nCrunchTemp_*
143 |
144 | # MightyMoose
145 | *.mm.*
146 | AutoTest.Net/
147 |
148 | # Web workbench (sass)
149 | .sass-cache/
150 |
151 | # Installshield output folder
152 | [Ee]xpress/
153 |
154 | # DocProject is a documentation generator add-in
155 | DocProject/buildhelp/
156 | DocProject/Help/*.HxT
157 | DocProject/Help/*.HxC
158 | DocProject/Help/*.hhc
159 | DocProject/Help/*.hhk
160 | DocProject/Help/*.hhp
161 | DocProject/Help/Html2
162 | DocProject/Help/html
163 |
164 | # Click-Once directory
165 | publish/
166 |
167 | # Publish Web Output
168 | *.[Pp]ublish.xml
169 | *.azurePubxml
170 | # Note: Comment the next line if you want to checkin your web deploy settings,
171 | # but database connection strings (with potential passwords) will be unencrypted
172 | *.pubxml
173 | *.publishproj
174 |
175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
176 | # checkin your Azure Web App publish settings, but sensitive information contained
177 | # in these scripts will be unencrypted
178 | PublishScripts/
179 |
180 | # NuGet Packages
181 | *.nupkg
182 | # The packages folder can be ignored because of Package Restore
183 | **/[Pp]ackages/*
184 | # except build/, which is used as an MSBuild target.
185 | !**/[Pp]ackages/build/
186 | # Uncomment if necessary however generally it will be regenerated when needed
187 | #!**/[Pp]ackages/repositories.config
188 | # NuGet v3's project.json files produces more ignorable files
189 | *.nuget.props
190 | *.nuget.targets
191 |
192 | # Microsoft Azure Build Output
193 | csx/
194 | *.build.csdef
195 |
196 | # Microsoft Azure Emulator
197 | ecf/
198 | rcf/
199 |
200 | # Windows Store app package directories and files
201 | AppPackages/
202 | BundleArtifacts/
203 | Package.StoreAssociation.xml
204 | _pkginfo.txt
205 | *.appx
206 |
207 | # Visual Studio cache files
208 | # files ending in .cache can be ignored
209 | *.[Cc]ache
210 | # but keep track of directories ending in .cache
211 | !*.[Cc]ache/
212 |
213 | # Others
214 | ClientBin/
215 | ~$*
216 | *~
217 | *.dbmdl
218 | *.dbproj.schemaview
219 | *.jfm
220 | *.pfx
221 | *.publishsettings
222 | orleans.codegen.cs
223 |
224 | # Including strong name files can present a security risk
225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
226 | #*.snk
227 |
228 | # Since there are multiple workflows, uncomment next line to ignore bower_components
229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
230 | #bower_components/
231 |
232 | # RIA/Silverlight projects
233 | Generated_Code/
234 |
235 | # Backup & report files from converting an old project file
236 | # to a newer Visual Studio version. Backup files are not needed,
237 | # because we have git ;-)
238 | _UpgradeReport_Files/
239 | Backup*/
240 | UpgradeLog*.XML
241 | UpgradeLog*.htm
242 | ServiceFabricBackup/
243 | *.rptproj.bak
244 |
245 | # SQL Server files
246 | *.mdf
247 | *.ldf
248 | *.ndf
249 |
250 | # Business Intelligence projects
251 | *.rdl.data
252 | *.bim.layout
253 | *.bim_*.settings
254 | *.rptproj.rsuser
255 |
256 | # Microsoft Fakes
257 | FakesAssemblies/
258 |
259 | # GhostDoc plugin setting file
260 | *.GhostDoc.xml
261 |
262 | # Node.js Tools for Visual Studio
263 | .ntvs_analysis.dat
264 | node_modules/
265 |
266 | # Visual Studio 6 build log
267 | *.plg
268 |
269 | # Visual Studio 6 workspace options file
270 | *.opt
271 |
272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
273 | *.vbw
274 |
275 | # Visual Studio LightSwitch build output
276 | **/*.HTMLClient/GeneratedArtifacts
277 | **/*.DesktopClient/GeneratedArtifacts
278 | **/*.DesktopClient/ModelManifest.xml
279 | **/*.Server/GeneratedArtifacts
280 | **/*.Server/ModelManifest.xml
281 | _Pvt_Extensions
282 |
283 | # Paket dependency manager
284 | .paket/paket.exe
285 | paket-files/
286 |
287 | # FAKE - F# Make
288 | .fake/
289 |
290 | # JetBrains Rider
291 | .idea/
292 | *.sln.iml
293 |
294 | # CodeRush
295 | .cr/
296 |
297 | # Python Tools for Visual Studio (PTVS)
298 | __pycache__/
299 | *.pyc
300 |
301 | # Cake - Uncomment if you are using it
302 | # tools/**
303 | # !tools/packages.config
304 |
305 | # Tabs Studio
306 | *.tss
307 |
308 | # Telerik's JustMock configuration file
309 | *.jmconfig
310 |
311 | # BizTalk build output
312 | *.btp.cs
313 | *.btm.cs
314 | *.odx.cs
315 | *.xsd.cs
316 |
317 | # OpenCover UI analysis results
318 | OpenCover/
319 |
320 | # Azure Stream Analytics local run output
321 | ASALocalRun/
322 |
323 | # MSBuild Binary and Structured Log
324 | *.binlog
325 |
326 | # NVidia Nsight GPU debugger configuration file
327 | *.nvuser
328 |
329 | # MFractors (Xamarin productivity tool) working folder
330 | .mfractor/
331 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/Wordy/Wordy/Data/Rotation/RotationStore.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Wordy.Data.Rotation
8 | {
9 | internal class RotationStore
10 | {
11 | protected TextRotationRule[] Rules { get; private set; }
12 |
13 | public int Count
14 | {
15 | get
16 | {
17 | return this.Rules.Length;
18 | }
19 | }
20 |
21 | public TextRotationRule this[int index]
22 | {
23 | get
24 | {
25 | return this.Rules[index];
26 | }
27 | }
28 |
29 | public RotationStore()
30 | {
31 | var mergedRules = new List();
32 | mergedRules.AddRange(this.GenerateRulesForEnglish());
33 | mergedRules.AddRange(this.GenerateRulesForRussian());
34 | mergedRules.AddRange(this.GenerateRulesForSigns());
35 |
36 | this.Rules = mergedRules.ToArray();
37 | }
38 |
39 | private TextRotationRule[] GenerateRulesForEnglish()
40 | {
41 | return new TextRotationRule[]
42 | {
43 | new TextRotationRule.Builder()
44 | .SetNormal("a")
45 | .SetRotated("ɐ")
46 | .Build(),
47 | new TextRotationRule.Builder()
48 | .SetNormal("b")
49 | .SetRotated("q")
50 | .Build(),
51 | new TextRotationRule.Builder()
52 | .SetNormal("c")
53 | .SetRotated("ɔ")
54 | .Build(),
55 | new TextRotationRule.Builder()
56 | .SetNormal("d")
57 | .SetRotated("р")
58 | .Build(),
59 | new TextRotationRule.Builder()
60 | .SetNormal("e")
61 | .SetRotated("ǝ")
62 | .Build(),
63 | new TextRotationRule.Builder()
64 | .SetNormal("f")
65 | .SetRotated("ɟ")
66 | .Build(),
67 | new TextRotationRule.Builder()
68 | .SetNormal("g")
69 | .SetRotated("ƃ")
70 | .Build(),
71 | new TextRotationRule.Builder()
72 | .SetNormal("h")
73 | .SetRotated("ɥ")
74 | .Build(),
75 | new TextRotationRule.Builder()
76 | .SetNormal("i")
77 | .SetRotated("ı")
78 | .Build(),
79 | new TextRotationRule.Builder()
80 | .SetNormal("j")
81 | .SetRotated("ɾ")
82 | .Build(),
83 | new TextRotationRule.Builder()
84 | .SetNormal("k")
85 | .SetRotated("ʞ")
86 | .Build(),
87 | new TextRotationRule.Builder()
88 | .SetNormal("l")
89 | .SetRotated("l")
90 | .Build(),
91 | new TextRotationRule.Builder()
92 | .SetNormal("m")
93 | .SetRotated("ш")
94 | .Build(),
95 | new TextRotationRule.Builder()
96 | .SetNormal("n")
97 | .SetRotated("u")
98 | .Build(),
99 | new TextRotationRule.Builder()
100 | .SetNormal("o")
101 | .SetRotated("о")
102 | .Build(),
103 | new TextRotationRule.Builder()
104 | .SetNormal("p")
105 | .SetRotated("d")
106 | .Build(),
107 | new TextRotationRule.Builder()
108 | .SetNormal("q")
109 | .SetRotated("ь")
110 | .Build(),
111 | new TextRotationRule.Builder()
112 | .SetNormal("r")
113 | .SetRotated("ɹ")
114 | .Build(),
115 | new TextRotationRule.Builder()
116 | .SetNormal("s")
117 | .SetRotated("s")
118 | .Build(),
119 | new TextRotationRule.Builder()
120 | .SetNormal("t")
121 | .SetRotated("ʇ")
122 | .Build(),
123 | new TextRotationRule.Builder()
124 | .SetNormal("u")
125 | .SetRotated("п")
126 | .Build(),
127 | new TextRotationRule.Builder()
128 | .SetNormal("v")
129 | .SetRotated("л")
130 | .Build(),
131 | new TextRotationRule.Builder()
132 | .SetNormal("w")
133 | .SetRotated("м")
134 | .Build(),
135 | new TextRotationRule.Builder()
136 | .SetNormal("x")
137 | .SetRotated("x")
138 | .Build(),
139 | new TextRotationRule.Builder()
140 | .SetNormal("y")
141 | .SetRotated("ʎ")
142 | .Build(),
143 | new TextRotationRule.Builder()
144 | .SetNormal("z")
145 | .SetRotated("z")
146 | .Build()
147 | };
148 | }
149 |
150 | private TextRotationRule[] GenerateRulesForRussian()
151 | {
152 | return new TextRotationRule[]
153 | {
154 | new TextRotationRule.Builder()
155 | .SetNormal("а")
156 | .SetRotated("ɐ")
157 | .Build(),
158 | new TextRotationRule.Builder()
159 | .SetNormal("б")
160 | .SetRotated("ƍ")
161 | .Build(),
162 | new TextRotationRule.Builder()
163 | .SetNormal("в")
164 | .SetRotated("ʚ")
165 | .Build(),
166 | new TextRotationRule.Builder()
167 | .SetNormal("г")
168 | .SetRotated("ɹ")
169 | .Build(),
170 | new TextRotationRule.Builder()
171 | .SetNormal("д")
172 | .SetRotated("ɓ")
173 | .Build(),
174 | new TextRotationRule.Builder()
175 | .SetNormal("е")
176 | .SetRotated("ǝ")
177 | .Build(),
178 | new TextRotationRule.Builder()
179 | .SetNormal("ё")
180 | .SetRotated("ǝ̤")
181 | .Build(),
182 | new TextRotationRule.Builder()
183 | .SetNormal("ж")
184 | .SetRotated("ж")
185 | .Build(),
186 | new TextRotationRule.Builder()
187 | .SetNormal("з")
188 | .SetRotated("ε")
189 | .Build(),
190 | new TextRotationRule.Builder()
191 | .SetNormal("и")
192 | .SetRotated("и")
193 | .Build(),
194 | new TextRotationRule.Builder()
195 | .SetNormal("й")
196 | .SetRotated("n̯")
197 | .Build(),
198 | new TextRotationRule.Builder()
199 | .SetNormal("к")
200 | .SetRotated("ʞ")
201 | .Build(),
202 | new TextRotationRule.Builder()
203 | .SetNormal("л")
204 | .SetRotated("v")
205 | .Build(),
206 | new TextRotationRule.Builder()
207 | .SetNormal("м")
208 | .SetRotated("w")
209 | .Build(),
210 | new TextRotationRule.Builder()
211 | .SetNormal("н")
212 | .SetRotated("н")
213 | .Build(),
214 | new TextRotationRule.Builder()
215 | .SetNormal("о")
216 | .SetRotated("o")
217 | .Build(),
218 | new TextRotationRule.Builder()
219 | .SetNormal("п")
220 | .SetRotated("u")
221 | .Build(),
222 | new TextRotationRule.Builder()
223 | .SetNormal("р")
224 | .SetRotated("d")
225 | .Build(),
226 | new TextRotationRule.Builder()
227 | .SetNormal("с")
228 | .SetRotated("ɔ")
229 | .Build(),
230 | new TextRotationRule.Builder()
231 | .SetNormal("т")
232 | .SetRotated("ɯ")
233 | .Build(),
234 | new TextRotationRule.Builder()
235 | .SetNormal("у")
236 | .SetRotated("ʎ")
237 | .Build(),
238 | new TextRotationRule.Builder()
239 | .SetNormal("ф")
240 | .SetRotated("ȸ")
241 | .Build(),
242 | new TextRotationRule.Builder()
243 | .SetNormal("х")
244 | .SetRotated("х")
245 | .Build(),
246 | new TextRotationRule.Builder()
247 | .SetNormal("ц")
248 | .SetRotated("ǹ")
249 | .Build(),
250 | new TextRotationRule.Builder()
251 | .SetNormal("ч")
252 | .SetRotated("Һ")
253 | .Build(),
254 | new TextRotationRule.Builder()
255 | .SetNormal("ш")
256 | .SetRotated("m")
257 | .Build(),
258 | new TextRotationRule.Builder()
259 | .SetNormal("щ")
260 | .SetRotated("m")
261 | .Build(),
262 | new TextRotationRule.Builder()
263 | .SetNormal("ъ")
264 | .SetRotated("q")
265 | .Build(),
266 | new TextRotationRule.Builder()
267 | .SetNormal("ы")
268 | .SetRotated("ıq")
269 | .Build(),
270 | new TextRotationRule.Builder()
271 | .SetNormal("ь")
272 | .SetRotated("q")
273 | .Build(),
274 | new TextRotationRule.Builder()
275 | .SetNormal("э")
276 | .SetRotated("є")
277 | .Build(),
278 | new TextRotationRule.Builder()
279 | .SetNormal("ю")
280 | .SetRotated("oı")
281 | .Build(),
282 | new TextRotationRule.Builder()
283 | .SetNormal("я")
284 | .SetRotated("ʁ")
285 | .Build()
286 | };
287 | }
288 |
289 | private TextRotationRule[] GenerateRulesForSigns()
290 | {
291 | return new TextRotationRule[]
292 | {
293 | new TextRotationRule.Builder()
294 | .SetNormal(".")
295 | .SetRotated("˙")
296 | .Build(),
297 | new TextRotationRule.Builder()
298 | .SetNormal(",")
299 | .SetRotated("‘")
300 | .Build(),
301 | new TextRotationRule.Builder()
302 | .SetNormal("'")
303 | .SetRotated(",")
304 | .Build(),
305 | new TextRotationRule.Builder()
306 | .SetNormal("!")
307 | .SetRotated("¡")
308 | .Build(),
309 | new TextRotationRule.Builder()
310 | .SetNormal("?")
311 | .SetRotated("¿")
312 | .Build(),
313 | new TextRotationRule.Builder()
314 | .SetNormal("/")
315 | .SetRotated("/")
316 | .Build(),
317 | new TextRotationRule.Builder()
318 | .SetNormal("\\")
319 | .SetRotated("\\")
320 | .Build(),
321 | new TextRotationRule.Builder()
322 | .SetNormal("<")
323 | .SetRotated(">")
324 | .Build(),
325 | new TextRotationRule.Builder()
326 | .SetNormal(">")
327 | .SetRotated("<")
328 | .Build(),
329 | new TextRotationRule.Builder()
330 | .SetNormal("(")
331 | .SetRotated(")")
332 | .Build(),
333 | new TextRotationRule.Builder()
334 | .SetNormal(")")
335 | .SetRotated("(")
336 | .Build(),
337 | new TextRotationRule.Builder()
338 | .SetNormal("[")
339 | .SetRotated("]")
340 | .Build(),
341 | new TextRotationRule.Builder()
342 | .SetNormal("]")
343 | .SetRotated("[")
344 | .Build()
345 | };
346 | }
347 | }
348 | }
349 |
--------------------------------------------------------------------------------
/Wordy/Wordy/Data/Transliteration/TransliterationStore.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Wordy.Types;
7 |
8 | namespace Wordy.Data.Transliteration
9 | {
10 | internal class TransliterationStore
11 | {
12 | private static TransliterationRule[] EnglishToRussianRules = new TransliterationRule[]
13 | {
14 |
15 | // 5 letters
16 | new TransliterationRule.Builder()
17 | .SetReplaceable("aught")
18 | .SetReplacement("от")
19 | .Build(),
20 |
21 | // 4 letters
22 | new TransliterationRule.Builder()
23 | .SetReplaceable("ould")
24 | .SetReplacement("уд")
25 | .Build(),
26 | new TransliterationRule.Builder()
27 | .SetReplaceable("ound")
28 | .SetReplacement("аунд")
29 | .Build(),
30 | new TransliterationRule.Builder()
31 | .SetReplaceable("eigh")
32 | .SetReplacement("эй")
33 | .Build(),
34 |
35 | // 3 letters
36 | new TransliterationRule.Builder()
37 | .SetReplaceable("igh")
38 | .SetReplacement("ай")
39 | .Build(),
40 | new TransliterationRule.Builder()
41 | .SetReplaceable("eer")
42 | .SetReplacement("иа")
43 | .Build(),
44 | new TransliterationRule.Builder()
45 | .SetReplaceable("our")
46 | .SetReplacement("ауэ")
47 | .Build(),
48 | new TransliterationRule.Builder()
49 | .SetReplaceable("oor")
50 | .SetReplacement("о")
51 | .Build(),
52 | new TransliterationRule.Builder()
53 | .SetReplaceable("wor")
54 | .SetReplacement("ё")
55 | .Build(),
56 | new TransliterationRule.Builder()
57 | .SetReplaceable("air")
58 | .SetReplacement("эа")
59 | .Build(),
60 | new TransliterationRule.Builder()
61 | .SetReplaceable("oar")
62 | .SetReplacement("о")
63 | .Build(),
64 |
65 | // 2 letters
66 | new TransliterationRule.Builder()
67 | .SetReplaceable("ee")
68 | .SetReplacement("и")
69 | .Build(),
70 | new TransliterationRule.Builder()
71 | .SetReplaceable("ea")
72 | .SetReplacement("и")
73 | .Build(),
74 | new TransliterationRule.Builder()
75 | .SetReplaceable("oo")
76 | .SetReplacement("у")
77 | .Build(),
78 | new TransliterationRule.Builder()
79 | .SetReplaceable("th")
80 | .SetReplacement("т")
81 | .Build(),
82 | new TransliterationRule.Builder()
83 | .SetReplaceable("sh")
84 | .SetReplacement("ш")
85 | .Build(),
86 | new TransliterationRule.Builder()
87 | .SetReplaceable("ch")
88 | .SetReplacement("ч")
89 | .Build(),
90 | new TransliterationRule.Builder()
91 | .SetReplaceable("ph")
92 | .SetReplacement("ф")
93 | .Build(),
94 | new TransliterationRule.Builder()
95 | .SetReplaceable("ck")
96 | .SetReplacement("к")
97 | .Build(),
98 | new TransliterationRule.Builder()
99 | .SetReplaceable("ng")
100 | .SetReplacement("нг")
101 | .Build(),
102 | new TransliterationRule.Builder()
103 | .SetReplaceable("wh")
104 | .SetReplacement("в")
105 | .Build(),
106 | new TransliterationRule.Builder()
107 | .SetReplaceable("wr")
108 | .SetReplacement("р")
109 | .Build(),
110 | new TransliterationRule.Builder()
111 | .SetReplaceable("qu")
112 | .SetReplacement("кв")
113 | .Build(),
114 | new TransliterationRule.Builder()
115 | .SetReplaceable("all")
116 | .SetReplacement("ол")
117 | .Build(),
118 | new TransliterationRule.Builder()
119 | .SetReplaceable("ai")
120 | .SetReplacement("эй")
121 | .Build(),
122 | new TransliterationRule.Builder()
123 | .SetReplaceable("ay")
124 | .SetReplacement("эй")
125 | .Build(),
126 | new TransliterationRule.Builder()
127 | .SetReplaceable("oi")
128 | .SetReplacement("ой")
129 | .Build(),
130 | new TransliterationRule.Builder()
131 | .SetReplaceable("oy")
132 | .SetReplacement("ой")
133 | .Build(),
134 | new TransliterationRule.Builder()
135 | .SetReplaceable("ow")
136 | .SetReplacement("оу")
137 | .Build(),
138 | new TransliterationRule.Builder()
139 | .SetReplaceable("ou")
140 | .SetReplacement("оу")
141 | .Build(),
142 | new TransliterationRule.Builder()
143 | .SetReplaceable("ew")
144 | .SetReplacement("ю")
145 | .Build(),
146 | new TransliterationRule.Builder()
147 | .SetReplaceable("aw")
148 | .SetReplacement("о")
149 | .Build(),
150 | new TransliterationRule.Builder()
151 | .SetReplaceable("wa")
152 | .SetReplacement("во")
153 | .Build(),
154 | new TransliterationRule.Builder()
155 | .SetReplaceable("au")
156 | .SetReplacement("о")
157 | .Build(),
158 | new TransliterationRule.Builder()
159 | .SetReplaceable("gh")
160 | .SetReplacement("ф")
161 | .Build(),
162 |
163 | // 1 letter
164 | new TransliterationRule.Builder()
165 | .SetReplaceable("a")
166 | .SetReplacement("э")
167 | .Build(),
168 | new TransliterationRule.Builder()
169 | .SetReplaceable("b")
170 | .SetReplacement("б")
171 | .Build(),
172 | new TransliterationRule.Builder()
173 | .SetReplaceable("c")
174 | .SetReplacement("к")
175 | .Build(),
176 | new TransliterationRule.Builder()
177 | .SetReplaceable("d")
178 | .SetReplacement("д")
179 | .Build(),
180 | new TransliterationRule.Builder()
181 | .SetReplaceable("e")
182 | .SetReplacement("э")
183 | .Build(),
184 | new TransliterationRule.Builder()
185 | .SetReplaceable("f")
186 | .SetReplacement("ф")
187 | .Build(),
188 | new TransliterationRule.Builder()
189 | .SetReplaceable("g")
190 | .SetReplacement("г")
191 | .Build(),
192 | new TransliterationRule.Builder()
193 | .SetReplaceable("h")
194 | .SetReplacement("х")
195 | .Build(),
196 | new TransliterationRule.Builder()
197 | .SetReplaceable("i")
198 | .SetReplacement("и")
199 | .Build(),
200 | new TransliterationRule.Builder()
201 | .SetReplaceable("j")
202 | .SetReplacement("дж")
203 | .Build(),
204 | new TransliterationRule.Builder()
205 | .SetReplaceable("k")
206 | .SetReplacement("к")
207 | .Build(),
208 | new TransliterationRule.Builder()
209 | .SetReplaceable("l")
210 | .SetReplacement("л")
211 | .Build(),
212 | new TransliterationRule.Builder()
213 | .SetReplaceable("m")
214 | .SetReplacement("м")
215 | .Build(),
216 | new TransliterationRule.Builder()
217 | .SetReplaceable("n")
218 | .SetReplacement("н")
219 | .Build(),
220 | new TransliterationRule.Builder()
221 | .SetReplaceable("o")
222 | .SetReplacement("о")
223 | .Build(),
224 | new TransliterationRule.Builder()
225 | .SetReplaceable("p")
226 | .SetReplacement("п")
227 | .Build(),
228 | new TransliterationRule.Builder()
229 | .SetReplaceable("r")
230 | .SetReplacement("р")
231 | .Build(),
232 | new TransliterationRule.Builder()
233 | .SetReplaceable("s")
234 | .SetReplacement("с")
235 | .Build(),
236 | new TransliterationRule.Builder()
237 | .SetReplaceable("t")
238 | .SetReplacement("т")
239 | .Build(),
240 | new TransliterationRule.Builder()
241 | .SetReplaceable("u")
242 | .SetReplacement("а")
243 | .Build(),
244 | new TransliterationRule.Builder()
245 | .SetReplaceable("v")
246 | .SetReplacement("в")
247 | .Build(),
248 | new TransliterationRule.Builder()
249 | .SetReplaceable("w")
250 | .SetReplacement("в")
251 | .Build(),
252 | new TransliterationRule.Builder()
253 | .SetReplaceable("x")
254 | .SetReplacement("кс")
255 | .Build(),
256 | new TransliterationRule.Builder()
257 | .SetReplaceable("y")
258 | .SetReplacement("и")
259 | .Build(),
260 | new TransliterationRule.Builder()
261 | .SetReplaceable("z")
262 | .SetReplacement("з")
263 | .Build()
264 |
265 | };
266 |
267 | private static TransliterationRule[] RussianToEnglishRules = new TransliterationRule[]
268 | {
269 |
270 | // 1 letter
271 | new TransliterationRule.Builder()
272 | .SetReplaceable("а")
273 | .SetReplacement("a")
274 | .Build(),
275 | new TransliterationRule.Builder()
276 | .SetReplaceable("б")
277 | .SetReplacement("b")
278 | .Build(),
279 | new TransliterationRule.Builder()
280 | .SetReplaceable("в")
281 | .SetReplacement("v")
282 | .Build(),
283 | new TransliterationRule.Builder()
284 | .SetReplaceable("г")
285 | .SetReplacement("g")
286 | .Build(),
287 | new TransliterationRule.Builder()
288 | .SetReplaceable("д")
289 | .SetReplacement("d")
290 | .Build(),
291 | new TransliterationRule.Builder()
292 | .SetReplaceable("е")
293 | .SetReplacement("e")
294 | .Build(),
295 | new TransliterationRule.Builder()
296 | .SetReplaceable("ё")
297 | .SetReplacement("yo")
298 | .Build(),
299 | new TransliterationRule.Builder()
300 | .SetReplaceable("ж")
301 | .SetReplacement("zh")
302 | .Build(),
303 | new TransliterationRule.Builder()
304 | .SetReplaceable("з")
305 | .SetReplacement("z")
306 | .Build(),
307 | new TransliterationRule.Builder()
308 | .SetReplaceable("и")
309 | .SetReplacement("i")
310 | .Build(),
311 | new TransliterationRule.Builder()
312 | .SetReplaceable("й")
313 | .SetReplacement("y")
314 | .Build(),
315 | new TransliterationRule.Builder()
316 | .SetReplaceable("к")
317 | .SetReplacement("k")
318 | .Build(),
319 | new TransliterationRule.Builder()
320 | .SetReplaceable("л")
321 | .SetReplacement("l")
322 | .Build(),
323 | new TransliterationRule.Builder()
324 | .SetReplaceable("м")
325 | .SetReplacement("m")
326 | .Build(),
327 | new TransliterationRule.Builder()
328 | .SetReplaceable("н")
329 | .SetReplacement("n")
330 | .Build(),
331 | new TransliterationRule.Builder()
332 | .SetReplaceable("о")
333 | .SetReplacement("o")
334 | .Build(),
335 | new TransliterationRule.Builder()
336 | .SetReplaceable("п")
337 | .SetReplacement("p")
338 | .Build(),
339 | new TransliterationRule.Builder()
340 | .SetReplaceable("р")
341 | .SetReplacement("r")
342 | .Build(),
343 | new TransliterationRule.Builder()
344 | .SetReplaceable("с")
345 | .SetReplacement("s")
346 | .Build(),
347 | new TransliterationRule.Builder()
348 | .SetReplaceable("т")
349 | .SetReplacement("t")
350 | .Build(),
351 | new TransliterationRule.Builder()
352 | .SetReplaceable("у")
353 | .SetReplacement("u")
354 | .Build(),
355 | new TransliterationRule.Builder()
356 | .SetReplaceable("ф")
357 | .SetReplacement("f")
358 | .Build(),
359 | new TransliterationRule.Builder()
360 | .SetReplaceable("х")
361 | .SetReplacement("kh")
362 | .Build(),
363 | new TransliterationRule.Builder()
364 | .SetReplaceable("ц")
365 | .SetReplacement("ts")
366 | .Build(),
367 | new TransliterationRule.Builder()
368 | .SetReplaceable("ч")
369 | .SetReplacement("ch")
370 | .Build(),
371 | new TransliterationRule.Builder()
372 | .SetReplaceable("ш")
373 | .SetReplacement("sh")
374 | .Build(),
375 | new TransliterationRule.Builder()
376 | .SetReplaceable("щ")
377 | .SetReplacement("sch")
378 | .Build(),
379 | new TransliterationRule.Builder()
380 | .SetReplaceable("ъ")
381 | .SetReplacement("")
382 | .Build(),
383 | new TransliterationRule.Builder()
384 | .SetReplaceable("ы")
385 | .SetReplacement("y")
386 | .Build(),
387 | new TransliterationRule.Builder()
388 | .SetReplaceable("ь")
389 | .SetReplacement("'")
390 | .Build(),
391 | new TransliterationRule.Builder()
392 | .SetReplaceable("э")
393 | .SetReplacement("e")
394 | .Build(),
395 | new TransliterationRule.Builder()
396 | .SetReplaceable("ю")
397 | .SetReplacement("yu")
398 | .Build(),
399 | new TransliterationRule.Builder()
400 | .SetReplaceable("я")
401 | .SetReplacement("ya")
402 | .Build()
403 |
404 | };
405 |
406 | public TransliterationStore()
407 | {
408 | }
409 |
410 | public TransliterationRule[] GetRules(Language sourceLanguage, Language targetLanguage)
411 | {
412 | switch (sourceLanguage)
413 | {
414 | case Language.English:
415 | switch (targetLanguage)
416 | {
417 | case Language.English:
418 | return new TransliterationRule[] { };
419 | case Language.Russian:
420 | return EnglishToRussianRules;
421 | default:
422 | return new TransliterationRule[] { };
423 | }
424 | case Language.Russian:
425 | switch (targetLanguage)
426 | {
427 | case Language.English:
428 | return RussianToEnglishRules;
429 | case Language.Russian:
430 | return new TransliterationRule[] { };
431 | default:
432 | return new TransliterationRule[] { };
433 | }
434 | default:
435 | return new TransliterationRule[] { };
436 | }
437 | }
438 | }
439 | }
440 |
--------------------------------------------------------------------------------