[RESOLVED] again help to chang my code
I have this code to extract what in between the first two /
VB Code:
If UCase(Left(tmp(x), 10)) = " SOLUTION" Then
gram = Split(tmp(x), "/")
sLine = sLine & " (" & Trim(gram(1)) & ") "
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 :wave:
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:
Option Explicit
Private Sub Form_Load()
Dim ln As String
Dim pos(1) As Long
Dim ff As Integer: ff = FreeFile
Open "c:\test.txt" For Input As #ff
Do Until EOF(ff)
Line Input #ff, ln
If InStr(1, ln, "/") > 0 Then
pos(0) = InStr(1, ln, "/")
If InStrRev(ln, "/") > pos(0) Then
pos(1) = InStrRev(ln, "/")
Debug.Print Mid(ln, pos(0) + 1, pos(1) - pos(0) - 1)
Else
pos(0) = 0
End If
End If
Loop
Close #ff
End Sub
What about SOLUTION 4 & 5? There are two //.
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)
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
Re: again help to chang my code
see if this can help you
VB Code:
If UCase(Left(tmp(x), 10)) = " SOLUTION" Then
gram = split(tmp(x), "/")
For i = 0 To UBound(gram)
Select Case Left(gram(i), 4)
Case "NOUN", "PRON", "VERB", "PREP", "ADJ+"
sLine = sLine & " (" & Trim(gram(i)) & ") "
Exit For ' this will only allow the first 1 found to be included in sline
' otherwise it will add all to the string
'you can do more procesing by seperating the def into different cases
End Select
Next
End If
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?
Re: again help to chang my code
try working backwards
VB Code:
For i = Ubound(gram) to 0 Step -1
Re: again help to chang my code
Ok Thanks Alot
It's Working Know