Results 1 to 8 of 8

Thread: [RESOLVED] again help to chang my code

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Resolved [RESOLVED] again help to chang my code

    I have this code to extract what in between the first two /

    VB Code:
    1. If UCase(Left(tmp(x), 10)) = "  SOLUTION" Then
    2.            
    3.             gram = Split(tmp(x), "/")
    4.            
    5.                sLine = sLine & " (" & Trim(gram(1)) & ") "
    6.            End If

    I need some one to help me in changing this code to extract this

    (if found these words in the line then extract what in between /
    NOUN
    PRON
    VERB
    ADJ

    Else if found ( PREP) then extract what in between /

    This is a sample of the text I need to search:
    SOLUTION 1: (tanaZ~ama) [tanaZ~am_1] tanaZ~am/VERB_PERFECT+a/PVSUFF_SUBJ:3MS
    SOLUTION 2: (jAmiEap) [jAmiEap_1] jAmiE/NOUN+ap/NSUFF_FEM_SG
    SOLUTION 3: (maEa) [maEa_1] maEa/PREP
    SOLUTION 4: (AljamoEiy~ap) [jamoEiy~_1] Al/DET+jamoEiy~/ADJ+ap/NSUFF_FEM_SG
    SOLUTION 5: (Al$amosiy~ap) [$amosiy~_1] Al/DET+$amosiy~/ADJ+ap/NSUFF_FEM_SG
    SOLUTION 6: (lahA) [li-_1] la/PREP+hA/PRON_3FS



    So the information I need to get are
    VERB_PERFECT+a
    NOUN+ap
    PREP
    ADJ+ap
    ADJ+ap
    PRON_3FS


    Can anyone help me

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: again help to chang my code

    Don't you mean "PREP+hA" for SOLUTION 6?

    If you have this in a text file:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.     Dim ln As String
    5.    
    6.     Dim pos(1) As Long
    7.     Dim ff As Integer: ff = FreeFile
    8.  
    9.         Open "c:\test.txt" For Input As #ff
    10.             Do Until EOF(ff)
    11.  
    12.                 Line Input #ff, ln
    13.  
    14.                     If InStr(1, ln, "/") > 0 Then
    15.                         pos(0) = InStr(1, ln, "/")
    16.                             If InStrRev(ln, "/") > pos(0) Then
    17.                                 pos(1) = InStrRev(ln, "/")
    18.                                     Debug.Print Mid(ln, pos(0) + 1, pos(1) - pos(0) - 1)
    19.                             Else
    20.                                 pos(0) = 0
    21.                             End If
    22.                     End If
    23.             Loop
    24.         Close #ff
    25. End Sub
    What about SOLUTION 4 & 5? There are two //.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: again help to chang my code

    Yes gavio
    there is diff solutions some with only one/ and some with two and others with nothing

    i need to get some info related to grammar of each solution and because i couldn't found a fiexed rule to follow to get what i need i'm thinking in

    serching each line
    if found (the words i wrote ) then
    takes what between//
    else if found (PREP) then
    takes what between//
    '...................................

    and about solution6 i need to get (PRON_3FS) because it have the priority to be extracted same as other words
    if solutions contains (PRON) so get it even if it contains (PREP)
    Last edited by om-yousif; Oct 14th, 2006 at 08:35 PM.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: again help to chang my code

    i forgot to say that the text i'm searching is long and contains other diff lines between solutions so the code i used is semi redy to search each line starts with (solution)

    i hope you understand me

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: again help to chang my code

    see if this can help you
    VB Code:
    1. If UCase(Left(tmp(x), 10)) = "  SOLUTION" Then
    2.                         gram = split(tmp(x), "/")
    3.                        
    4.        For i = 0 To UBound(gram)
    5.             Select Case Left(gram(i), 4)
    6.                 Case "NOUN", "PRON", "VERB", "PREP", "ADJ+"
    7.                     sLine = sLine & " (" & Trim(gram(i)) & ") "
    8.                     Exit For    ' this will only allow the first 1 found to be included in sline
    9.                     ' otherwise it will add all to the string
    10.                     'you can do more procesing by seperating the def into different cases
    11.             End Select
    12.         Next
    13.            
    14.     End If
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: again help to chang my code

    i tried that westconn1
    it didn't work it's still extracting what in between the first two //

    what should i do?

  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: again help to chang my code

    try working backwards
    VB Code:
    1. For i = Ubound(gram) to 0 Step -1
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: again help to chang my code

    Ok Thanks Alot

    It's Working Know

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width