User:Eleanorg/2.1/Prototypes/transcription: Difference between revisions

From XPUB & Lens-Based wiki
Line 35: Line 35:


===proces input form===
===proces input form===
Change status of that img in db to 'finished'.  
Change status of that img in db to 'finished'.




(this version just prints the text submitted)
<source lang="python">
#!/usr/bin/python
#-*- coding:utf-8 -*-
import cgi
import cgitb; cgitb.enable()
#import pymongo
#from pymongo import Connection
#======== get text from input form
form = cgi.FieldStorage() # Grabs whatever input comes from form
text = form.getvalue("text", "//this part was transcribed blank//")
title = form.getvalue("title")
#========= put it in the db
#connection = Connection()
#myDB = connection['consentTexts1']
#collection = myDB.collection 
#if title:
# collection.update( {'title': title}, {"$set":{'status': 'done', 'text': text}} )
#========= print thank you
print """
<!DOCTYPE html>
<html>
  <head>
    <title></title>
  </head>
 
<body>""" + title + "<br />" + text + """
</body>
</html>
"""
</source>


===display transcribed texts===
===display transcribed texts===
CGI displays an html doc of all transcribed db entries.
CGI displays an html doc of all transcribed db entries.

Revision as of 16:03, 21 September 2012

Asking people to transcribe text and submit it to a central document. Will they transcribe verbatim?

make db of imgs waiting to be transcribed

#!/usr/bin/python
#-*- coding:utf-8 -*-

import pymongo
from pymongo import Connection


#======== create db with img files

connection = Connection()
myDB = connection['consentTexts1']
collection = myDB.collection  

for x in range(0,11):
	title = "text" + str(x)
	fileName = "img" + str(x) + ".jpg"
	
	
	sentence = {'title': title, 'file': fileName, 'status': "waiting", 'text':" " }
	print sentence
	collection.insert(sentence)

input form

Show an img waiting to be transcribed, with input form for transcription.

proces input form

Change status of that img in db to 'finished'.


(this version just prints the text submitted)

#!/usr/bin/python
#-*- coding:utf-8 -*-

import cgi
import cgitb; cgitb.enable()
#import pymongo
#from pymongo import Connection

#======== get text from input form

form = cgi.FieldStorage()			# Grabs whatever input comes from form
text = form.getvalue("text", "//this part was transcribed blank//")		
title = form.getvalue("title")



#========= put it in the db

#connection = Connection()
#myDB = connection['consentTexts1']
#collection = myDB.collection  

#if title:
#	collection.update( {'title': title}, {"$set":{'status': 'done', 'text': text}} )

#========= print thank you
print """
<!DOCTYPE html>
<html>
  <head>
    <title></title>
  </head>
  
<body>""" + title + "<br />" + text + """

</body>

</html>



"""

display transcribed texts

CGI displays an html doc of all transcribed db entries.