从句子或单词中提取阿拉伯字母 [英] extract arabic letter from sentence or word

查看:179
本文介绍了从句子或单词中提取阿拉伯字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在vb6中开发一个小程序,该程序可以处理阿拉伯文档,我想计算每个阿拉伯字母出现在文档中的次数

基本阿拉伯字符

اأإآىءبخخرررررظظظظظظظp p p

例句

البيتالكسزاللتيلالزجاجالست.

我不懂阿拉伯语,甚至不懂怎么读.

如果vb6无法正常工作,我可以使用vb.net

解决方案

使用VB.Net会容易得多.

  • VB6具有 patchy 支持Unicode.
  • 在VB6中,您此答案.它需要异常处理.

    ''# You may need a different character encoding here, this is UTF-8
    Using sr As New IO.StreamReader("Test.txt", Text.Encoding.UTF8)
      Dim c As Char
      Dim dict As New Dictionary(Of String, Integer)
    
      Do Until sr.EndOfStream
       c = ChrW(sr.Read)
    
       If (dict.ContainsKey(c))
         dict(c)+=1
       Else
         dict(c) = 1
       End If
      Loop
    End Using
    

    i am developing a small program in vb6 that will work with an Arabic document, i want to count how many occurrence each Arabic letter appears in the document

    basic arabic characters

    ا أ إ آ ى ؤ ئ ء ب ت ة ث ج ح خ د ذ ر ز س ش ص ض ط ظ ع غ ف ق ك ل م ن ه

    example sentence

    البيت الكسز اللتيل الزجاج الست.‏

    i don't know arabic or even know how to read it.

    if vb6 won't work, i can use vb.net

    解决方案

    It'll be much easier to use VB.Net.

    • VB6 has patchy support for Unicode.
    • In VB6, you'd probably need to change your PC system code page to Arabic to be able to read the document.

    EDIT: Air code solution in VB.Net, partly based on this answer. It needs exception handling.

    ''# You may need a different character encoding here, this is UTF-8
    Using sr As New IO.StreamReader("Test.txt", Text.Encoding.UTF8)
      Dim c As Char
      Dim dict As New Dictionary(Of String, Integer)
    
      Do Until sr.EndOfStream
       c = ChrW(sr.Read)
    
       If (dict.ContainsKey(c))
         dict(c)+=1
       Else
         dict(c) = 1
       End If
      Loop
    End Using
    

    这篇关于从句子或单词中提取阿拉伯字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