kylefoley76
Well-known Member
- Joined
- Mar 1, 2010
- Messages
- 1,553
I'm a little upset with myself for taking 30 hours to write the following code.
What the code does is it loops through the justifiers array which in this case had 11 members but 9 of the members were blank. It then had to look in the osent array and the more_sent array to find the sentences that justified the member in the justifier array. After that was done, it then had to get the corresponding members from the ancestors array and then it had to take each ancestor and look through the osent and more_sent array to find which sentences causes the ancestors. And when it found them, it had to delete the members. This process had to continue into all the members in one of the array was deleted. The reason why it took 30 hours was partly because I was dieting and couldn't concentrate that well but also because I kept trying to do it backwards from the wrong starting point.
What the code does is it loops through the justifiers array which in this case had 11 members but 9 of the members were blank. It then had to look in the osent array and the more_sent array to find the sentences that justified the member in the justifier array. After that was done, it then had to get the corresponding members from the ancestors array and then it had to take each ancestor and look through the osent and more_sent array to find which sentences causes the ancestors. And when it found them, it had to delete the members. This process had to continue into all the members in one of the array was deleted. The reason why it took 30 hours was partly because I was dieting and couldn't concentrate that well but also because I kept trying to do it backwards from the wrong starting point.
Code:
Function explain_justification(more_sent As Variant, ancestors As Variant, _
assumption As Variant, justifiers As Variant, sent As Variant, _
cons_sent As Variant, implication As Boolean, num_just As Integer, osent As Variant) As String
Dim i As Integer, temp_just As String, j As Integer, temp_more_sent As String
Dim more_sent_used(), more_sent_just As Boolean, found As Boolean
Dim temp_ancest3 As String, temp_ancest4 As String, match As Boolean
Dim temp_ancest1 As String, temp_ancest2 As String, temp_more_sent2 As String
Dim m As Integer, o As Integer
Dim k As Integer, n As Integer, help_me As Boolean, temp_more(), t As Integer
ReDim temp_more(UBound(more_sent))
Dim match1 As Boolean, match2 As Boolean, double_match As Boolean, temp_osent As String
Dim to_be_found()
ReDim more_sent_used(UBound(more_sent))
Dim temp_tsent As String
j = UBound(justifiers)
Do Until j = 0
temp_just = justifiers(j)
If justifiers(j) <> "" Then
Do
more_sent_used(j) = temp_just
ReDim Preserve to_be_found(m)
to_be_found(m) = ancestors(j, 1)
m = m + 1
ReDim Preserve to_be_found(m)
to_be_found(m) = ancestors(j, 2)
m = m + 1
so_real:
For t = 1 To UBound(osent)
temp_osent = osent(t)
For m = 1 To UBound(to_be_found)
Dim temp_to_be_found As String
temp_to_be_found = to_be_found(m)
If temp_osent = temp_to_be_found Then
to_be_found(m) = ""
End If
Next
If Len(Join(to_be_found, "")) = 0 Then
GoTo im_real
justifiers(j) = ""
End If
Next
Dim to_be_found2()
For t = UBound(more_sent) To 1 Step -1
temp_more_sent = more_sent(t)
For m = 1 To UBound(to_be_found)
temp_to_be_found = to_be_found(m)
If temp_more_sent = temp_to_be_found Then
more_sent_used(t) = temp_more_sent
to_be_found(m) = ancestors(t, 1)
m = UBound(to_be_found) + 1
ReDim Preserve to_be_found(m)
to_be_found(m) = ancestors(t, 2)
GoTo so_real
End If
Next
Next
im_real:
Loop Until Len(Join(to_be_found, "")) = 0
End If
j = j - 1
Loop Until Len(Join(justifiers, "")) = 0