17 Commity f839bdd0b2 ... 16853c28e8

Autor SHA1 Správa Dátum
  estelendur 16853c28e8 Merge branch 'master' of notabug.org:estelendur/workscripts 9 rokov pred
  esty b3b5eb53b5 Added leadlist.py 9 rokov pred
  esty 468a50fa0f Hacky ugly fix to display issue with regex/scan 9 rokov pred
  esty 8564ba3e70 Commented indep_short and indep_long in indepcites 9 rokov pred
  esty 6f3d125be7 Added sort function for weird citations 9 rokov pred
  estelendur e35d56f4cf Merge branch 'master' of gitorious.org:estelendur/estelendur 9 rokov pred
  estelendur 129e25fdfc Added indepcites.rb 9 rokov pred
  esty 5b7ba9748e Made the regex do the thing 10 rokov pred
  Matt Arnold 07c2bf1fe8 Added sample file and removed confidential data oops 10 rokov pred
  estelendur 417af71292 Updated leadlist to do all tasks, not just list of leads 10 rokov pred
  estelendur de0a4ebf9e Changed CR to LF 10 rokov pred
  estelendur 92fb6fe05d Fixed filesystem nonsense 10 rokov pred
  estelendur fe880dd837 Merge branch 'master' of gitorious.org:estelendur/estelendur 10 rokov pred
  estelendur fe5cf52197 Added test file 10 rokov pred
  esty 2220d6e735 fixed space 10 rokov pred
  estelendur e805dee168 Updated leadlist.rb 10 rokov pred
  estelendur 41a5d9723a Added leadlist script 10 rokov pred
4 zmenil súbory, kde vykonal 173 pridanie a 0 odobranie
  1. 69 0
      indepcites.rb
  2. 37 0
      leadlist.py
  3. 38 0
      leadlist.rb
  4. 29 0
      sample.txt

+ 69 - 0
indepcites.rb

@@ -0,0 +1,69 @@
+# Author: Esty Thomas
+# License: GPL v3.0
+
+# If the list of authors will return a search term 
+# under 2048 characters, indep() will use this
+# which simply returns a string of the format
+# author:'name 1' OR author:'name 2' etc
+def indep_short(authl)
+    authors=authl.join("' OR author:'")
+    authors="author:'"+authors+"'"
+    return authors
+end
+
+# If the list of authors will return a search term
+# over 2048 characters, indep() will use this
+# which recursively splits the list until each
+# separate output term will be under 2048 characters
+# and returns them in an array.
+# It's not the prettiest hack but it will do until
+# I start figuring out how to make this into a browser
+# extension or something.
+def indep_long(authl)
+    half = (authl.length/2).floor
+    authl1 = authl.take(half)
+    authl2 = authl.drop(half)
+    authors1 = "author:'"+authl1.join("' OR author:'")+"'"
+    authors2 = "author:'"+authl2.join("' OR author:'")+"'"
+    if (authors1.length>2048) && (authors2.length<2048)
+        return [indep_long(authl1), authors2] #split authl1
+    elsif (authors1.length<2048) && (authors2.length>2048)
+        return [authors1, indep_long(authl2)] #split authl2
+    elsif (authors1.length>2048) && (authors2.length>2048)
+        return [indep_long(authl1), indep_long(authl2)] #split both
+    else
+        return [authors1, authors2]
+    end
+end
+
+# only use 'sort' when you have an author list like this:
+# "Last, First, First Last, First Last, and First Last"
+# it will give you the author list back like this:
+# "First Last, First Last, First Last, First Last"
+# so you can put it into 'indep'
+def sort(auth) 
+    authl = auth.split(", ")
+    authl[1] = authl[1] + " " + authl[0]
+    authl = authl.drop(1)
+    last = authl[-1]
+    lastl = last.split(" ")
+    lastnew = lastl.drop(1).join(" ")
+    authl[-1] = lastnew
+    return authl.join(", ")
+end
+
+# this will give you search terms you can use in Google Scholar
+# use this for author lists like this:
+# "First Last, First Last, First Last, First Last"
+# If the list starts "Last, First" and ends "and First Last"
+# put it into 'sort' and use the result
+def indep(auth)
+    authl = auth.split(", ")
+    if (auth.length+9+(authl.length-1)) < 2048
+        return indep_short(authl)
+    else
+        return indep_long(authl)
+    end
+end
+
+

