This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn parse-lines [filename] | |
(with-open [rdr (clojure.java.io/reader filename)] | |
(line-seq rdr))) | |
(defn rhyme-list [] | |
(parse-lines "Documents/dev/rhyme-finder/rhymes.txt")) | |
;; (count (rhyme-list)) | |
;; IOException Stream closed java.io.BufferedReader.ensureOpen (BufferedReader.java:97) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(doc) { | |
if(doc.base_doc === "CouchUser") { | |
var ll = new Date(doc.last_login); | |
var eula_date = new Date("2012-11-01"); | |
if (!(doc.eula.signed) && (ll > eula_date ) { | |
emit(doc.username, doc.last_login, null); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rhyme-finder.core> (def poem-line (nth (get-poem "poems/test.txt") 2)) | |
#'rhyme-finder.core/poem-line | |
rhyme-finder.core> (clojure.string/split poem-line #"\s") | |
["It" "is" "not" "quite" "the" "best"] | |
rhyme-finder.core> (map test-prons (clojure.string/split poem-line #"\s")) | |
(nil ["" "ih" "z"] ["" "n" "aa" "t"] ["" "k" "w" "ay" "t"] ["" "dh" "ah"] ["" "b" "eh" "s" "t"]) | |
rhyme-finder.core> poem-line | |
"It is not quite the best" | |
rhyme-finder.core> (test-prons "it") | |
["" "ih" "t"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; I'm trying to write this rhyme-scheme function which takes a poem(list of lines[strings]) and returns "abab" or "aabb" or "aaaa" for the rhyme scheme of the poem. THe length of the string should be the length of the line in the poems. | |
;I have this function classify-lines, that groups each line by it's end rhyme as shown below | |
;rhyme-finder.core> (classify-lines (get-poem "poems/abab.txt")) | |
;{("ey") ["i'm writing a poem today" "i don't care what you say"], ("eh" "l") ["i hope it turns out swell" "because we're all under a spell"]} | |
; This is how I started out, I'm kinda stuck on how the reduce function should go. | |
(defn rhyme-scheme [poem] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ 'facets': { 'author': { 'facet_filter': { 'and': [ { 'term': { 'is_approved': True}}]}, | |
'terms': { 'field': 'author', 'size': 9999}}, | |
'license': { 'facet_filter': { 'and': [ { 'term': { 'is_approved': True}}]}, | |
'terms': { 'field': 'license', 'size': 9999}}, | |
'project_type': { 'facet_filter': { 'and': [ { 'term': { 'is_approved': True}}]}, | |
'terms': { 'field': 'project_type', | |
'size': 9999}}, | |
'region': { 'facet_filter': { 'and': [ { 'term': { 'is_approved': True}}]}, | |
'terms': { 'field': 'region', 'size': 9999}}}, | |
'filter': { 'and': [{ 'term': { 'is_approved': True}}]}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _visited_in_timeframe_of_birth(case, days): | |
visit_time = _get_time_of_visit_after_birth(case) | |
time_birth = get_related_prop(case, "time_of_birth") or get_add(case) # use add if time_of_birth can't be found | |
if visit_time and time_birth: | |
print type(time_birth) | |
if isinstance(time_birth, datetime.date): | |
time_birth = datetime.combine(time_birth, datetime.time(datetime.now())) #convert date to datetime | |
return time_birth < visit_time < time_birth + timedelta(days=days) | |
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function (doc) { | |
if (doc.doc_type === 'FixtureOwnership') { | |
emit([doc.owner_type + ' by data_item', doc.domain, doc.data_item_id], doc.owner_id); | |
emit(['data_item by ' + doc.owner_type, doc.domain, doc.owner_id], doc.data_item_id); | |
emit(['by data_item and ' + doc.owner_type, doc.domain, doc.data_item_id, doc.owner_id], null); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function (doc) { | |
if (doc.doc_type === 'FixtureOwnership') { | |
emit([doc.owner_type + ' by data_item', doc.domain, doc.data_item_id], doc.owner_id); | |
emit(['data_item by ' + doc.owner_type, doc.domain, doc.owner_id], doc.data_item_id); | |
emit(['by data_item and ' + doc.owner_type, doc.domain, doc.data_item_id, doc.owner_id], null); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pdis_by_id = {} | |
for pt, items in place_data_items.iteritems(): | |
if pt == 'state': | |
for i in items: | |
print "update loop: %s" % i | |
pdis_by_id.update(dict((pdi.fields['id'], pdi) for pdi in items)) | |
tree_root = [] | |
for item in place_data_items["state"]: | |
item._children = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if strict: | |
result = cls.view("domain/domains", | |
key=name, | |
reduce=False, | |
include_docs=True, | |
).first() | |
else: | |
result = cls.view("domain/domains", | |
key=name, |