idiolectalyzer_feeder.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import sys
  2. import web
  3. import re
  4. sys.path.append(".")
  5. import idiolectalyzer
  6. import collections
  7. def countWordsIn(sample):
  8. a = len(sample.split() )
  9. return a
  10. def checkWordCount (sample):
  11. goodCount = 0
  12. sampleWordcount = countWordsIn(sample)
  13. if sampleWordcount > 1000:
  14. goodCount = 1
  15. return goodCount
  16. def gatherVariables():
  17. #findRepeatWords_minFreq,
  18. #findRepeatWords_context (all,non-function),
  19. #findRepeatWords_maxWords
  20. #howCommonIs_context(all_google,google_1965)
  21. return
  22. def getTextSampleCommandLine():
  23. done = 0
  24. while done == 0:
  25. sample = raw_input("Enter first text sample, minimum 1000 words:")
  26. sampleWordCount = countWordsIn( sample ),'\n'
  27. print sampleWordCount
  28. counted = checkWordCount( sample )
  29. if counted == 0:
  30. print "Sample text must be at least 1000 words."
  31. sample = "blank"
  32. else:
  33. done = 1
  34. sample = idiolectalyzer.stripData(sample)
  35. return sample
  36. def getTextSampleWeb():
  37. urls = ( '/' , 'index.html')
  38. render = web.template.render('web/')
  39. app = web.application(globals())
  40. app.run()
  41. done = 0
  42. while done == 0:
  43. sample = web.input(sample=None)
  44. done = 1
  45. return sample
  46. if __name__ == '__main__':
  47. print "Idiolectalyzer 0.1\n\n"
  48. #gatherVariables()
  49. #textSample = getTextSampleCommandLine()
  50. getTextSampleWeb()
  51. print "\nSo it was written"