+ 37 - 0
leadlist.py

@@ -0,0 +1,37 @@
+import re
+
+def report(evals):
+    task = re.compile(r"\n\n(\D*:.*)\n1\.")
+    tasks = task.findall(evals)
+    s = re.compile(r"\n?(.*SS.*)\n")
+    ss = s.findall(evals)
+    listend = re.compile(r"\n(\d+)\.\s?\n")
+    listends = listend.findall(evals)
+    lead = re.compile(r"\((\d+)\)")
+    leads = lead.findall(evals)
+    i = 0
+    reportl = []
+    while i < (len(leads)-1):
+        item = leads[i]
+        if leads.count(item) > 1:
+            reportl.append("%s (%d)" % (item, leads.count(item)))
+        else:
+            reportl.append("{}".format(item))
+        i += 1
+    i = len(listends) # final element of listends
+    k = len(tasks)-1 # final element of tasks
+    while i > 0:
+        if int(listends[i-1]) == len(leads)+1:
+            tasks[k] = ""
+        else:
+            t = re.compile(r"(.*):")
+            tsk = t.findall(tasks[k])[0]
+            tasks[k] = "{} ({})".format(tsk, int(listends[i-1][0])-1)
+        i -= 1
+        k -= 1
+    report = "Left evaluation messages ({}): {}".format(len(leads), \
+            ", ".join(list(set(reportl))))
+    print "\n".join(ss)
+    print "\n".join(tasks)
+    print report
+

+ 38 - 0
leadlist.rb

@@ -0,0 +1,38 @@
+#!/usr/bin/env ruby
+# Takes a long daily work report (sample.txt) and formats it into a short form
+# Author: estelendur
+
+def report(evals)
+    tasks = evals.scan(/^\n?(\D*:.*)\n/)
+    listends = evals.scan(/\n(\d+)\.\s?$/)
+    leads = evals.scan(/\((\d+)\)/)
+    i = 0
+    reportl = []
+    while i < (leads.length-1) do
+        item = leads[i]
+        if leads.count(item) > 1
+            reportl << item[0]+" (#{leads.count(item)})"
+        else
+            reportl << item[0]
+        end
+        i += 1
+    end
+    i = listends.length # final element of listends
+    k = tasks.length-1 # final element of tasks
+    while i > 0 do
+        if Integer(listends[i-1][0]) == leads.length+1 # won't work properly if i've done anything as many times as leaving eval messages
+            tasks[k][0] = ""
+            i -= 1
+            k -= 1
+        else
+            tasks[k] = "#{tasks[k][0].scan(/(.*):/)[0][0]} " +\
+                "(#{Integer(listends[i-1][0])-1})"
+            i -= 1
+            k -= 1
+        end
+    end
+    report = "Left evaluation messages (#{leads.length}): "+\
+        reportl.uniq.join(", ")+"\n\n"
+    puts report
+    puts tasks
+end

+ 29 - 0
sample.txt

@@ -0,0 +1,29 @@
+Tertiary task for John Smith: 1 hr
+Tertiary task for Jane Ng: .75 hr
+
+Left eval messages:
+1. Martin Reddy (3298): message
+2. Karl Koenig (3248): message
+3. Jefferson Mbuye (5284): message
+4. Feng Zhang (6458): message
+5. Li Wu (6500): message
+6. Seyed Moghaddam (6491): message
+7. Maryam Moghri (6476): message
+8. Philip Ericsson (6512): message
+9. Hilo Nguyen (4953): message
+10. 
+
+Built leads:
+1. Feng Zhang
+2. Philip Ericsson
+3. Wang Li
+4. Hilo Nguyen
+5. 
+
+Sent eval emails:
+1. Matt Arnold
+2. Kellan Birch
+3. 
+
+
+