aka007

Untitled

Mar 2nd, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. def generate_and_solve_query13():
  2.  
  3. name_to_var = {}
  4. name_to_var['Southee'] = 'r1'
  5. name_to_var['Ryder'] = 'r2'
  6.  
  7. c1=get_series_catches('Southee')
  8. c2=get_series_catches('Ryder')
  9.  
  10. temp_strin1=''
  11. for i in name_to_var:
  12. temp_strin1 += i+' => '+name_to_var[i]+'\n'
  13. if c1 > c2:
  14. c2 = c1
  15.  
  16. temp_strin2 = 'southee => {'+str(c1)+'} \n'
  17. temp_strin3 = 'ryder => {'+str(c2)+'} \n'
  18.  
  19. v = temp_strin1+temp_strin2+temp_strin3
  20. query = 'exists x ( southee(x) & ryder(x) )'
  21.  
  22. val = nltk.parse_valuation(v)
  23. dom = val.domain
  24.  
  25. m = nltk.Model(dom, val)
  26. g = nltk.Assignment(dom, [])
  27.  
  28. return m.evaluate(query, g)
  29.  
  30.  
  31. def get_series_catches(name):
  32. c=0
  33. for i in bat1:
  34. if bat1[i][0].split()[0] == 'c':
  35. if bat1[i][0].split()[1]==name:
  36. c+=1
  37. elif bat1[i][0].split()[1]=='&' and bat1[i][0].split()[3]==name:
  38. c+=1
  39. for i in bat2:
  40. if bat2[i][0].split()[0] == 'c':
  41. if bat2[i][0].split()[1]==name:
  42. c+=1
  43. elif bat2[i][0].split()[1]=='&' and bat2[i][0].split()[3]==name:
  44. c+=1
  45. for i in bat3:
  46. if bat3[i][0].split()[0] == 'c':
  47. if bat3[i][0].split()[1]==name:
  48. c+=1
  49. elif bat3[i][0].split()[1]=='&' and bat3[i][0].split()[3]==name:
  50. c+=1
  51. for i in bat4:
  52. if bat4[i][0].split()[0] == 'c':
  53. if bat4[i][0].split()[1]==name:
  54. c+=1
  55. elif bat4[i][0].split()[1]=='&' and bat4[i][0].split()[3]==name:
  56. c+=1
  57. for i in bat5:
  58. if bat5[i][0].split()[0] == 'c':
  59. if bat5[i][0].split()[1]==name:
  60. c+=1
  61. elif bat5[i][0].split()[1]=='&' and bat5[i][0].split()[3]==name:
  62. c+=1
  63. return c
Advertisement
Add Comment
Please, Sign In to add comment