# Path: conceptnet/corpus/models.py
# class ScoredModel(object):
# class Language(models.Model):
# class Sentence(models.Model, ScoredModel):
# class TaggedSentence(models.Model):
# class DependencyParse(models.Model):
# class Frequency(models.Model):
#     class Meta:
#     def get_rating(self, user):
#     def set_rating(self, user, val, activity=None):
#     def update_score(self):
# def denormalize_votes(sender, instance, created=False, **kwargs):
# def get_lang(lang_code):
#     def __str__(self):
#     def get(id):
#     def nl(self):
#     def __unicode__(self):
#     def update_consistency(self):
#     def tagged_words(self):
#     def __unicode__(self):
#     def from_string(sentence_id, depstring):
#     def __unicode__(self):
#     def __unicode__(self):
#     _PARSE_RE = re.compile(r"(.+)\((.*)-(\d+)'*, (.*)-(\d+)'*\)")


from django.db import models
from django.db.models import Q
from conceptnet.corpus.models import Language, Sentence, User, ScoredModel, Frequency
from events.models import Event, Activity
from voting.models import Vote, SCORES
from django.contrib.contenttypes import generic
from csc_utils.cache import cached
from datetime import datetime
from urllib import quote as urlquote
        from django.db.models import F
import re
    def nl_parts_topdown(self):
        frame = Frame.objects.filter(language=self.lang,
        relation=self.relation, goodness__gte=3)[0]
        #surfaces = {}
        same_c1 = RawAssertion.objects.filter(language=self.lang,
            frame__relation=self.relation, surface1__concept=self.concept1)
        try:
            surface1 = same_c1[0].surface1.text
        except IndexError:
            surface1 = self.concept1.some_surface() or self.concept1
            surface1 = surface1.text
        same_c2 = RawAssertion.objects.filter(language=self.lang,
            frame__relation=self.relation, surface2__concept=self.concept2)            
        try:
            surface2 = same_c2[0].surface2.text
        except IndexError:
            surface2 = self.concept2.some_surface() or self.concept2
            surface2 = surface2.text
        return (frame, frame.text, surface1, surface2)

class Concept(models.Model):
    """
    Concepts are the nodes of ConceptNet. They are the things that people have
    common sense knowledge about.
    
    Concepts are expressed in natural language with
    sets of related words and phrases: for example, "take a picture", "taking
    pictures", "to take pictures", and "you take a picture" are various
    `surface forms`_ of the same Concept.
    """

# Path: conceptnet/corpus/models.py
# class ScoredModel(object):
# class Language(models.Model):
# class Sentence(models.Model, ScoredModel):
# class TaggedSentence(models.Model):
# class DependencyParse(models.Model):
# class Frequency(models.Model):
#     class Meta:
#     def get_rating(self, user):
#     def set_rating(self, user, val, activity=None):
#     def update_score(self):
# def denormalize_votes(sender, instance, created=False, **kwargs):
# def get_lang(lang_code):
#     def __str__(self):
#     def get(id):
#     def nl(self):
#     def __unicode__(self):
#     def update_consistency(self):
#     def tagged_words(self):
#     def __unicode__(self):
#     def from_string(sentence_id, depstring):
#     def __unicode__(self):
#     def __unicode__(self):
#     _PARSE_RE = re.compile(r"(.+)\((.*)-(\d+)'*, (.*)-(\d+)'*\)")


# Path: conceptnet/models.py
from django.db import models
from django.db.models import Q
from conceptnet.corpus.models import Language, Sentence, User, ScoredModel, Frequency
from events.models import Event, Activity
from voting.models import Vote, SCORES
from django.contrib.contenttypes import generic
from csc_utils.cache import cached
from datetime import datetime
from urllib import quote as urlquote
        from django.db.models import F
import re

    def nl_parts_topdown(self):
        frame = Frame.objects.filter(language=self.lang,
        relation=self.relation, goodness__gte=3)[0]
        #surfaces = {}
        same_c1 = RawAssertion.objects.filter(language=self.lang,
            frame__relation=self.relation, surface1__concept=self.concept1)
        try:
            surface1 = same_c1[0].surface1.text
        except IndexError:
            surface1 = self.concept1.some_surface() or self.concept1
            surface1 = surface1.text
        same_c2 = RawAssertion.objects.filter(language=self.lang,
            frame__relation=self.relation, surface2__concept=self.concept2)            
        try:
            surface2 = same_c2[0].surface2.text
        except IndexError:
            surface2 = self.concept2.some_surface() or self.concept2
            surface2 = surface2.text
        return (frame, frame.text, surface1, surface2)

class Concept(models.Model):
    """
    Concepts are the nodes of ConceptNet. They are the things that people have
    common sense knowledge about.
    
    Concepts are expressed in natural language with
    sets of related words and phrases: for example, "take a picture", "taking
    pictures", "to take pictures", and "you take a picture" are various
    `surface forms`_ of the same Concept.
    """

    language = models.ForeignKey(Language)