Main function. Takes a row of incoming data and the models definition
963686
function autoParse(data, models, options) {
  options = options || {};
  var parsed = {};

  // Go through each data point
  _.each(data, function(value, field) {
    var d = findField(field, models);

    // Find field in
    if (d) {
      parsed[d.modelName] = parsed[d.modelName] || {};
      parsed[d.modelName][d.field.name] = parse(value, d.field, options);
    }
  });

  return parsed;
}
60197
def models(klass)
      return @models if defined? @models
      return [] if frozen?

      # Use select_all to retrieve hashes for each row instead of arrays of values.
      @models = connection.
        select_all(query, "#{klass.name} Load via #{self.class.name}").
          collect! { |record| klass.send :instantiate, record }

      retrieve_found_row_count
      freeze

      @models
    end
1148745
def main(model=None, output_dir=None, n_iter=100):
    """"""
    if model is not None:
        nlp = spacy.load(model)  # load existing spaCy model
        print("Loaded model '%s'" % model)
    else:
        nlp = spacy.blank("en")  # create blank Language class
        print("Created blank 'en' model")

    # create the built-in pipeline components and add them to the pipeline
    # nlp.create_pipe works for built-ins that are registered with spaCy
    if "ner" not in nlp.pipe_names:
        ner = nlp.create_pipe("ner")
        nlp.add_pipe(ner, last=True)
    # otherwise, get it so we can add labels
    else:
        ner = nlp.get_pipe("ner")

    # add labels
    for _, annotations in TRAIN_DATA:
        for ent in annotations.get("entities"):
            ner.add_label(ent[2])

    # get names of other pipes to disable them during training
    other_pipes = [pipe for pipe in nlp.pipe_names if pipe != "ner"]
    with nlp.disable_pipes(*other_pipes):  # only train NER
        # reset and initialize the weights randomly – but only if we're
        # training a new model
        if model is None:
            nlp.begin_training()
        for itn in range(n_iter):
            random.shuffle(TRAIN_DATA)
            losses = {}
            # batch up the examples using spaCy's minibatch
            batches = minibatch(TRAIN_DATA, size=compounding(4.0, 32.0, 1.001))
            for batch in batches:
                texts, annotations = zip(*batch)
                nlp.update(
                    texts,  # batch of texts
                    annotations,  # batch of annotations
                    drop=0.5,  # dropout - make it harder to memorise data
                    losses=losses,
                )
            print("Losses", losses)

    # test the trained model
    for text, _ in TRAIN_DATA:
        doc = nlp(text)
        print("Entities", [(ent.text, ent.label_) for ent in doc.ents])
        print("Tokens", [(t.text, t.ent_type_, t.ent_iob) for t in doc])

    # save model to output directory
    if output_dir is not None:
        output_dir = Path(output_dir)
        if not output_dir.exists():
            output_dir.mkdir()
        nlp.to_disk(output_dir)
        print("Saved model to", output_dir)

        # test the saved model
        print("Loading from", output_dir)
        nlp2 = spacy.load(output_dir)
        for text, _ in TRAIN_DATA:
            doc = nlp2(text)
            print("Entities", [(ent.text, ent.label_) for ent in doc.ents])
            print("Tokens", [(t.text, t.ent_type_, t.ent_iob) for t in doc])
387101
def create(cls, data, **kwargs):
        """"""
        with db.session.begin_nested():
            model = cls.dbmodel(**kwargs)
            model.data = data
            obj = cls(model)
            db.session.add(obj.model)
        return obj
774769
function modelExport(m) {
  const result = _.mapValues(m.classes, _.head)
  result[m.__name] = m
  return result
}
885933
public static void main(String[] args) {
        String modelFile = "";
        String outputFile = "";
        int numberOfRows = 0;
        try {
            modelFile = args[0];
            outputFile = args[1];
            numberOfRows = Integer.valueOf(args[2]);
        } catch (IndexOutOfBoundsException | NumberFormatException e) {
            System.out.println("ERROR! Invalid command line arguments, expecting: <scxml model file> "
                    + "<desired csv output file> <desired number of output rows>");
            return;
        }

        FileInputStream model = null;
        try {
            model = new FileInputStream(modelFile);
        } catch (FileNotFoundException e) {
            System.out.println("ERROR! Model file not found");
            return;
        }

        SCXMLEngine engine = new SCXMLEngine();
        engine.setModelByInputFileStream(model);
        engine.setBootstrapMin(5);

        DataConsumer consumer = new DataConsumer();
        CSVFileWriter writer;
        try {
            writer = new CSVFileWriter(outputFile);
        } catch (IOException e) {
            System.out.println("ERROR! Can not write to output csv file");
            return;
        }
        consumer.addDataWriter(writer);

        DefaultDistributor dist = new DefaultDistributor();
        dist.setThreadCount(5);
        dist.setMaxNumberOfLines(numberOfRows);
        dist.setDataConsumer(consumer);

        engine.process(dist);
        writer.closeCSVFile();

        System.out.println("COMPLETE!");
    }
