Skip to content

Commit f718030

Browse files
committed
Fixed numeric query
added Query.toString() fixed formatting
1 parent b7438ad commit f718030

File tree

6 files changed

+56
-46
lines changed

6 files changed

+56
-46
lines changed

README.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let notation = require('myanmar-notation');
1111

1212
- [x] Return formatted Numeric
1313
- [x] Decimals are rounded (floor)
14-
- [x] Query `get(2700)`, `get('၂၇ဝဝ')`, `get('2,700.00')` is flexible
14+
- [x] Query `get(2700)`, `get('၂၇ဝဝ')`, `get('27,000,000.00')` is flexible
1515

1616
```js
1717
notation.get('2700');
@@ -25,31 +25,30 @@ notation.get('2700');
2525
]
2626
}
2727

28-
notation.get('27000000');
28+
notation.get('၂၇ဝဝ');
2929
// return
3030
{
31-
"Numeric": "၂၇,ဝဝဝ,ဝဝဝ",
31+
"Numeric": "2,700",
3232
"Notation": [
3333
{
34-
"sense": "သိန်းပေါင်း နှစ်ရာ့ခုနစ်ဆယ်"
35-
},
36-
{
37-
"sense": "သန်းပေါင်း နှစ်ဆယ့်ခုနစ်"
38-
},
39-
{
40-
"sense": "နှစ်ကု​ဋေ​နှင့် ခုနစ်သန်း"
34+
"sense": "နှစ်ထောင်နှင့် ခုနစ်ရာ"
4135
}
4236
]
4337
}
4438

45-
// Reverse
46-
notation.get('၈၆ဝ');
39+
notation.get('27,000,000.00');
4740
// return
4841
{
49-
"Numeric": "860",
42+
"Numeric": "၂၇,ဝဝဝ,ဝဝဝ",
5043
"Notation": [
5144
{
52-
"sense": "ရှစ်ရာနှင့် ခြောက်ဆယ်"
45+
"sense": "သိန်းပေါင်း နှစ်ရာ့ ခုနစ်ဆယ်"
46+
},
47+
{
48+
"sense": "သန်းပေါင်း နှစ်ဆယ့် ခုနစ်"
49+
},
50+
{
51+
"sense": "နှစ်ကု​ဋေ​နှင့် ခုနစ်သန်း"
5352
}
5453
]
5554
}

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ module.exports = {
33
get:function (q) {
44
return new notation().get(q);
55
},
6-
getCreaky:function (q) {
7-
},
8-
getNormal:function (q) {
9-
},
6+
// getCreaky:function (q) {
7+
// },
8+
// getNormal:function (q) {
9+
// },
1010
name:function () {
1111
return new notation().configName();
1212
},

notation.js

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = class Notation {
2626
return this.config.conjunction;
2727
}
2828
get(query) {
29-
let q=Math.floor(Number(query.replace(/,\s?/g, ""))).toString(),t=0;
29+
let q=Math.floor(Number(query.toString().replace(/,\s?/g, ""))).toString(),t=0;
3030
if (isNaN(q)){
3131
q=this.getUni(query),t=1;
3232
if (q<1 || isNaN(q)) return false;
@@ -53,8 +53,8 @@ module.exports = class Notation {
5353
if (this.config.task.length) {
5454
this.config.task=[];
5555
return {
56-
// "sense":this.requestCreakyTone(q)
57-
"sense":this.requestWrittenTone(q)
56+
// sense:this.requestCreakyTone(q)
57+
sense:this.requestWrittenTone(q)
5858
}
5959
}
6060
return false;
@@ -83,9 +83,7 @@ module.exports = class Notation {
8383
rawSense.push(this.requestPrime(rulePrime,s)+this.requestCreakyTone(q,0,ruleExtract));
8484
rawSense.push(this.requestCreakyTone(q,rulePrime, s+1));
8585
rawSense.push(this.requestWrittenTone(q,s+1, q.length));
86-
examNotation={
87-
1:21
88-
};
86+
// examNotation={1:21};
8987
} else {
9088
if (rawCount > rawEndCount) {
9189
ruleExtract=rawCount;
@@ -95,8 +93,7 @@ module.exports = class Notation {
9593
rulePrime=1;
9694
rawSense.push(this.requestPrime(rulePrime,s,true)+this.requestCreakyTone(q,0,ruleExtract));
9795
rawSense.push(this.requestCreakyTone(q,ruleExtract, q.length));
98-
99-
examNotation={1:22};
96+
// examNotation={1:22};
10097
}
10198
} else {
10299
if (s == rawEndCount) {
@@ -105,40 +102,48 @@ module.exports = class Notation {
105102
if (Number(q.substring(ruleExtract, q.length))){
106103
rawOver=this.config.conjunction.over;
107104
}
108-
109105
rawSense.push(this.requestPrime(rulePrime,s)+this.requestCreakyTone(q,0,ruleExtract)+rawOver);
110-
111-
examNotation={1:31};
106+
// examNotation={1:31};
112107
} else {
113-
let abc=false;
114108
ruleExtract=rawCount-1+rawEndCount;
115109
rulePrime=rawCount-1;
116110
// ruleExtract=rawCount;
117111
if (ruleExtract > ruleMax){
118112
ruleExtract=rawEndCount-3;
119113
rulePrime=rawCount;
120-
abc=true;
121114
}
122115
let rawOver='';
123-
if (Number(q.substring(ruleExtract, q.length))){
116+
// if (Number(q.substring(ruleExtract, q.length))){
117+
// rawOver=this.config.conjunction.over;
118+
// }
119+
let leftOver = q.substring(ruleExtract, q.length);
120+
if (Number(leftOver)){
124121
rawOver=this.config.conjunction.over;
122+
// leftOver = q.substring(ruleExtract, q.length-s);
123+
leftOver = q.substring(ruleExtract, q.length-s);
125124
}
126125

127126
rawSense.push(this.requestPrime(rulePrime,s)+this.requestCreakyTone(q,0,ruleExtract)+rawOver);
128-
examNotation={
129-
abc:abc,
130-
1:32
131-
};
127+
// examNotation={
128+
// working:true,
129+
// a1:q,
130+
// a2:q.substring(0,ruleExtract),
131+
// a3:leftOver,
132+
// a4:leftOver.length,
133+
// a5:this.strSeparate(q.substring(ruleExtract, q.length),ruleExtract),
134+
// raw:raw
135+
// };
132136
}
133137
}
134138

135139
return {
136140
sense:this.createString(rawSense),
137-
exam: examNotation
141+
// exam: examNotation
138142
};
139143
}
140144
requestObject(str,callback) {
141145
let strCount = str.length, e=[];
146+
// let testing = this.config.tone.reverse()
142147
// let strReverse = str.reverse(); index += to, ++index
143148
for (let index = 0; index < strCount;++index){
144149
let position = strCount - index;
@@ -161,7 +166,7 @@ module.exports = class Notation {
161166
return tone;
162167
}).map((k,index)=>{
163168
return k.name+k.tone;
164-
}).join('')
169+
}).join(' ')
165170
}
166171
requestWrittenTone(num,from,to) {
167172
let str = this.strIntersect(num,from,to);

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "myanmar-notation",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "get Myanmar digital and notation",
55
"main": "index.js",
66
"scripts": {
@@ -14,7 +14,8 @@
1414
"Myanmar",
1515
"Number",
1616
"Notation",
17-
"Convertor"
17+
"Convertor",
18+
"Num2Word"
1819
],
1920
"author": "Khen Solomon Lethil",
2021
"license": "MIT",

test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
const fs = require('fs');
22
let notation = require('./notation');
33
let query = process.argv.slice(2)[0];
4-
// query = '10,000';
4+
// query = '27,000,000.00';
55
// query = '၁,၂ဝဝဝဝဝ.၂ဝ';
6-
// query = '၈၆ဝ';
6+
// query = '၂၇ဝဝ';
77

88
let raw = new notation().get(query);
99
raw.Query=query;
@@ -26,5 +26,4 @@ fs.writeFile("./test.json", JSON.stringify(raw, null, 2), 'utf8', function (err)
2626
000000
2727
000000
2828
000000
29-
3029
*/

test.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
{
2-
"Numeric": "၄၅",
2+
"Numeric": "၁၂,၃၄၅,၆၇ဝ,ဝဝဝ,ဝဝဝ,ဝဝဝ,ဝဝဝ",
33
"Notation": [
44
{
5-
"sense": "လေးဆယ်နှင့် ငါး"
5+
"sense": "သိန်းပေါင်း သိန်းပေါင်း သိန်းတစ်သောင်း နှစ်ထောင့် သုံးရာ့ လေးဆယ့် ငါးကျော်"
6+
},
7+
{
8+
"sense": "သန်းပေါင်း သန်းတစ်ကု​ဋေ​ နှစ်သန်း သုံးသိန်း လေးသောင်း ငါးထောင့် ခြောက်ရာ့ ခုနစ်ဆယ်"
9+
},
10+
{
11+
"sense": "ကု​ဋေ​ပေါင်း ကု​ဋေ​တစ်သိန်း နှစ်သောင်း သုံးထောင့် လေးရာ့ ငါးဆယ့် ခြောက်ကျော်"
612
}
713
],
8-
"Query": "45"
14+
"Query": "12345670000000000000"
915
}

0 commit comments

Comments
 (0)