Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("main") 'Load the layout file.
MainForm.Show
TextArea1.Text="我爱中国!"
RunMarian
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub RunMarian
sh.Initialize("sh","cmd",Array("/c","StartSentencePieceMtPipe.bat","C:\Users\xulihang\AppData\Local\fiskmo\models\zh-en\opus-2020-07-17-zh2en"))
sh.InputStreamEnabled=True
sh.Encoding="UTF8"
sh.WorkingDirectory="E:\Download\FiskmoMTEngine"
sh.RunWithOutputEvents(-1)
'sh.Run(-1)
End Sub
Sub Button1_MouseClicked (EventData As MouseEvent)
sh.WriteToInputStream(TextArea1.Text.GetBytes("UTF8"))
End Sub
Sub sh_StdOut (Buffer() As Byte, Length As Int)
Log("out")
Dim translation As String=BytesToString(Buffer,0,Length,"UTF8").Replace(" ","").Replace("▁"," ").Trim
Log(translation)
TextArea2.Text=translation
End Sub
Sub sh_StdErr (Buffer() As Byte, Length As Int)
Log("err")
Log(BytesToString(Buffer,0,Length,"UTF8"))
End Sub