Ejemplo n.º 1
0
def one_or_more_timeref_redblk(note):
    note = n2vals(note)
    timeCount = ca.daysofweek(note)['daysofweek'] if type(
        ca.daysofweek(note)) == dict else ca.daysofweek(note)[1]
    timeCount += ca.months(note)['months'] if type(
        ca.months(note)) == dict else ca.months(note)[1]
    return 'red' if timeCount > 0 else 'black'
Ejemplo n.º 2
0
def one_or_more_daysofweek_redblk(note):
    note = n2vals(note)
    lines = ca.daysofweek(note)
    if type(lines) == dict:
        val = lines['daysofweek']
    else:
        val = lines[1]
    return 'red' if lines > 0 else 'black'
Ejemplo n.º 3
0
def one_or_more_verbs_redblk(note):
    note = n2vals(note)
    lines = ca.note_verbs(note)
    if type(lines) == dict:
        val = lines['note_verbs']
    else:
        val = lines[1]
    return 'red' if val > 0 else 'black'
Ejemplo n.º 4
0
def one_or_more_verbs_redblk(note):
  note = n2vals(note)
  lines = ca.note_verbs(note)
  if type(lines) == dict:
    val = lines['note_verbs']
  else:
    val = lines[1]    
  return 'red' if val > 0 else 'black'
Ejemplo n.º 5
0
def one_or_more_daysofweek_redblk(note):
  note = n2vals(note)
  lines = ca.daysofweek(note)
  if type(lines) == dict:
    val = lines['daysofweek']
  else:
    val = lines[1]      
  return 'red' if lines > 0 else 'black'
Ejemplo n.º 6
0
def one_or_more_lines_multicolor(note):
    note = n2vals(note)
    lines = ca.note_lines(note)
    if type(lines) == dict:
        val = lines['note_lines']
    else:
        val = lines[1]
    if val == 1: return 'black'
    if val in [2, 3, 4, 5]: return 'blue'
    if val in range(6, 12): return 'orange'
    return 'red'
Ejemplo n.º 7
0
def one_or_more_lines_multicolor(note):
  note = n2vals(note)
  lines = ca.note_lines(note)
  if type(lines) == dict:
    val = lines['note_lines']
  else:
    val = lines[1]
  if val == 1: return 'black'
  if val in [2,3,4,5]: return 'blue'
  if val in range(6,12): return 'orange'
  return 'red'
Ejemplo n.º 8
0
def user_note_rank_spearman(u):
    try:
        print u
        import jv3.study.thesis_figures as tfigs
        ff = [note_rank(tfigs.n2vals(n)) for n in u.note_owner.order_by('created')]
        ff = [x['note_rank'] for x in ff if x['note_rank'] is not None]
        reverse_standard = range(len(ff))
        reverse_standard.reverse()
        return r('cor.test')(c(ff),c(reverse_standard),method='spearman')[3][0]
    except :
        import sys
        print sys.exc_info()
    return None
Ejemplo n.º 9
0
def user_note_rank_spearman(u):
    try:
        print u
        import jv3.study.thesis_figures as tfigs
        ff = [
            note_rank(tfigs.n2vals(n))
            for n in u.note_owner.order_by('created')
        ]
        ff = [x['note_rank'] for x in ff if x['note_rank'] is not None]
        reverse_standard = range(len(ff))
        reverse_standard.reverse()
        return r('cor.test')(c(ff), c(reverse_standard),
                             method='spearman')[3][0]
    except:
        import sys
        print sys.exc_info()
    return None
Ejemplo n.º 10
0
def two_or_more_sentences_redblk(note):
  note = n2vals(note)
  senCount = ca.note_sentences(note)['note_sentences'] if type(ca.note_sentences(note)) == dict else ca.note_sentences(note)[1]
  return 'red' if senCount > 1 else 'black'
Ejemplo n.º 11
0
def two_or_more_sentences_redblk(note):
    note = n2vals(note)
    senCount = ca.note_sentences(note)['note_sentences'] if type(
        ca.note_sentences(note)) == dict else ca.note_sentences(note)[1]
    return 'red' if senCount > 1 else 'black'
Ejemplo n.º 12
0
def one_or_more_timeref_redblk(note):
  note = n2vals(note)
  timeCount = ca.daysofweek(note)['daysofweek'] if type(ca.daysofweek(note)) == dict else ca.daysofweek(note)[1]
  timeCount += ca.months(note)['months'] if type(ca.months(note)) == dict else ca.months(note)[1]
  return 'red' if timeCount > 0 else 'black'
