mt6
v0.3.0
Published
Machine Translation (Generate, Learning, Translate)
Downloads
3
Maintainers
Readme
Machine Translation
Model, Generate, Learning, Translation
Install
$ npm install mt6
Model
/*
S = NP?'VP?
NP = A* /N
VP = (V NP?)?
N = 人 | 魚
V = 愛 | 食
A = 藍 | 紅
*/
...
B.P = { NP: 0.7, VP: 0.7, VP_NP: 0.6, NP_A: 0.4,
'藍人': 0.1, '藍魚': 0.9,
'小人': 0.4, '小魚': 0.6 }
...
Generate
D:\Dropbox\github\mt6\tool>node gen 10 tag
'
N'
N'V/
AAN'V/
'
N'V/
'
N'V/AN
N'V/
'V/
D:\Dropbox\github\mt6\tool>node gen 10
人'食/
小小人'食/
小魚'愛/
魚'食/
'食/魚
人'
魚'食/魚
'食/魚
'愛/小人
'
D:\Dropbox\github\mt6\tool>node gen 10000 > word.10000.bak
D:\Dropbox\github\mt6\tool>node gen 10000 tag > tag.10000.bak
D:\Dropbox\github\mt6\tool>node statistics tag.10000.bak
{
".": 10000,
"A": 7408,
"N": 11083,
"'": 10000,
"V": 6941,
"/": 6941
}
{
".A": 2805,
"AN": 4483,
"N'": 6947,
"'V": 6941,
"V/": 6941,
".'": 3053,
".N": 4142,
"/N": 2458,
"AA": 2925,
"/A": 1678
}
P(A|.)=0.2805
P(N|A)=0.6051565874730022
P('|N)=0.6268158440855364
P(V|')=0.6941
P(/|V)=1
P('|.)=0.3053
P(N|.)=0.4142
P(N|/)=0.3541276473130673
P(A|A)=0.39484341252699784
P(A|/)=0.24175190894683762
Analysis
file : tag.10000.map
P(A|.)+P(N|.)=0.2805+0.4142=0.6947 ~ 0.7 = P[NP]
P(A|A)=0.3948 ~ 0.4 = P(A|NP) = P[NP_A]
P(N|/)+P(A|/)=0.354 + 0.24 = 0.594 ~ 0.6 = P(NP|VP) = P[VP_NP]
file : word.10000.map
D:\Dropbox\github\mt6\tool>node statistics word.10000.bak
{
".": 10000,
"魚": 7996,
"'": 10000,
"愛": 3495,
"/": 6939,
"小": 3754,
"人": 3164,
"食": 3444,
"藍": 3713
}
{
".魚": 2170,
"魚'": 4264,
"'愛": 3495,
"愛/": 3495,
".小": 1345,
"小人": 896,
"人'": 2732,
"'食": 3444,
"食/": 3444,
"/魚": 2505,
".人": 2053,
".'": 3004,
".藍": 1428,
"藍藍": 725,
"藍魚": 1990,
"小小": 779,
"小魚": 1331,
"小藍": 748,
"藍小": 783,
"/藍": 812,
"/小": 847,
"藍人": 215
}
P(魚|.)=0.217
P('|魚)=0.5332666333166584
P(愛|')=0.3495
P(/|愛)=1
P(小|.)=0.1345
P(人|小)=0.23867874267448055
P('|人)=0.8634639696586599
P(食|')=0.3444
P(/|食)=1
P(魚|/)=0.3610030263726762
P(人|.)=0.2053
P('|.)=0.3004
P(藍|.)=0.1428
P(藍|藍)=0.19525989765688123
P(魚|藍)=0.5359547535685429
P(小|小)=0.20751198721363878
P(魚|小)=0.3545551411827384
P(藍|小)=0.19925412892914224
P(小|藍)=0.21088068946943173
P(藍|/)=0.11701974347888745
P(小|/)=0.12206369793918433
P(人|藍)=0.05790465930514409
Analysis
P(人|小)/(P(魚|小) + P(人|小)) = 0.23 / (0.23 + 0.35) = 0.396
P(魚|小)/(P(魚|小) + P(人|小)) = 0.35 / (0.23 + 0.35) = 0.603
P(人|藍)/(P(魚|藍) + P(人|藍)) = 0.0579 / (0.535 + 0.0579) = 0.0976
P(魚|藍)/(P(魚|藍) + P(人|藍)) = 0.535 / (0.535 + 0.0579) = 0.9023