Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim strText, strLiteral, strPhonetic
- strText = "Transcription in the linguistic sense is the systematic representation of language in written form."
- GetFoneticNotation strText, 0, "on", strLiteral, strPhonetic
- MsgBox strLiteral & vbcrlf & vbcrlf & strPhonetic
- Sub GetFoneticNotation(strText, strOptIpa, strOptStrs, strLiteral, strPhonetic)
- ' http://upodn.com/phon.php
- ' usage
- ' strText - text to get fonetic notation
- ' strOptIpa:
- ' 0 - IPA
- ' 1 - American Phonetic Alphabet
- ' 2 - SAMPA
- ' 3 - Shavian
- ' strOptStrs:
- ' on | off - Mark word stress
- ' strLiteral - return recognized text
- ' strPhonetic - return phonetic notation
- Dim strData, strResp
- strData = "intext=" & escape(strText) & "&ipa=" & strOptIpa & "&stress=" & strOptStrs
- With CreateObject("Msxml2.XMLHTTP")
- .Open "POST", "http://upodn.com/phon.php", False
- .SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
- .SetRequestHeader "Content-Length", Len(strData)
- .Send strData
- strResp = .ResponseText
- End With
- With New RegExp
- .Pattern = "<table[\s\S]*<tr[\s\S]*<td[\s\S]*>([\s\S]*)</td>[\s\S]*<td[\s\S]*<font[\s\S]*>([\s\S]*)</font>[\s\S]*</td>[\s\S]*</tr>[\s\S]*</table>"
- .Global = True
- .IgnoreCase = True
- With .Execute(strResp)
- If .Count = 1 Then
- strLiteral = .Item(0).SubMatches(0)
- With CreateObject("htmlfile")
- .write strLiteral
- strLiteral = UnEscape(.getElementsByTagName("body")(0).innerText)
- End With
- strPhonetic = .Item(0).SubMatches(1)
- With CreateObject("htmlfile")
- .write strPhonetic
- strPhonetic = .getElementsByTagName("body")(0).innerText
- End With
- End If
- End With
- End With
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement