from csc.conceptnet.models import * from csc.util import foreach target_frame = Frame.objects.get(language=en, relation__name='UsedFor', text='{1} is for {2}') def queryset(): frame = Frame.objects.get(text='{1} are {2}', language=en, relation__name='IsA') got = RawAssertion.objects.filter(language=en, frame=frame) return got def fix(s): if s.surface2.text.startswith('for '): print s newsurf = SurfaceForm.get(s.surface2.text[4:], 'en', auto_create=True) print "=>", print s.correct_assertion(target_frame, s.surface1, newsurf) foreach(queryset(), fix)
from csc.conceptnet.models import * from csc.util import foreach target_frame = Frame.objects.get(language=en, relation__name='ConceptuallyRelatedTo', text='{1} is like {2}') def queryset(): frame = Frame.objects.get(text='{1} is {2}', language=en, relation__name='HasProperty') got = RawAssertion.objects.filter(language=en, frame=frame) return got def fix(s): if s.surface2.text.startswith('like '): print s newsurf = SurfaceForm.get(s.surface2.text[4:], 'en', auto_create=True) print "=>", print s.correct_assertion(target_frame, s.surface1, newsurf) foreach(queryset(), fix)
from csc.conceptnet.models import * from csc.util import foreach def fix_spaces(s): if (s.surface1.text.startswith(' ') or s.surface2.text.startswith(' ')): print s newsurf1 = SurfaceForm.get(s.surface1.text.strip(), s.language, auto_create=True) newsurf2 = SurfaceForm.get(s.surface2.text.strip(), s.language, auto_create=True) print "=>", print s.correct_assertion(s.frame, newsurf1, newsurf2) s.save() foreach(RawAssertion.objects.filter(language__id='zh-Hant'), fix_spaces)
from csc.conceptnet.models import * from csc.util import foreach target_frame = Frame.objects.get(language=en, relation__name='UsedFor', text='{1} is for {2}') def queryset1(): frame = Frame.objects.get(text='{1} is {2}', language=en, relation__name='HasProperty') got = RawAssertion.objects.filter(language=en, frame=frame) return got def queryset2(): frame = Frame.objects.get(text='{1} is {2}', language=en, relation__name='ReceivesAction') got = RawAssertion.objects.filter(language=en, frame=frame) return got def fix_is_for(s): if s.surface2.text.startswith('for '): print s newsurf = SurfaceForm.get(s.surface2.text[4:], 'en', auto_create=True) print "=>", print s.correct_assertion(target_frame, s.surface1, newsurf) foreach(queryset1(), fix_is_for)
target_frame = Frame.objects.get(language=en, relation__name='UsedFor', text='{1} is for {2}') def queryset1(): frame = Frame.objects.get(text='{1} is {2}', language=en, relation__name='HasProperty') got = RawAssertion.objects.filter(language=en, frame=frame) return got def queryset2(): frame = Frame.objects.get(text='{1} is {2}', language=en, relation__name='ReceivesAction') got = RawAssertion.objects.filter(language=en, frame=frame) return got def fix_is_for(s): if s.surface2.text.startswith('for '): print s newsurf = SurfaceForm.get(s.surface2.text[4:], 'en', auto_create=True) print "=>", print s.correct_assertion(target_frame, s.surface1, newsurf) foreach(queryset1(), fix_is_for)