B4A Library [Chargeable] BGL Parser

Discussion in 'Additional libraries, classes and official updates' started by somed3v3loper, Jun 30, 2018.

  1. somed3v3loper

    somed3v3loper Well-Known Member Licensed User

    Java parser for Babylon dictionaries

    A wrap for this project https://github.com/secnelis/BabylonDictParser



    SMMBGLParser
    Author:
    SMM
    Version: 0.13
    • Dict
      Methods:
      • Initialize (ba As anywheresoftware.b4a.BA, name As java.lang.String, author As java.lang.String) As void
      • addEntry (entry As smm.SBabylonParser.sDictEntry) As void
      • entries As anywheresoftware.b4a.objects.collections.List
      • IsInitialized As boolean
      Properties:
      • author As java.lang.String [read only]
      • title As java.lang.String [read only]
    • DictEntry
      Methods:
      • IsInitialized As boolean
      • alternates As anywheresoftware.b4a.objects.collections.List
      Properties:
      • definition As java.lang.String [read only]
      • wordClass As int [read only]
      • displayWord As java.lang.String [read only]
      • headWord As java.lang.String [read only]
      • phonetics As java.lang.String [read only]
    • SMMBGLParser
      Events:
      • _parsed (dict As Dict)
      Methods:
      • parseDict (dir As java.lang.String, zfile As java.lang.String, srcEncoding As java.lang.String, dstEncoding As java.lang.String) As void
      • Initialize (ba As anywheresoftware.b4a.BA, EventName As java.lang.String) As void
      Permissions:
      • android.permission.READ_EXTERNAL_STORAGE
      • android.permission.WRITE_EXTERNAL_STORAGE



    Sample :

    Code:
    Sub Process_Globals
        
    'These global variables will be declared once when the application starts.
        'These variables can be accessed from all modules.
        Dim par As SMMBGLParser
    End Sub

    Sub Globals
        
    'These global variables will be redeclared each time the activity is created.
        'These variables can only be accessed from this module.

    End Sub

    Sub Activity_Create(FirstTime As Boolean)
        
    'Do not forget to load the layout file created with the visual designer. For example:
        'Activity.LoadLayout("Layout1")
        par.Initialize("par")
        
        
        
    If File.Exists(File.DirDefaultExternal,"babylon_english_chinese.bgl")= False Then
            
    File.Copy(File.DirAssets,"babylon_english_chinese.bgl",File.DirDefaultExternal,"babylon_english_chinese.bgl")
            
        
    End If
        par.parseDict(
    File.DirDefaultExternal, "babylon_english_chinese.bgl","GBK","GBK" )
    End Sub
    Sub par_parsed(dict As Dict)
        
    Log(dict.title&" by "&dict.author)
        
    For Each ent As DictEntry In dict.entries
            
    Dim phonetic As String =""
            
    If ent.phonetics<>Null Then
                phonetic=
    " ("&ent.phonetics&") "
            
    End If
            
    Log(ent.wordClass&","&ent.headWord&phonetic&" = " &ent.alternates)
        
    Next
    End Sub
    Result would be something like this:

    Please note before your donation:
    * You will get a wrapper for the current version with methods mentioned above , there is no promise of any kind that I will add a new feature in the future and updates will be only to fix bugs in my wrapper .
    * You can ask any question here or by PM prior to your donation to make sure this wrapper does what you need / want .
    * A minimum of $10 (more is better :D ) is required to get this library . (You get B4A and B4J libraries)
     
    Johan Schoeman and DonManfred like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice