|
-
Oct 14th, 2006, 04:12 PM
#1
Thread Starter
Addicted Member
[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
-
Oct 14th, 2006, 05:15 PM
#2
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 //.
-
Oct 14th, 2006, 08:02 PM
#3
Thread Starter
Addicted Member
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.
-
Oct 14th, 2006, 08:06 PM
#4
Thread Starter
Addicted Member
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
-
Oct 14th, 2006, 08:46 PM
#5
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
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
-
Oct 16th, 2006, 11:27 AM
#6
Thread Starter
Addicted Member
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?
-
Oct 16th, 2006, 04:21 PM
#7
Re: again help to chang my code
try working backwards
VB Code:
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
-
Oct 18th, 2006, 07:22 AM
#8
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|