Tài liệu Phiên dịch tiếng Anh sang tiếng Việt bằng VB doc – Tài liệu text

Tài liệu Phiên dịch tiếng Anh sang tiếng Việt bằng VB doc

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (143.49 KB, 4 trang )

Phiên dịch tiếng Anh sang tiếng Việt bằng VB

Viết ứng dụng để dịch một đoạn văn tiếng Anh sang tiếng Việt
dường như là việc quá ư khó khăn. Tuy nhiên, nếu ta chỉ xét
những câu đàm thoại thông thường thì việc “phiên dịch tự động”
không phức tạp lắm. Xin trình bày một ý tưởng để giúp bạn
học tiếng Anh tốt hơn.

Bạn hãy tạo dự án mới trong VB rồi bấm Ctrl+T. Trên hộp thoại vừa hiện ra, bạn chọn Microsoft
Rich Textbox Control 6.0 và nhấn OK. Tiếp theo, bạn thiết kế giao diện như hình 1 với các thuộc
tính như trong bảng 1 và bảng 2 rồi đánh đoạn mã 1.
Sau khi lưu ứng dụng, bạn tạo 3 tập tin văn bản TXT trong thư mục của ứng dụng:
– phrases.txt: chứa các mệnh đề đặc biệt hay thành ngữ tiếng Anh (at night, at times, ).
– verbs.txt: chứa các chủ ngữ và động từ tiếng Anh (I am, he is, we do, ).
– words.txt: chứa các từ tiếng Anh thông dụng (I, hello, you, ).
Cả ba tập tin như vậy có dạng thức như sau:
“tu_tieng_Anh_1″,”nghia_1”
“tu_tieng_Anh_2″,”nghia_2”

Xem thêm  giáo phái scientology là gì? Hé lộ bí mật giáo phái Scientology Nơi ‘cầm tù’ người nổi tiếng

Bạn chạy thử và đánh câu tiếng Anh ở khung văn bản phía trên xem sao. Thật ngạc nhiên, phía
dưới xuất hiện câu tiếng Việt tương ứng! Bạn chú ý, ứng dụng hoạt động tốt hay không là do cơ
sở dữ liệu (CSDL) từ ngữ của ta có phong phú hay không. Bạn nên đưa nhiều thành ngữ vào tập
tin phrases.txt. Bạn có thể tải mã nguồn và CSDL của ứng dụng tại: www.echip.com.vn. Chúc
bạn thành công.
H1

Bảng 1
Control Name Font
RichTextbox1 txtenglish 14, Bold
RichTextbox2 txtvietnam 14, Bold
Bảng 2

Control Name Interval
Timer1 t_1 5
Timer2 t_2 1

Đoạn mã 1
Dim vn_words(1 To 1000)
Dim en_words(1 To 1000)
Dim dotime As String
Dim strings As String
Dim check_verbs As Integer
Dim check_phrases As Integer
Dim englishtext, vietnamtext

Private Sub Form_Load()
Form1.Show
t_1.Enabled = False
t_2.Enabled = True
listwords = 1

Open (App.Path & “\phrases.txt”) For Input As #1
Do While Not EOF(1)
Input #1, englishtext, vietnamtext
en_words(listwords) = englishtext
vn_words(listwords) = vietnamtext
listwords = listwords + 1
Loop
Close #1
check_phrases = listwords

Open (App.Path & “\verbs.txt”) For Input As #1

Do While Not EOF(1)
Input #1, englishtext, vietnamtext
en_words(listwords) = englishtext
vn_words(listwords) = vietnamtext
listwords = listwords + 1
Loop
Close #1
check_verbs = listwords – check_phrases

Open (App.Path & “\words.txt”) For Input As #1
Do While Not EOF(1)
Input #1, englishtext, vietnamtext
en_words(listwords) = englishtext
vn_words(listwords) = vietnamtext
listwords = listwords + 1
Loop
Close #1
End Sub

Xem thêm  Sau “By” dùng gì, cách dùng “By” trong Tiếng Anh

