Imports System
Imports System
Namespace Businness
Public Class PYService
Private gDataSet As New dsPinYin
Public ReadOnly Property PinYinTable() As dsPinYin
Get
Return gDataSet
End Get
End Property
Private gTxtFile As String = AppDomain
Private gxmlFile As String = AppDomain
Private gRegex As New Regex(
Public Sub Load()
If Not IO
Throw New Exception(String
End If
DataSetInitialize()
gDataSet
End Sub
Public Sub Update()
If Not IO
Throw New Exception(String
End If
UpdateFromTxt(gTxtFile)
End Sub
Public Sub Save()
gDataSet
End Sub
Private Sub DataSetInitialize()
Me
Me
End Sub
Private Sub UpdateFromTxt(ByVal file As String)
DataSetInitialize()
Dim mLine As String
Dim mBuilder As New System
Dim mReader As New IO
Do
mLine = mReader
Add(mLine)
Loop Until String
mReader
mReader
Me
End Sub
Private Sub Add(ByVal line As String)
If line Is Nothing Then Exit Sub
With gRegex
If
If
Add(
End If
End If
End With
End Sub
Private Sub Add(ByVal word As String
py = py
Dim mCode As String = ChineseCode(word)
Dim mRow As dsPinYin
If mRow Is Nothing Then
Me
Else
Dim pyArray() As String = py
For Each s As String In pyArray
If Not mRow
mRow
End If
Next
End If
End Sub
Public Function ToPinyin(ByVal line As String
Dim mBuilder As New Text
For Each s As Char In line
If IsTrue(s) Then
mBuilder
Else
mBuilder
End If
Next
Return mBuilder
End Function
Private Function GetPinyin(ByVal word As String
Dim mResult As String = word
Dim mArray As String() = PinYinArray(ChineseCode(word))
If Not mArray Is Nothing Then
If mArray
mResult = mArray(
Else
mResult = String
End If
End If
Return mResult
End Function
Private Function PinYinArray(ByVal code As String) As String()
Dim mRow As dsPinYin
If mRow Is Nothing Then Return Nothing
Return mRow
End Function
Public Function WordArray(ByVal pinyin As String) As String()
Dim mRows As dsPinYin
Dim mResult(
For i As Integer =
If Array
Me
End If
Next
Return mResult
End Function
Public Function Words(ByVal pinyin As String) As String
Return String
End Function
Public Shared Function ChineseCode(ByVal word As String) As String
If Not IsTrue(word) Then Return Nothing
Dim bytes() As Byte = System
Return String
End Function
Public Shared Function IsTrue(ByVal word As String) As Boolean
If word Is Nothing Then Return False
Return System
End Function
Private Sub Append(ByRef collection As String()
ReDim Preserve collection(collection
collection(collection
End Sub
End Class
End Namespace
From:http://tw.wingwit.com/Article/program/net/201311/13826.html