Beispiel #1
0
def orderingRun(paper):
   methods = [ method(paper) for method in AVAILABLE_METHODS ]
   res = {}

   for methodObj in methods:
      hits = 0
      misses = 0

      for i in range(0, len(paper.citations)):
         cite = paper.citations[i]
         correctReference = paper.citationKey[i]

         # Skip citations that do not have a reference.
         if not paper.references.has_key(correctReference['main']):
            continue

         guess = methodObj.guess(cite, paper)
         if guess in correctReference['allowed']:
            hits += 1
         elif guess:
            misses += 1

      print "{} -- Misses: {}".format(methodObj.__class__.__name__, misses)
      res[methodObj.__class__.__name__] = misses

   print ''
   res = sorted(res.iteritems(), key=operator.itemgetter(1))
   for (methodName, misses) in res:
      print methodName
Beispiel #2
0
    def doReq(self, req):

        req->JSON

        ?import method ?

        res = method(*args)

        JSON->resp

        return resp
Beispiel #3
0
def normalRun(paper):
   methods = [ method(paper) for method in AVAILABLE_METHODS ]

   hits = 0
   misses = 0
   # Don't count references without any information
   total = 0

   # foaad counting system
   hitRefs = set()

   for i in range(0, len(paper.citations)):
      cite = paper.citations[i]
      correctReference = paper.citationKey[i]

      # Skip citations that do not have a reference.
      if not paper.references.has_key(correctReference['main']):
         continue

      total += 1

      # Don't count if a value is unreported (earlier phases of the pipeline do not report).
      # But make sure to only count a hit once.
      reportedValue = False
      for methodObj in methods:
         guess = methodObj.guess(cite, paper)
         if guess:
            if guess in correctReference['allowed']:
               hits += 1
               hitRefs.add(paper.references[guess].title.strip().upper())
            else:
               misses += 1
            break

   if total == 0:
      return None

   return ((float(hits) / total),
           "{:.2%}\t(Hits: {},\tMisses: {},\tTotal: {})\t{}".format((float(hits) / total), hits, misses, total, paper.title),
           hitRefs)
Beispiel #4
0
def debugRun(paper):
   methods = [ method(paper) for method in AVAILABLE_METHODS ]

   hits = 0
   misses = 0

   for i in range(0, len(paper.citations)):
      cite = paper.citations[i]
      correctReference = paper.citationKey[i]

      # Skip citations that do not have a reference.
      if not paper.references.has_key(correctReference['main']):
         print "Warning: There is no citation information found for citation #{}, skipping".format(correctReference['main'])
         continue

      print '---------'
      print cite.paragraphContext.raw
      print cite.sentenceContext.raw
      print cite.sentenceContext.marked
      res = ''
      # Don't count if a value is unreported (earlier phases of the pipeline do not report).
      # But make sure to only count a hit once.
      reportedValue = False
      for methodObj in methods:
         guess = methodObj.guess(cite, paper)
         res += methodObj.__class__.__name__ + "(" + str(guess) + '), '
         if not reportedValue and guess:
            reportedValue = True
            if guess in correctReference['allowed']:
               hits += 1
            else:
               misses += 1

      print res
      print "Actual Reference: {0}".format(correctReference['allowed'])
      print '---------'

   print "HITS: {0} / {1} ({2})".format(hits, len(paper.citations), hits / float(len(paper.citations)))
   print "Misses: {0}".format(misses)