653347
def populateFromRow(self, dataset):
        
        self._description = dataset.description
        self.setAttributesJson(dataset.attributes)
795032
def execute(self, input_data):
        '''  '''

        # Aggregate the output from all the memory workers, clearly this could be kewler
        output = input_data['view_memory']
        output['tables'] = {}
        for data in [input_data[key] for key in ViewMemoryDeep.dependencies]:
            for name,table in data['tables'].iteritems():
                output['tables'].update({name: table})
        return output
950972
function () {
        var list = slice.call(this.indexes || []);
        var i = 0;
        list.push(this.mainIndex);
        list.push('cid');
        var l = list.length;
        this.models = [];
        this._indexes = {};
        for (; i < l; i++) {
            this._indexes[list[i]] = {};
        }
    }
616710
def from_dict(cls, data, model):
        
        model_provided = model is not None
        result = {}
        for name, new_value in data.items():
            kwargs = {
                'name': name,
                'new_value': new_value,
            }
            if model_provided:
                kwargs['params'] = model.get_field_params(name)
            result[name] = cls(**kwargs)
        return result
122084
def execute(self, input_data):
        '''  '''
        raw_bytes = input_data['sample']['raw_bytes']
        strings = self.find_strings.findall(raw_bytes)
        return {'string_list': strings}
286152
async def create(self, model_, **data):
        
        inst = model_(**data)
        query = model_.insert(**dict(inst.__data__))

        pk = await self.execute(query)
        if inst._pk is None:
            inst._pk = pk
        return inst
1296364
def load_data(self, model_instance, *args, **kwargs):
        
        model_dict = copy_model_instance(model_instance)
        return super(DjangoModelReader, self).load_data(**model_dict)
201058
def generate_models(args):
  """"""
  data_table = get_data_table(args.filename)
  tables = to_tables(data_table.rows_to_dicts())
  attr_indent = "\n" + args.indent * 2
  attr_sep = "," + attr_indent

  for tname, cols in tables.items():
    model_name = table_to_model_name(tname, list(cols.values())[0]["table_schema"])
    pk_cols, oth_cols = split_pks(cols)
    timestamps = get_timestamps(cols, args.created_at_col_name, args.updated_at_col_name)
    is_auto = len(pk_cols) == 1 and cols[pk_cols[0]]["is_auto"] == "t"

    attrs = OrderedDict()
    for cname in oth_cols:
      if cname not in timestamps:
        attrs[cname] = None

    print(_MODEL_SOURCE.format(
      class_name=model_name,
      base_class_name="ModelBase",
      indent=args.indent,
      table_name=repr(tname),
      pk_name=repr(pk_cols[0] if len(pk_cols) == 1 else pk_cols),
      pk_is_auto=is_auto,
      timestamps=timestamps,
      attrs="dict(" + attr_indent + attr_sep.join("{0}={1}".format(k, v) for k, v in attrs.items()) + ")"))
    print()
721262
def main():
    
    args = parser.parse_args()
    filehandle = args.filename
    delim = args.delimiter
    columns = args.columns[0]

    if not columns:
        for line in filehandle:
            print line,
        exit(0)

    cs = list(chain.from_iterable(columns))
    fields = (extract_fields(line, delim, cs) for line in filehandle)

    for line in fields:
        print ' '.join(line)

    args.filename.close()
1325501
def _render_rows(self):
        
        _datas = getattr(self, '_datas', ())
        headers = getattr(self, 'headers', ())
        for index, row in enumerate(_datas):
            row_number = index + 2
            for col_num, value in enumerate(row):
                cell = self.worksheet.cell(row=row_number, column=col_num + 1)
                if value is not None:
                    cell.value = value
                else:
                    cell.value = ""
                if len(headers) > col_num:
                    header = headers[col_num]
                    format = get_cell_format(header)
                    if format is not None:
                        cell.number_format = format
57808
function(model) {
    const maxLen = model.get("seq").length;
    const selection = [];
    const sels = this.g.selcol.getSelForRow(model.get("id"));
    const rows = find(sels, function(el) { return el.get("type") === "row"; });
    if ((typeof rows !== "undefined" && rows !== null)) {
      // full match
      const end = maxLen - 1;
      for (let n = 0; n <= end; n++) {
        selection.push(n);
      }
    } else if (sels.length > 0) {
      for (let i = 0, sel; i < sels.length; i++) {
        sel = sels[i];
        const start = sel.get("xStart");
        const end = sel.get("xEnd");
        for (let n = start; n <= end; n++) {
          selection.push(n);
        }
      }
    }

    return selection;
  }