Interpret the content as a particular class.
168779
def cast_out(self, klass):
        """"""
        if _debug: Any._debug("cast_out %r", klass)
        global _sequence_of_classes, _list_of_classes

        # check for a sequence element
        if (klass in _sequence_of_classes) or (klass in _list_of_classes):
            # build a sequence helper
            helper = klass()

            # make a copy of the tag list
            t = TagList(self.tagList[:])

            # let it decode itself
            helper.decode(t)

            # make sure everything was consumed
            if len(t) != 0:
                raise DecodingError("incomplete cast")

            # return what was built
            return helper.value

        # check for an array element
        elif klass in _array_of_classes:
            # build a sequence helper
            helper = klass()

            # make a copy of the tag list
            t = TagList(self.tagList[:])

            # let it decode itself
            helper.decode(t)

            # make sure everything was consumed
            if len(t) != 0:
                raise DecodingError("incomplete cast")

            # return what was built with Python list semantics
            return helper.value[1:]

        elif issubclass(klass, (Atomic, AnyAtomic)):
            # make sure there's only one piece
            if len(self.tagList) == 0:
                raise DecodingError("missing cast component")
            if len(self.tagList) > 1:
                raise DecodingError("too many cast components")

            if _debug: Any._debug("    - building helper: %r", klass)

            # a helper cooperates between the atomic value and the tag
            helper = klass(self.tagList[0])

            # return the value
            return helper.value

        else:
            if _debug: Any._debug("    - building value: %r", klass)

            # build an element
            value = klass()

            # make a copy of the tag list
            t = TagList(self.tagList[:])

            # let it decode itself
            value.decode(t)

            # make sure everything was consumed
            if len(t) != 0:
                raise DecodingError("incomplete cast")

            # return what was built
            return value
251802
@Override
    public String classify(String text) throws IllegalArgumentException, IllegalStateException
    {
        Map<String, Double> scoreMap = predict(text);

        return CollectionUtility.max(scoreMap);
    }
37087
def _parse(self, content):
        """"""
        if content.find('<clam') != -1:
            data = clam.common.data.CLAMData(content,self, loadmetadata=self.loadmetadata)
            if data.errors:
                error = data.parametererror()
                if error:
                    raise clam.common.data.ParameterError(error)
            return data
        else:
            return True
589633
def from_conll(this_class, text):
        """"""
        fields = text.split('\t')
        fields[0] = int(fields[0]) # index
        fields[6] = int(fields[6]) # head index
        if fields[5] != '_': # feats
            fields[5] = tuple(fields[5].split('|'))
        fields = [value if value != '_' else None for value in fields]
        fields.append(None) # for extra
        return this_class(**dict(zip(FIELD_NAMES_PLUS, fields)))
479745
def _nonmatch_class_pos(self):
        """"""
        # TODO: add notfitted warnings
        if self.kernel.classes_.shape[0] != 2:
            raise ValueError("Number of classes is {}, expected 2.".format(
                self.kernel.classes_.shape[0]))

        # # get the position of match probabilities
        # classes = list(self.kernel.classes_)
        # return classes.index(0)

        return 0
73940
def from_string(cls, value):
        """"""
        match = cls.pattern.search(value)
        if match is None:
            raise ValueError('"%s" is not a valid media type' % value)
        try:
            return cls(match.group('mime_type'), float(match.group('weight') or 1))
        except ValueError:
            return cls(value)
1305604
def with_class(self, cls):
        
        rcls = []
        for key, value in self._classification.items():
            if value[0] == cls:
                rcls.append(key)
        return rcls
332973
def p_Class(p):
    '''
    
    '''
    p[0] = Class(p[1], p[2], p[4], p[5], p[6], p[8], p[9])
199550
def _class(self):
        """"""
        try:
            self._project_name()
        except ValueError:
            return MalformedReq
        if self._is_satisfied():
            return SatisfiedReq
        if not self._expected_hashes():
            return MissingReq
        if self._actual_hash() not in self._expected_hashes():
            return MismatchedReq
        return InstallableReq
843602
def classification(request):
    

    ctx = {
        'classification_text': getattr(settings, 'CLASSIFICATION_TEXT', 'UNCLASSIFIED'),
        'classification_text_color': getattr(settings, 'CLASSIFICATION_TEXT_COLOR', 'white'),
        'classification_background_color': getattr(settings, 'CLASSIFICATION_BACKGROUND_COLOR', 'green'),
        'classification_banner_enabled': getattr(settings, 'CLASSIFICATION_BANNER_ENABLED', True),
        'classification_link': getattr(settings, 'CLASSIFICATION_LINK', None)
    }

    return ctx
307588
def classify(self, txt):
        '''
        
        '''
        ranks = []
        for lang, score in langid.rank(txt):
            if lang in self.preferred_languages:
                score += self.preferred_factor
            ranks.append((lang, score))
        ranks.sort(key=lambda x: x[1], reverse=True)
        return ranks[0][0]
640848
def match_classes(self, el, classes):
        """"""

        current_classes = self.get_classes(el)
        found = True
        for c in classes:
            if c not in current_classes:
                found = False
                break
        return found
1085841
def parse_content(self, content):
        
        self.lines = content
        for scanner in self.scanners:
            scanner(self)
692181
def parse_content(self, content):
        
        # note, the Parser class sets:
        # * self.file_path = context.path and
        # * self.file_name = os.path.basename(context.path)
        self.active_lines_unparsed = get_active_lines(content) if content is not None else []
        #  (man page shows all options with "=")
        self.active_settings = split_kv_pairs(content, use_partition=False) if content is not None else []
653284
def genre(self):
        """"""
        if self._metadata:
            from pyatv.mrp.protobuf import ContentItem_pb2
            transaction = ContentItem_pb2.ContentItem()
            transaction.ParseFromString(self._metadata)
679008
def to_dense(self):
        """"""
        if hasattr(self._X_train, 'todense'):
            self._X_train = self._X_train.todense()
            self._X_test = self._X_test.todense()
578387
def _split_what(what):
    
    return (
        frozenset(cls for cls in what if isclass(cls)),
        frozenset(cls for cls in what if isinstance(cls, Attribute)),
    )