Ejemplo n.º 13
0
def one_or_more_todoref_redblk(note):
  note = n2vals(note)
  todoCount = ca.note_todos(note)['note_todos'] if type(ca.note_todos(note) ) == dict else ca.note_todos(note)[1]  
  return 'red' if todoCount > 0 else 'black'
Ejemplo n.º 14
0
def one_or_no_url_redblk(note):
    note = n2vals(note)
    urls = ca.note_urls(note)
    if type(urls) == dict:
        return 'red' if urls['note_urls'] > 0 else 'black'
    return 'red' if urls[1] > 0 else 'black'
Ejemplo n.º 15
0
def initMaxEntModel(encoding, weights):
    maxEntModel = nltk.MaxentClassifier(encoding, weights)
    return maxEntModel


def refClassifier():
    ## Ref and nonRef thingies
    refNotes, nonRefNotes = splitNotes('reference')
    labels = ['reference', 'nonref']
    mapping, weights = getStdMapping()
    encoding = nltk.BinaryMaxentFeatureEncoding(labels, mapping)
    maxEntModel = initMaxEntModel(encoding, weights)


nvals = lambda note: tfigs.n2vals(note)
pos_word = lambda word: nltk.pos_tag([word])[0][1]


def pos_word(word):
    return nltk.pos_tag([word])[0][1]


def word_is_verb(word):
    return pos_word(word) in ["VB", "VBD", "VBG", "VBN", "VBP", "VBZ"]


def word_is_noun(word):
    return pos_word(word) in ["NN", "NNS", "NNP", "NNPS"]

Ejemplo n.º 16
0
def one_or_no_email_redblk(note):
    note = n2vals(note)
    emails = ca.note_emails(note)
    if type(emails) == dict:
        return 'red' if emails['email_addrs'] > 0 else 'black'
    return 'red' if emails[1] > 0 else 'black'
Ejemplo n.º 17
0
def one_or_no_email_redblk(note):
  note = n2vals(note)
  emails = ca.note_emails(note)
  if type(emails) == dict:
    return 'red' if emails['email_addrs'] > 0 else 'black'
  return 'red' if emails[1] > 0 else 'black'
Ejemplo n.º 18
0
def compute_feature_named(feature_name,n):
    if getattr(ca,feature_name,None):
        return getattr(ca,feature_name)(n2vals(n))[feature_name]  ## compute the feature given the note!
    return None
Ejemplo n.º 19
0
            notCat.append(Note.objects.filter(id=k)[0])
    return (cat, notCat)

def initMaxEntModel(encoding, weights):
    maxEntModel = nltk.MaxentClassifier(encoding, weights)
    return maxEntModel

def refClassifier():
    ## Ref and nonRef thingies
    refNotes, nonRefNotes = splitNotes('reference')
    labels = ['reference', 'nonref']
    mapping, weights = getStdMapping()
    encoding = nltk.BinaryMaxentFeatureEncoding(labels, mapping)
    maxEntModel = initMaxEntModel(encoding, weights)

nvals = lambda note : tfigs.n2vals(note)
pos_word = lambda word: nltk.pos_tag([word])[0][1]

def pos_word(word):
    return nltk.pos_tag([word])[0][1]

def word_is_verb(word):
    return pos_word(word) in ["VB","VBD","VBG","VBN","VBP","VBZ"]

def word_is_noun(word):
    return pos_word(word) in ["NN","NNS","NNP","NNPS"]

try:
    pass
    #mem = mem
    #if mem == None:
Ejemplo n.º 20
0
def one_or_more_todoref_redblk(note):
    note = n2vals(note)
    todoCount = ca.note_todos(note)['note_todos'] if type(
        ca.note_todos(note)) == dict else ca.note_todos(note)[1]
    return 'red' if todoCount > 0 else 'black'
Ejemplo n.º 21
0
def one_or_no_url_redblk(note):
  note = n2vals(note)
  urls = ca.note_urls(note)
  if type(urls) == dict:
    return 'red' if urls['note_urls'] > 0 else 'black'
  return 'red' if urls[1] > 0 else 'black'
Ejemplo n.º 22
0
def compute_feature_named(feature_name, n):
    if getattr(ca, feature_name, None):
        return getattr(ca, feature_name)(
            n2vals(n))[feature_name]  ## compute the feature given the note!
    return None