Private Sub t_1_Timer()
If txtvietnam.Text = “” Then Exit Sub
If dotime = txtvietnam.Text Then Exit Sub
txtenglish.Text = “”
whereareweat = 1
dotime = txtvietnam.Text
strings = txtvietnam.Text
For i = 1 To 13
strings = Replace(strings, vn_words(i), en_words(i) & ” “)
Next i
For i = 1 To 1000

strings = Replace(strings, vn_words(i), en_words(i) & ” “)
Next i
txtvietnam.Text = strings
End Sub

Private Sub t_2_Timer()
If txtenglish.Text = “” Then Exit Sub
If dotime = txtenglish.Text Then Exit Sub
txtvietnam.Text = “”
whereareweat = 1
dotime = txtenglish.Text
strings = txtenglish.Text
For i = 1 To check_phrases
strings = Replace(strings, vn_words(i), en_words(i) & ” “)
Next i
For i = check_phrases To check_verbs
strings = Replace(strings, vn_words(i), en_words(i) & ” “)
Next i
For i = 1 To 1000
strings = Replace(strings, en_words(i), vn_words(i) & ” “)
Next i
txtvietnam.Text = strings
End Sub


Control Name IntervalTimer1 t_1 5T imer2 t_2 1 Đoạn mã 1D im vn_words ( 1 To 1000 ) Dim en_words ( 1 To 1000 ) Dim dotime As StringDim strings As StringDim check_verbs As IntegerDim check_phrases As IntegerDim englishtext, vietnamtextPrivate Sub Form_Load ( ) Form1. Showt_1. Enabled = Falset_2. Enabled = Truelistwords = 1O pen ( App. Path và ” \ phrases.txt ” ) For Input As # 1D o While Not EOF ( 1 ) Input # 1, englishtext, vietnamtexten_words ( listwords ) = englishtextvn_words ( listwords ) = vietnamtextlistwords = listwords + 1L oopClose # 1 check_phrases = listwordsOpen ( App. Path và ” \ verbs.txt ” ) For Input As # 1D o While Not EOF ( 1 ) Input # 1, englishtext, vietnamtexten_words ( listwords ) = englishtextvn_words ( listwords ) = vietnamtextlistwords = listwords + 1L oopClose # 1 check_verbs = listwords – check_phrasesOpen ( App. Path và ” \ words.txt ” ) For Input As # 1D o While Not EOF ( 1 ) Input # 1, englishtext, vietnamtexten_words ( listwords ) = englishtextvn_words ( listwords ) = vietnamtextlistwords = listwords + 1L oopClose # 1E nd SubPrivate Sub t_1_Timer ( ) If txtvietnam. Text = ” ” Then Exit SubIf dotime = txtvietnam. Text Then Exit Subtxtenglish. Text = ” ” whereareweat = 1 dotime = txtvietnam. Textstrings = txtvietnam. TextFor i = 1 To 13 strings = Replace ( strings, vn_words ( i ), en_words ( i ) và ” ” ) Next iFor i = 1 To 1000 strings = Replace ( strings, vn_words ( i ), en_words ( i ) và ” ” ) Next itxtvietnam. Text = stringsEnd SubPrivate Sub t_2_Timer ( ) If txtenglish. Text = ” ” Then Exit SubIf dotime = txtenglish. Text Then Exit Subtxtvietnam. Text = ” ” whereareweat = 1 dotime = txtenglish. Textstrings = txtenglish. TextFor i = 1 To check_phrasesstrings = Replace ( strings, vn_words ( i ), en_words ( i ) và ” ” ) Next iFor i = check_phrases To check_verbsstrings = Replace ( strings, vn_words ( i ), en_words ( i ) và ” ” ) Next iFor i = 1 To 1000 strings = Replace ( strings, en_words ( i ), vn_words ( i ) và ” ” ) Next itxtvietnam. Text = stringsEnd Sub

Xem thêm  Πάρε τον πόνο από τη μέση... Δώσε πόνο στο χορό σου! | Counterpain® | Website information tips

Source: https://bem2.vn
Category: TỔNG HỢP

Rate this post

Bài viết liên quan

Để lại ý kiến của bạn:

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *