import sys
sys.path.insert(0, '..')
import settings
from util import queryset_foreach
from events.models import Event
from voting.models import Vote
from datetime import datetime
from conceptnet4.models import Rating

def rating_to_vote(r):
    obj = r.sentence or r.raw_assertion or r.assertion
    score = 0
    if r.score > 0: score=1
    if r.score < 0: score=-1
    Vote.objects.record_vote(obj, r.user, score)
    ev = Event.record_event(obj, r.user, r.activity)
    ev.timestamp = r.updated
    ev.save()

def progress_callback(num, den):
    print num, '/', den

queryset_foreach(Rating.objects.all(), rating_to_vote)

Ejemplo n.º 2
0
import sys
sys.path.insert(0, '..')
import settings
from util import queryset_foreach
from events.models import Event
from voting.models import Vote
from datetime import datetime
from conceptnet4.models import Rating


def rating_to_vote(r):
    obj = r.sentence or r.raw_assertion or r.assertion
    score = 0
    if r.score > 0: score = 1
    if r.score < 0: score = -1
    Vote.objects.record_vote(obj, r.user, score)
    ev = Event.record_event(obj, r.user, r.activity)
    ev.timestamp = r.updated
    ev.save()


def progress_callback(num, den):
    print num, '/', den


queryset_foreach(Rating.objects.all(), rating_to_vote)
import sys
sys.path.insert(0, '..')
import settings

from util import queryset_foreach
from corpus.models import DependencyParse

def generalize_dep(dep):
    if dep.linktype.startswith('prep_') or dep.linktype.startswith('prepc_'):
        newlt = 'prep'
    elif dep.linktype.startswith('conj_'):
        newlt = 'conj'
    else: return

    newdep = DependencyParse(sentence_id=dep.sentence_id,
                             linktype=newlt,
                             word1=dep.word1,
                             word2=dep.word2,
                             index1=dep.index1,
                             index2=dep.index2)
    newdep.save()

def progress_callback(num, den):
    print num, '/', den

queryset_foreach(DependencyParse.objects.all(), generalize_dep)

import sys
sys.path.insert(0, '..')
import settings

from util import queryset_foreach
from corpus.models import DependencyParse


def generalize_dep(dep):
    if dep.linktype.startswith('prep_') or dep.linktype.startswith('prepc_'):
        newlt = 'prep'
    elif dep.linktype.startswith('conj_'):
        newlt = 'conj'
    else:
        return

    newdep = DependencyParse(sentence_id=dep.sentence_id,
                             linktype=newlt,
                             word1=dep.word1,
                             word2=dep.word2,
                             index1=dep.index1,
                             index2=dep.index2)
    newdep.save()


def progress_callback(num, den):
    print num, '/', den


queryset_foreach(DependencyParse.objects.all(), generalize_dep)