Returns a Dialect named tuple or None if the dataset file comprises a
		single column of data. If the dialect is not already known, then tries
		to determine it. Raises ValueError if it fails in the latter case.
161398
def get_dialect(self):
		
		if self.is_single_col:
			return None

		if self.delimiter and self.quotechar:
			return Dialect(self.delimiter, self.quotechar,
						True if self.escapechar is None else False,
						self.escapechar)

		ext = os.path.basename(self.file_path).rsplit('.', maxsplit=1)
		ext = ext[1].lower() if len(ext) > 1 else None

		if ext in TSV_EXTENSIONS:
			self.delimiter = '\t'
			self.quotechar = '"'

		else:
			f = self._open()
			lines = f.read().splitlines()
			f.close()

			if lines:
				dialect = self._determine_dialect(lines)
			else:
				dialect = None

			if dialect is None:
				self.is_single_col = True
			else:
				self.delimiter = dialect.delimiter
				self.quotechar = dialect.quotechar
				self.escapechar = dialect.escapechar

		return self.get_dialect()
367094
def freeze(self):
        
        # None is the same as empty string
        if self.value is None:
            self.value = ""
        if self.dialect in [DIALECT_ALTREE]:
            name_tuple = parse_name_altree(self)
        elif self.dialect in [DIALECT_MYHERITAGE]:
            name_tuple = parse_name_myher(self)
        elif self.dialect in [DIALECT_ANCESTRIS]:
            name_tuple = parse_name_ancestris(self)
        else:
            name_tuple = split_name(self.value)
        self.value = name_tuple
        return self
246775
protected Dataset<Instance> getDataset(Resource data, String format, CorpusType corpusType, boolean undersample, boolean oversample) {
        Corpus corpus = Corpus.builder()
                .format(format)
                .source(data)
                .corpusType(corpusType)
                .build();
        AnnotatableType[] required = required();
        if (required != null && required.length > 0) {
            corpus = corpus.annotate(required);
        }


        Corpus filtered = corpus;
        SerializablePredicate<HString> predicate = getTextFilter();
        if (predicate != null) {
            filtered = corpus.filter(getTextFilter());
        }
        Dataset<Instance> dataset = Dataset
                .classification()
                .featureEncoder(getFeatureEncoder())
                .type(corpus.getDataSetType())
                .source(filtered
                        .asLabeledStream(getOracle())
                        .map(getFeaturizer()::extractInstance));


        if (undersample) {
            dataset = dataset.undersample();
        }
        if (oversample) {
            dataset = dataset.oversample();
        }

        return dataset.shuffle(new Random(34));
    }
1138696
def get_version_tuple(string):
    ''''''
    match = re.match(r'(\d+)\.(\d+)\.?(\d*)([abc]?)(\d*)', string)
    major = int(match.group(1))
    minor = int(match.group(2))
    patch = int(match.group(3) or 0)
    level = RELEASE_LEVEL_MAP.get(match.group(4), 'final')
    serial = int(match.group(5) or 0)

    return major, minor, patch, level, serial
286492
def dataset_from_any(source)
      ds = case source
           # when initialized with dataframe (it passes here several vectors)
           when (defined?(Daru) ? Daru::Vector : nil)
             Dataset.new(source)
           when Dataset
             source.clone
           else
             Dataset.new(*source)
           end
      data = source.is_a?(Array) ? source[0] : source
      provide_with_datetime_format(data, ds.using)
      ds
    end
487110
def tuple(self):
        
        return (self.value, {dv.id: dv.value for dv in self.dimensionvalues})
1359023
def check_dataset_in_collection(dataset_id, collection_id, **kwargs):
    

    _get_collection(collection_id)
    collection_item = _get_collection_item(collection_id, dataset_id)
    if collection_item is None:
        return 'N'
    else:
        return 'Y'
186225
def getDatasetByName(self, name):
        
        
        result = None
        for dataset in self.__datasets:
            datasetName = dataset.getName()
            if datasetName == name:
                result = dataset
                break
        return result
