1 #
   2 # CC bibliography format parser
   3 # ver 0.2
   4 #
   5 # by Walter A. Aprile
   6 #
   7 """ 
   8 Nicely format into HTML text present in the Current Contents database, in their funky format
   9 also understands BibTex and CiteSeer formats, although I wouldn't bet too heavily on that
  10 
  11 TITLE: Segmentation, tracking and interpretation using panoramic video
  12 AUTHOR: Nicolescu,-M.; Medioni,-G.; Mi-Suen-Lee
  13 AUTHOR AFFILIATION: Integrated Media Syst. Center, Univ. of Southern California, Los Angeles, CA, USA
  14 SOURCE: Proceedings-IEEE-Workshop-on-Omnidirectional-Vision-Cat.-No.PR00704. 2000: 169-74
  15 PUBLISHER: IEEE Comput. Soc, Los Alamitos, CA, USA
  16 NUMBER OF PAGES: viii+175
  17 COUNTRY OF PUBLICATION: USA
  18 RECORD TYPE: Conference-Paper
  19 CONFERENCE DETAILS: Proceedings IEEE Workshop on Omnidirectional Vision. 12 June 2000 Hilton Head Island, SC, USA [IEEE Comput. Soc Tech. Committee on Pattern Anal. & Machine Intelligence]
  20 LANGUAGE: English
  21 ABSTRACT: Choosing the appropriate type of video input is an important issue for any vision-based system and the right decision must take into account the specific requirements of the intended application. We present GlobeAll, a modular four-component prototype for a vision-based Intelligent Room: a panoramic video input component that uses an electronic pan-tilt-zoom camera array, a background learning and foreground extraction component, a tracking component and an interpretation component. In the context of Intelligent Room systems, we establish several qualitative criteria to evaluate their video input component. We use these principles to compare our panoramic video system with two other current solutions-mobile pan-tilt-zoom and wide-angle lens cameras-and we show that electronic pan-tilt-zoom systems best satisfy our criteria.
  22 AVAILABILITY: foograz.pdf
  23 
  24 
  25 """
  26 
  27 
  28 
  29 Dependencies = []
  30 import string
  31 import copy
  32 import re
  33 from MoinMoin.parser import wiki
  34 class Parser:
  35 
  36    default_values = {"AUTHOR":"Unknown Author",
  37                      "TITLE":"Unknown Title",
  38                      "ABSTRACT":"",
  39                      "SOURCE":"No Source",
  40 		     "AVAILABILITY":"",
  41                      "COMMENT":"",
  42                      "LINK":"",
  43                      "COMMENT":"",
  44                      "URL":""
  45                     }
  46         
  47    def __init__(self, raw, request, **kw):
  48         self.raw = raw
  49         self.request = request
  50         self.form = request.form
  51         self._ = request.getText
  52         
  53         
  54    def format(self, formatter):
  55 	attachment_prefix = formatter.page.page_name + "?action=AttachFile&do=get&target="
  56 	data = copy.copy(self.default_values)
  57         raw = self.raw.split('\n')
  58 	cooked = []
  59 	late = ""
  60 	for s in raw:
  61 		if ((s != "\n") or (late != "\n")):
  62 			cooked.append(s)
  63 		late = s
  64 	
  65 	
  66 
  67 	for i in range (0,len(cooked)):
  68 		line = cooked[i]
  69 		# self.request.write(formatter.text(line)+"<BR")
  70 		equalpos = line.find("=")
  71 		colonpos = line.find(":")
  72 		if ((colonpos<0) or ((equalpos >0) and (equalpos < colonpos))):
  73 			separator = "="
  74 		else:
  75 			separator = ":"
  76 
  77 		linecouple = line.split(separator,1)
  78 		if (len(linecouple)==2):
  79 			category = linecouple[0].upper().strip()
  80 			content = linecouple[1].strip(" ").strip(',').strip('"').strip("{").strip("}")
  81 			data[category] = content
  82 		if (len(line)<6 or i==(len(raw)-1)): 
  83 				#This must be an interruption in the record
  84 				#Or we are at the end of the marked up section
  85 				#So we output the data
  86 
  87 			abstract = data["ABSTRACT"]
  88 			availability = data["AVAILABILITY"]
  89 			comment = data["COMMENT"]
  90 			link = data["LINK"]
  91 
  92 			# Hacky fix for CiteSeer
  93 			if ((data["SOURCE"] == self.default_values["SOURCE"]) and (data.has_key("JOURNAL"))):
  94 				source = data["JOURNAL"] + "," + data["VOLUME"]  + "," + data["NUMBER"] + "," + data["PAGES"] + "(" + data["YEAR"] + ")"
  95 			else:
  96 				source = data["SOURCE"]
  97 
  98 			# More CiteSeer hackery
  99 			if (data["URL"] != self.default_values["URL"]):
 100 				link = "http://" + data["URL"]
 101 
 102 			#  Start Formatting Output
 103 			self.request.write(formatter.paragraph(1))
 104 			if (availability!=""):
 105 				self.request.write(formatter.text("*"))
 106 			self.request.write(formatter.text(data["AUTHOR"]))
 107 			self.request.write(formatter.text(" "))
 108 			self.request.write(formatter.strong(1))
 109 			self.request.write(formatter.text(data["TITLE"]))
 110 			self.request.write(formatter.strong(0))
 111 			self.request.write(formatter.text(" in "))
 112 			self.request.write(formatter.emphasis(1))
 113 			self.request.write(formatter.text(source))
 114 			self.request.write(formatter.emphasis(0))
 115 			self.request.write(formatter.linebreak())
 116 
 117 			
 118 			
 119 			if (link!=""):
 120 				self.request.write(formatter.url(1,url=link))
 121                                 self.request.write(formatter.text(" (link) "))
 122                                 self.request.write(formatter.url(0))
 123 
 124 			if (abstract!=""):
 125 				self.request.write(formatter.span(1))
 126 				self.request.write(formatter.text(" (abs) "))
 127 				self.request.write(formatter.span(1))
 128 				self.request.write(formatter.text(abstract))
 129 				self.request.write(formatter.span(0))
 130 				self.request.write(formatter.span(0))
 131 
 132 			if (comment!=""):
 133 				self.request.write(formatter.span(1))
 134 				self.request.write(formatter.text(" (comment) "))
 135 				self.request.write(formatter.span(1))
 136 				self.request.write(formatter.text(comment))
 137 				self.request.write(formatter.span(0))
 138 				self.request.write(formatter.span(0))
 139 
 140 			if (availability!=""):
 141 				# self.request.write(formatter.text("QUACKY %s") % availability)
 142 				if (availability.find("http://")!=-1):
 143 					URL = re.findall("http://[^ ]*",availability)[0]
 144 					self.request.write(formatter.url(1,url=URL))
 145 					self.request.write(formatter.text("remote file"))
 146 					self.request.write(formatter.url(0))
 147 					
 148 				elif (availability.find(".pdf")!=-1):
 149 					URL = attachment_prefix + re.findall("[^ ]*.pdf",availability)[0]
 150 					self.request.write(formatter.url(1,url=URL))
 151 					self.request.write(formatter.text("wiki pdf"))
 152 					self.request.write(formatter.url(0))
 153 				elif (availability.find("paper")==0):
 154 					self.request.write(formatter.text("hardcopy"))
 155 				else:
 156 					self.request.write(formatter.text("availability?"))
 157 					
 158 
 159 		        self.request.write(formatter.paragraph(0))
 160 
 161 			data = copy.copy(self.default_values)
 162         
 163         
 164         

MoinMoin: parser/CC.py (last edited 2007-10-29 19:12:03 by localhost)