Skip to content

Commit 3b767ce

Browse files
Merge branch 'add-normalization'
2 parents 2ed2456 + 49af911 commit 3b767ce

File tree

11 files changed

+118
-134
lines changed

11 files changed

+118
-134
lines changed

dist/knayi-myscript.es.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/knayi-myscript.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/knayi-myscript.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/knayi-myscript.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/knayi-myscript.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

Lines changed: 103 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@
4242
display: block;
4343
font-size: 13px;
4444
}
45-
/*.debug_content pre.code {
46-
display: block;
47-
padding: 5px;
48-
font-size: 13px;
49-
}*/
5045
.debug_content code {
5146
display: block;
5247
font-size: 13px;
@@ -59,102 +54,98 @@
5954
</head>
6055
<body>
6156
<div id="app">
62-
<!-- <section class="hero"> -->
63-
<!-- <div class="hero-body"> -->
64-
<div class="container">
65-
<div class="columns">
66-
<div class="column">
67-
<h1 class="title logo">
68-
knayi
69-
<a class="github" href="https://github.com/greenlikeorange/knayi-myscript"></a>
70-
</h1>
71-
<h2 class="subtitle">Myanmar langauge js library</h2>
72-
</div>
73-
<div class="column">
74-
<p class="badges" style="text-align: right;">
75-
<br />
76-
<a href="https://npmjs.org/package/knayi-myscript">
77-
<img src="https://badge.fury.io/js/knayi-myscript.png" alt=""></a>
78-
<a href="#">
79-
<img src="https://api.travis-ci.org/greenlikeorange/knayi-myscript.svg?branch=master" alt=""></a>
80-
<a href="https://david-dm.org/greenlikeorange/knayi-myscript">
81-
<img src="https://david-dm.org/greenlikeorange/knayi-myscript.png" alt=""></a>
82-
</p>
57+
<div class="container">
58+
<div class="columns">
59+
<div class="column">
60+
<h1 class="title logo">
61+
knayi
62+
<a class="github" href="https://github.com/greenlikeorange/knayi-myscript"></a>
63+
</h1>
64+
<h2 class="subtitle">Myanmar langauge js library</h2>
65+
</div>
66+
<div class="column">
67+
<p class="badges" style="text-align: right;">
68+
<br />
69+
<a href="https://npmjs.org/package/knayi-myscript">
70+
<img src="https://badge.fury.io/js/knayi-myscript.png" alt=""></a>
71+
<a href="#">
72+
<img src="https://api.travis-ci.org/greenlikeorange/knayi-myscript.svg?branch=master" alt=""></a>
73+
<a href="https://david-dm.org/greenlikeorange/knayi-myscript">
74+
<img src="https://david-dm.org/greenlikeorange/knayi-myscript.png" alt=""></a>
75+
</p>
76+
</div>
77+
</div>
78+
79+
<div class="tabs">
80+
<ul>
81+
<li data-view="converting" class="view-tab is-active"><a>Font Converting</a></li>
82+
<li data-view="normalization" class="view-tab" ><a>Normalization</a></li>
83+
</ul>
84+
</div>
85+
<div id="converting_view" class="columns view">
86+
<div class="column">
87+
<div class="field">
88+
<label class="label">Unicode</label>
89+
<div class="control">
90+
<textarea
91+
id="convert_unicode_text"
92+
class="textarea is-hovered notosansmyanmar convert_input"
93+
data-font-type="unicode"
94+
type="text">သီဟိုဠ်မှ ဉာဏ်ကြီးရှင်သည် အာယုဝဍ်ဎနဆေးညွှန်းစာကို ဇလွန်ဈေးဘေးဗာဒံပင်ထက် အဓိဋ္ဌာန်လျက် ဂဃနဏဖတ်ခဲ့သည်။ယေဓမ္မာ ဟေတုပ္ပဘဝါ တေသံ ဟေတုံ တထာဂတော အာဟ တေသဉ္စ ယောနိရောဓေါ ဧဝံ ဝါဒီ မဟာသမဏော။(မြန်မာပြန်)မြတ်စွာဘုရားရှင်သည် ရှေးကပြုခဲ့ဖူးသော အကြောင်းတရားကြောင့် ဖြစ်ပေါ်လာကြသော အကျိုးတရားကို ဟောကြားတော်မူသည်။ထိုအကြောင်းတရားတို့၏ ချုပ်ငြိမ်းရာတရားတို့ကိုလည်း ဟောတော်မူ၏။ရဟန်းကြီးဖြစ်သော ဗုဒ္ဓမြတ်စွာဘုရားသည် ဤသို့သောအယူရှိတော်မူ၏။</textarea>
8395
</div>
8496
</div>
85-
86-
<div class="tabs">
87-
<ul>
88-
<li data-view="converting" class="view-tab is-active"><a>Font Converting</a></li>
89-
<li data-view="normalization" class="view-tab" ><a>Normalization</a></li>
90-
</ul>
91-
</div>
92-
<div id="converting_view" class="columns view">
93-
<div class="column">
94-
<div class="field">
95-
<label class="label">Unicode</label>
96-
<div class="control">
97-
<textarea
98-
id="convert_unicode_text"
99-
class="textarea is-hovered notosansmyanmar convert_input"
100-
data-font-type="unicode"
101-
type="text">သီဟိုဠ်မှ ဉာဏ်ကြီးရှင်သည် အာယုဝဍ်ဎနဆေးညွှန်းစာကို ဇလွန်ဈေးဘေးဗာဒံပင်ထက် အဓိဋ္ဌာန်လျက် ဂဃနဏဖတ်ခဲ့သည်။ယေဓမ္မာ ဟေတုပ္ပဘဝါ တေသံ ဟေတုံ တထာဂတော အာဟ တေသဉ္စ ယောနိရောဓေါ ဧဝံ ဝါဒီ မဟာသမဏော။(မြန်မာပြန်)မြတ်စွာဘုရားရှင်သည် ရှေးကပြုခဲ့ဖူးသော အကြောင်းတရားကြောင့် ဖြစ်ပေါ်လာကြသော အကျိုးတရားကို ဟောကြားတော်မူသည်။ထိုအကြောင်းတရားတို့၏ ချုပ်ငြိမ်းရာတရားတို့ကိုလည်း ဟောတော်မူ၏။ရဟန်းကြီးဖြစ်သော ဗုဒ္ဓမြတ်စွာဘုရားသည် ဤသို့သောအယူရှိတော်မူ၏။</textarea>
102-
</div>
103-
</div>
104-
</div>
105-
<div class="column">
106-
<div class="field">
107-
<label class="label">Zawgyi</label>
108-
<div class="control">
109-
<textarea
110-
id="convert_zawgyi_text"
111-
class="textarea is-hovered zawgyi convert_input"
112-
data-font-type="zawgyi"
113-
type="text">သီဟိုဠ္မွ ဉာဏ္ႀကီးရွင္သည္ အာယုဝဍ္ဎနေဆးညႊန္းစာကို ဇလြန္ေဈးေဘးဗာဒံပင္ထက္ အဓိ႒ာန္လ်က္ ဂဃနဏဖတ္ခဲ့သည္။ေယဓမၼာ ေဟတုပၸဘဝါ ေတသံ ေဟတုံ တထာဂေတာ အာဟ ေတသၪၥ ေယာနိေရာေဓါ ဧဝံ ဝါဒီ မဟာသမေဏာ။(ျမန္မာျပန္)ျမတ္စြာဘုရားရွင္သည္ ေရွးကျပဳခဲ့ဖူးေသာ အေၾကာင္းတရားေၾကာင့္ ျဖစ္ေပၚလာၾကေသာ အက်ိဳးတရားကို ေဟာၾကားေတာ္မူသည္။ထိုအေၾကာင္းတရားတို့၏ ခ်ဳပ္ၿငိမ္းရာတရားတို့ကိုလည္း ေဟာေတာ္မူ၏။ရဟန္းႀကီးျဖစ္ေသာ ဗုဒၶျမတ္စြာဘုရားသည္ ဤသို့ေသာအယူရွိေတာ္မူ၏။</textarea>
114-
</div>
115-
</div>
97+
</div>
98+
<div class="column">
99+
<div class="field">
100+
<label class="label">Zawgyi</label>
101+
<div class="control">
102+
<textarea
103+
id="convert_zawgyi_text"
104+
class="textarea is-hovered zawgyi convert_input"
105+
data-font-type="zawgyi"
106+
type="text">သီဟိုဠ္မွ ဉာဏ္ႀကီးရွင္သည္ အာယုဝဍ္ဎနေဆးညႊန္းစာကို ဇလြန္ေဈးေဘးဗာဒံပင္ထက္ အဓိ႒ာန္လ်က္ ဂဃနဏဖတ္ခဲ့သည္။ေယဓမၼာ ေဟတုပၸဘဝါ ေတသံ ေဟတုံ တထာဂေတာ အာဟ ေတသၪၥ ေယာနိေရာေဓါ ဧဝံ ဝါဒီ မဟာသမေဏာ။(ျမန္မာျပန္)ျမတ္စြာဘုရားရွင္သည္ ေရွးကျပဳခဲ့ဖူးေသာ အေၾကာင္းတရားေၾကာင့္ ျဖစ္ေပၚလာၾကေသာ အက်ိဳးတရားကို ေဟာၾကားေတာ္မူသည္။ထိုအေၾကာင္းတရားတို့၏ ခ်ဳပ္ၿငိမ္းရာတရားတို့ကိုလည္း ေဟာေတာ္မူ၏။ရဟန္းႀကီးျဖစ္ေသာ ဗုဒၶျမတ္စြာဘုရားသည္ ဤသို့ေသာအယူရွိေတာ္မူ၏။</textarea>
116107
</div>
117108
</div>
118-
119-
<div id="normalization_view" class="columns hide view">
120-
<div class="column">
121-
<div class="field">
122-
<label class="label">Input</label>
123-
<div class="control">
124-
<textarea
125-
id="normalization_input"
126-
class="textarea is-hovered notosansmyanmar"
127-
type="text"></textarea>
128-
</div>
129-
</div>
109+
</div>
110+
</div>
111+
112+
<div id="normalization_view" class="columns hide view">
113+
<div class="column">
114+
<div class="field">
115+
<label class="label">Input</label>
116+
<div class="control">
117+
<textarea
118+
id="normalization_input"
119+
class="textarea is-hovered notosansmyanmar"
120+
type="text"></textarea>
130121
</div>
131-
<div class="column">
132-
<div class="field">
133-
<label class="label">Output</label>
134-
<div class="control">
135-
<textarea
136-
id="normalization_output"
137-
class="textarea is-hovered notosansmyanmar"
138-
disabled="disabled"
139-
type="text"></textarea>
140-
</div>
141-
</div>
122+
</div>
123+
</div>
124+
<div class="column">
125+
<div class="field">
126+
<label class="label">Output</label>
127+
<div class="control">
128+
<textarea
129+
id="normalization_output"
130+
class="textarea is-hovered notosansmyanmar"
131+
disabled="disabled"
132+
type="text"></textarea>
142133
</div>
143134
</div>
135+
</div>
136+
</div>
144137

145-
<div id="debugging">
146-
<div class="content">
147-
<h4>Debuging</h4>
148-
</div>
149-
<div class="columns">
150-
<div class="column">
151-
<pre id="debug_content" class="content debug_content"></pre>
152-
</div>
153-
</div>
138+
<div id="debugging">
139+
<div class="content">
140+
<h4>Debuging</h4>
141+
</div>
142+
<div class="columns">
143+
<div class="column">
144+
<pre id="debug_content" class="content debug_content"></pre>
154145
</div>
155146
</div>
156-
<!-- </div>
157-
</section> -->
147+
</div>
148+
</div>
158149
</div>
159150

160151
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.slim.min.js" charset="utf-8"></script>
@@ -163,13 +154,11 @@ <h4>Debuging</h4>
163154
<script src="../dist/knayi-myscript.js"></script>
164155

165156
<script type="text/javascript">
166-
// (function () {
157+
(function () {
167158
console.log('knayi-myscript version: ' + knayi.version);
168159

169160
var $view_tabs = $('.view-tab');
170161
var $views = $('.view');
171-
// var $converting_view = $('#converting_view');
172-
// var $normalization_view = $('#normalization_view');
173162

174163
var $convert_unicode_text = $('#convert_unicode_text');
175164
var $convert_zawgyi_text = $('#convert_zawgyi_text');
@@ -266,22 +255,6 @@ <h4>Debuging</h4>
266255
var highlight_end = regexp_of_converted_selected_value.lastIndex;
267256

268257
if (regexp_of_converted_selected_value.lastIndex) {
269-
// var highlight_html = converted_value.substr(0, highlight_start)
270-
// + '<span class="highlight">'
271-
// + converted_selected_value
272-
// + '</span>'
273-
// + converted_value.substr(highlight_end);
274-
275-
// $target_output_input.html(highlight_html);
276-
// $target_output_input.highlightWithinTextarea({
277-
// highlight: [highlight_start, highlight_end]
278-
// });
279-
280-
// console.log("Working ", highlight_start, highlight_end)
281-
282-
// $target_output_input[0].setSelectionRange(highlight_start, highlight_end)
283-
// $target_output_input.selectRange(highlight_start, highlight_end);
284-
285258
var converting_debug_logs = knayi.fontConvert.debugging(selected_value, target_font_type, origin_font_type, true);
286259

287260
var unicode_selected_value;
@@ -341,8 +314,27 @@ <h4>Debuging</h4>
341314
}
342315
})
343316
/** Font Convert Debuging **/
317+
318+
$normalization_input.on('select', function (event) {
319+
var $convert_input = $(this);
320+
var selection_start = event.target.selectionStart;
321+
var selection_end = event.target.selectionEnd;
322+
323+
var selected_value = origin_value.slice(selection_start, selection_end);
324+
325+
var normalized_value = knayi.normalize(selected_value);
326+
327+
$debug_content.html(
328+
html_line('<b>Selected Words</b>')
329+
+ html_code(selected_value)
330+
+ html_line('<br/ >')
331+
+ html_line('<b>Normalized string</b>')
332+
+ html_line('<br/ >')
333+
+ [].join.call(normalized_value, ' + ')
334+
);
335+
});
344336
}
345-
// } ())
337+
} ())
346338
</script>
347339
</body>
348340
</html>

