/gongshi.lua

https://code.google.com/p/google-pinyin-api/ · Lua · 274 lines · 237 code · 27 blank · 10 comment · 122 complexity · cc90d3f49313a5f4d623137e570dbea1 MD5 · raw file

  1. -- encoding: UTF-8
  2. ------------------------------------------------
  3. -- ??????????
  4. -- ??: 0.1
  5. -- ??: Mike
  6. -- ????: http://code.google.com/p/google-pinyin-api/
  7. --
  8. -- ?????GPLv3??
  9. ------------------------------------------------
  10. function liangjiaohe (input)
  11. if input == "a" then
  12. return {
  13. {["suggest"] = "a", ["help"] = "sin(A+B)"},
  14. {["suggest"] = "b", ["help"] = "sin(A-B)"},
  15. {["suggest"] = "c", ["help"] = "cos(A+B)"},
  16. {["suggest"] = "d", ["help"] = "cos(A-B)"},
  17. {["suggest"] = "e", ["help"] = "tan(A+B)"},
  18. {["suggest"] = "f", ["help"] = "tan(A-B)"},
  19. {["suggest"] = "g", ["help"] = "ctg(A+B)"},
  20. {["suggest"] = "h", ["help"] = "ctg(A-B)"},
  21. }
  22. end
  23. end
  24. function beijiao (input)
  25. if input == "b" then
  26. return {
  27. {["suggest"] = "a", ["help"] = "sin2A"},
  28. {["suggest"] = "b", ["help"] = "cos2A"},
  29. {["suggest"] = "c", ["help"] = "tag2A)"},
  30. {["suggest"] = "d", ["help"] = "ctg2A"},
  31. }
  32. end
  33. end
  34. function banjiao (input)
  35. if input == "c" then
  36. return {
  37. {["suggest"] = "a", ["help"] = "sin(A/2)"},
  38. {["suggest"] = "b", ["help"] = "cos(A/2)"},
  39. {["suggest"] = "c", ["help"] = "tag(A/2))"},
  40. {["suggest"] = "d", ["help"] = "ctg(A/2)"},
  41. }
  42. end
  43. end
  44. function hechahuaji (input)
  45. if input == "d" then
  46. return {
  47. {["suggest"] = "a", ["help"] = "sinA+sinB"},
  48. {["suggest"] = "b", ["help"] = "sinA-sinB"},
  49. {["suggest"] = "c", ["help"] = "cosA+cosB"},
  50. {["suggest"] = "d", ["help"] = "cosA-cosB"},
  51. }
  52. end
  53. end
  54. function jihuahecha (input)
  55. if input == "e" then
  56. return {
  57. {["suggest"] = "a", ["help"] = "sinAcosB"},
  58. {["suggest"] = "b", ["help"] = "cosAsinB"},
  59. {["suggest"] = "c", ["help"] = "sinAsinB"},
  60. {["suggest"] = "d", ["help"] = "cosAcosB"},
  61. }
  62. end
  63. end
  64. function wanneng (input)
  65. if input == "f" then
  66. return {
  67. {["suggest"] = "a", ["help"] = "sinA"},
  68. {["suggest"] = "b", ["help"] = "cosA"},
  69. {["suggest"] = "c", ["help"] = "tagA"},
  70. }
  71. end
  72. end
  73. function sanjiao (input)
  74. if #input == 0 then
  75. return {
  76. {["suggest"] = "a", ["help"] = "?????"},
  77. {["suggest"] = "b", ["help"] = "????"},
  78. {["suggest"] = "c", ["help"] = "????"},
  79. {["suggest"] = "d", ["help"] = "????"},
  80. {["suggest"] = "e", ["help"] = "????"},
  81. {["suggest"] = "f", ["help"] = "????"},
  82. }
  83. elseif input == "a" then
  84. return liangjiaohe(input)
  85. elseif input == "aa" then
  86. return "sin(A+B)=sinAcosB+cosAsinB"
  87. elseif input == "ab" then
  88. return "sin(A-B)=sinAcosB-sinBcosA"
  89. elseif input == "ac" then
  90. return "cos(A+B)=cosAcosB-sinAsinB"
  91. elseif input == "ad" then
  92. return "cos(A-B)=cosAcosB+sinAsinB"
  93. elseif input == "ae" then
  94. return "tan(A+B)=(tanA+tanB)/(1-tanAtanB)"
  95. elseif input == "af" then
  96. return "tan(A-B)=(tanA-tanB)/(1+tanAtanB)"
  97. elseif input == "ag" then
  98. return "ctg(A+B)=(ctgActgB-1)/(ctgB+ctgA)"
  99. elseif input == "ah" then
  100. return "ctg(A-B)=(ctgActgB+1)/(ctgB-ctgA)"
  101. elseif input == "b" then
  102. return beijiao(input)
  103. elseif input == "ba" then
  104. return "sin(A-B)=2sinAcosA"
  105. elseif input == "bb" then
  106. return "cos2A=(cosA)^2-(sinA)^2=2(cosA)^2-1=1-2(sinA)^2"
  107. elseif input == "bc" then
  108. return "tag2A=2tanA/[1-(tanA)^2]"
  109. elseif input == "bd" then
  110. return "ctg2A=[ctgA)^2-1]/2ctgA"
  111. elseif input == "c" then
  112. return banjiao(input)
  113. elseif input == "ca" then
  114. return "sin(A/2)=?[(1-cosA)/2]"
  115. elseif input == "cb" then
  116. return "cos(A/2)=?[(1+cosA)/2]"
  117. elseif input == "cc" then
  118. return "tan(A/2)=?[(1-cosA)/(1+cosA)]"
  119. elseif input == "cd" then
  120. return "ctg(A/2)=?[(1+cosA)/(1-cosA)]"
  121. elseif input == "d" then
  122. return hechaohuaji(input)
  123. elseif input == "da" then
  124. return "sinA+sinB=2sin[(A+B)/2]cos[(A-B)/2]"
  125. elseif input == "db" then
  126. return "sinA-sinB=2cos[(A+B)/2]sin[(A-B)/2]"
  127. elseif input == "dc" then
  128. return "cosA+cosB=2cos[(A+B)/2]cos[(A-B)/2]"
  129. elseif input == "dd" then
  130. return "cosA-cosB=-2sin[(A+B)/2]sin[(A-B)/2] "
  131. elseif input == "e" then
  132. return hechaohuaji(input)
  133. elseif input == "ea" then
  134. return "sinAcosB=(1/2)[sin(A+B)+sin(A-B)]"
  135. elseif input == "eb" then
  136. return "cosAsinB=(1/2)[sin(A+B)-sin(A-B)]"
  137. elseif input == "ec" then
  138. return "sinAsinB=-(1/2)[cos(A+B)-cos(A-B)]"
  139. elseif input == "ed" then
  140. return "cosAcosB=(1/2)[cos(A+B)+cos(A-B)]"
  141. elseif input == "f" then
  142. return wanneng(input)
  143. elseif input == "fa" then
  144. return "sinA=2tan(A/2)/[1+tan^2(A/2)]"
  145. elseif input == "fb" then
  146. return "cosA=[1-tan^2(A/2)]/[1+tan^2(A/2)]"
  147. elseif input == "fc" then
  148. return "tanA=2tan(A/2)/[1-tan^2(A/2)]"
  149. end
  150. end
  151. function daoshu (input)
  152. if #input == 0 then
  153. return {
  154. {["suggest"] = "a", ["help"] = "C(??)"},
  155. {["suggest"] = "b", ["help"] = "x^a"},
  156. {["suggest"] = "c", ["help"] = "a^x"},
  157. {["suggest"] = "d", ["help"] = "e^x"},
  158. {["suggest"] = "e", ["help"] = "loga(x)"},
  159. {["suggest"] = "f", ["help"] = "lnx"},
  160. {["suggest"] = "g", ["help"] = "sinx"},
  161. {["suggest"] = "h", ["help"] = "cosx"},
  162. {["suggest"] = "l", ["help"] = "tagx"},
  163. {["suggest"] = "j", ["help"] = "ctgx"},
  164. {["suggest"] = "k", ["help"] = "secx"},
  165. {["suggest"] = "l", ["help"] = "cscx"},
  166. {["suggest"] = "m", ["help"] = "arcsinx"},
  167. {["suggest"] = "n", ["help"] = "arccosx"},
  168. {["suggest"] = "o", ["help"] = "arctagx"},
  169. {["suggest"] = "p", ["help"] = "arcctgx"},
  170. }
  171. elseif input == "a" then
  172. return "(C)'=0"
  173. elseif input == "b" then
  174. return "(x^a)'=ax^(a-1)"
  175. elseif input == "c" then
  176. return "(a^x)'=a^xˇlna"
  177. elseif input == "d" then
  178. return "(e^x)'=e^x"
  179. elseif input == "e" then
  180. return "(loga(x))'=1/(xˇlna)"
  181. elseif input == "f" then
  182. return "(lnx)'=1/x"
  183. elseif input == "g" then
  184. return "(sinx)'=cosx"
  185. elseif input == "h" then
  186. return "(cosx)'=-sinx"
  187. elseif input == "i" then
  188. return "(tagx)'=(secx)^2"
  189. elseif input == "j" then
  190. return "(ctgx)'=-(cscx)^2"
  191. elseif input == "k" then
  192. return "(secx)'=secxtagx"
  193. elseif input == "l" then
  194. return "(cscx)'=cscxctgx"
  195. elseif input == "m" then
  196. return "(arcsinx)'=1/?(1-x^2)"
  197. elseif input == "n" then
  198. return "(arccosx)'=-1/?(1-x^2)"
  199. elseif input == "o" then
  200. return "(arctagx)'=1/(1+x^2)"
  201. elseif input == "p" then
  202. return "(arcctgx)'=-1/(1+x^2)"
  203. end
  204. end
  205. function jifen (input)
  206. if #input == 0 then
  207. return {
  208. {["suggest"] = "a", ["help"] = "?0ˇdx"},
  209. {["suggest"] = "b", ["help"] = "?x^aˇdx"},
  210. {["suggest"] = "c", ["help"] = "?1/xˇdx"},
  211. {["suggest"] = "d", ["help"] = "?a^xˇdx"},
  212. {["suggest"] = "e", ["help"] = "?e^xˇdx"},
  213. {["suggest"] = "f", ["help"] = "?sinxˇdx"},
  214. {["suggest"] = "g", ["help"] = "?cosxˇdx"},
  215. {["suggest"] = "h", ["help"] = "?(secx)^2ˇdx"},
  216. {["suggest"] = "l", ["help"] = "?(cscx)^2ˇdx"},
  217. {["suggest"] = "j", ["help"] = "?1/?(1-x^2)ˇdx"},
  218. {["suggest"] = "k", ["help"] = "?1/(1+x^2)ˇdx"},
  219. }
  220. elseif input == "a" then
  221. return "?0ˇdx=C"
  222. elseif input == "b" then
  223. return "?x^aˇdx=1/(a+1)ˇx(a+1)+C (a?-1)"
  224. elseif input == "c" then
  225. return "?1/xˇdx=ln|x|+C"
  226. elseif input == "d" then
  227. return "?a^xˇdx=1/lnxˇa^x+C (a>0, a?-1)"
  228. elseif input == "e" then
  229. return "?e^xˇdx=e^x+C"
  230. elseif input == "f" then
  231. return "?sinxˇdx=-cosx+C"
  232. elseif input == "g" then
  233. return "?cosxˇdx=sinx+C"
  234. elseif input == "h" then
  235. return "?(secx)^2ˇdx=tagx+C"
  236. elseif input == "i" then
  237. return "?(cscx)^2ˇdx=-ctgx+C"
  238. elseif input == "j" then
  239. return "?1/?(1-x^2)ˇdx=arcsinx+C=-arccosx+C"
  240. elseif input == "k" then
  241. return "?1/(1+x^2)ˇdx=arctagx+C=-arcctgx+C"
  242. end
  243. end
  244. ------------
  245. ime.register_command("fj", "jifen", "??????")
  246. ime.register_command("fd", "daoshu", "????????")
  247. ime.register_command("fs", "sanjiao", "??????")