528579
public static int numExamplesTrain(Set dataSet) {
        switch (dataSet) {
            case COMPLETE:
                return NUM_COMPLETE_TRAIN;
            case MERGE:
                return NUM_MERGE_TRAIN;
            case BALANCED:
                return NUM_BALANCED_TRAIN;
            case LETTERS:
                return NUM_LETTERS_TRAIN;
            case DIGITS:
                return NUM_DIGITS_TRAIN;
            case MNIST:
                return NUM_MNIST_TRAIN;
            default:
                throw new UnsupportedOperationException("Unknown Set: " + dataSet);
        }
    }
795200
def _as_document(self, dataset):
        
        assert isinstance(dataset, Dataset)

        doc = super(self.__class__, self)._as_document(dataset)

        # SQLite FTS can't find terms with `-`, replace it with underscore here and while searching.
        # See http://stackoverflow.com/questions/3865733/how-do-i-escape-the-character-in-sqlite-fts3-queries
        doc['keywords'] = doc['keywords'].replace('-', '_')
        doc['doc'] = doc['doc'].replace('-', '_')
        doc['title'] = doc['title'].replace('-', '_')
        return doc
58848
def cv(row, col_name, arg, current_data_model, df, con):
    
    vocabulary = con.vocab.vocabularies
    cell_value = str(row[col_name])
    if not cell_value:
        return None
    elif cell_value == "None":
        return None
    cell_values = cell_value.split(":")
    cell_values = [c.strip() for c in cell_values]
    # get possible values for controlled vocabulary
    # exclude weird unicode
    possible_values = []
    for val in vocabulary[col_name]:
        try:
            possible_values.append(str(val).lower())
        except UnicodeEncodeError as ex:
            print(val, ex)
    for value in cell_values:
        if str(value).lower() == "nan":
            continue
        elif str(value).lower() in possible_values:
            continue
        elif value.lower() == "none":
            continue
        else:
            try:
                if str(float(value)) in possible_values:
                    continue
            except:
                pass
            return '"{}" is not in controlled vocabulary for {}'.format(value, arg)
    return None
437696
def _parseRecord(self, gff3Set, line):
        
        row = line.split("\t")
        if len(row) != self.GFF3_NUM_COLS:
            raise GFF3Exception(
                "Wrong number of columns, expected {}, got {}".format(
                    self.GFF3_NUM_COLS, len(row)),
                self.fileName, self.lineNumber)
        feature = Feature(
            urllib.unquote(row[0]),
            urllib.unquote(row[1]),
            urllib.unquote(row[2]),
            int(row[3]), int(row[4]),
            row[5], row[6], row[7],
            self._parseAttrs(row[8]))
        gff3Set.add(feature)
1050373
def __get_datasetname(d, filename):
    
    try:
        filename = d["dataSetName"]
    except KeyError:
        logger_excel.info("get_datasetname: KeyError: No dataSetName found. Reverting to: {}".format(filename))
    return filename
977653
def columns_dataset(self):
        
        data = {}
        words_total = {}

        for instance, words in self.raw_dataset.items():
            words_item_total = {}
            for word in words:
                words_total.setdefault(word, 0)
                words_item_total.setdefault(word, 0)
                words_total[word] += 1
                words_item_total[word] += 1
            data[instance] = words_item_total

        columns = sorted(words_total.keys(),
                         key=lambda w: words_total[w],
                         reverse=True)[:250]
        columns = sorted(columns)
        dataset = {}
        for instance in data.keys():
            dataset[instance] = [data[instance].get(word, 0)
                                 for word in columns]
        return columns, dataset
869410
def irfs(self, **kwargs):
        
        dsval = kwargs.get('dataset', self.dataset(**kwargs))
        tokens = dsval.split('_')
        irf_name = "%s_%s_%s" % (DATASET_DICTIONARY['%s_%s' % (tokens[0], tokens[1])],
                                 EVCLASS_NAME_DICTIONARY[tokens[3]],
                                 kwargs.get('irf_ver'))
        return irf_name
117247
def process_result_value(self, value, dialect):
        
        if value is None:
            return None

        p = value.split("|")

        if len(p) == 0:
            return None
        return SourceLocation(*map(int, p))
221240
def translate(self, dialect):
        """"""
        new_resultset = copy(self)
        new_resultset.dialect = dialect

        for result in new_resultset:
            for dimensionvalue in result.dimensionvalues:
                dimensionvalue.value = dimensionvalue.translate(dialect)
        return new_resultset