library/detector.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ library.detect = {
2121
]
2222
};
2323

24-
// Populate Detect library as RegExps
24+
// Populate Detect library as Regex
2525
Object.keys(library.detect).forEach((type) => {
2626
for (var i = 0; i < library.detect[type].length; i++) {
2727
library.detect[type][i] = new RegExp(library.detect[type][i], 'g');
@@ -52,7 +52,6 @@ function fontDetect(content, fallback_font_type, options = {}){
5252
options = globalOptions.detector(options);
5353

5454
if (options.use_myanmartools) {
55-
5655
var myanmartools_zg_probability = myanmartoolZawgyiDetector.getZawgyiProbability(content);
5756

5857
if (myanmartools_zg_probability < options.myanmartools_zg_threshold[0]) {
@@ -64,7 +63,6 @@ function fontDetect(content, fallback_font_type, options = {}){
6463
}
6564

6665
} else {
67-
6866
var match = {};
6967

7068
for (var type in library.detect) {

library/normalization.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const BURMESE = 'က-ဧဩ';
2020

2121
const C = 'က-အ';
2222
const LONG_C = 'ကဃဆဏတထဘအယလသဟ';
23+
const SHORT_C = 'ခဂငစဇဈဉဎဒဓနပဖဗမရဝဠ';
2324
// Medials
2425
const M = removeSpace(_M);
2526
// Dependent Vowel Signs
@@ -65,7 +66,7 @@ const DOUBLE_TA_CHAUNG_NGIN = 'ုူ ူ';
6566
const ZA_MYIN_ZWAE = 'စျ ဈ';
6667

6768
// Post fix rule
68-
const SPACE_IN_FRONT_OF_VIRAMA = `([^${LONG_C}])\\s(္[က-အ]) $1$2`;
69+
const SPACE_IN_FRONT_OF_VIRAMA = `([${SHORT_C}])\\s(္[က-အ]) $1$2`;
6970

7071
addReplacementRule(extendedRules, ZERO_WA.split(' '));
7172
addReplacementRule(extendedRules, U_FIX.split(' '));

test/detector.test.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,29 @@ knayi.setGlobalOptions({ detector: { use_myanmartools: true } })
66

77
describe('Detector default mode',()=>{
88
describe('Detect Zawgyi',()=>{
9-
it('should detect zawgyi',done=>{
9+
it('should detect zawgyi',()=>{
1010
knayi.fontDetect('မဂၤလာပါ').should.equal('zawgyi');
11-
done();
1211
})
1312
})
1413

1514
describe('Detect Unicode',()=>{
16-
it('should detect unicode',done=>{
15+
it('should detect unicode',()=>{
1716
knayi.fontDetect('မင်္ဂလာပါ').should.equal('unicode');
18-
done();
1917
})
2018
})
2119
})
2220

2321
describe('Detector with myanmartools',()=>{
2422

2523
describe('Detect Zawgyi',()=>{
26-
it('should detect zawgyi',done=>{
24+
it('should detect zawgyi',()=>{
2725
knayi.fontDetect('မဂၤလာပါ', null, {use_myanmartools: true}).should.equal('zawgyi');
28-
done();
2926
})
3027
})
3128

3229
describe('Detect Unicode',()=>{
33-
it('should detect unicode',done=>{
30+
it('should detect unicode',()=>{
3431
knayi.fontDetect('မင်္ဂလာပါ', null, {use_myanmartools: true}).should.equal('unicode');
35-
done();
3632
})
3733
})
3834
})

test/spellingCheck.test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ var should = chai.should();
44

55
describe('spellingFix',()=>{
66
describe('spellingFix Unicode',()=>{
7-
it('should fix for unicode',done=>{
7+
it('should fix for unicode',()=>{
88
knayi.spellingFix('မင်္ဂလာာပါါ','unicode').should.equal('မင်္ဂလာပါ');
9-
done();
109
})
1110
})
1211

1312
describe('spellingFix Zawgyi',()=>{
14-
it('should fix for zawgyi',done=>{
13+
it('should fix for zawgyi',()=>{
1514
knayi.spellingFix('မဂၤလာပါါ').should.equal('မဂၤလာပါ');
16-
done();
1715
})
1816
})
1917
})

0 commit comments

Comments
 (0)