Converts an RDF dataset to N-Quads.

@param dataset the RDF dataset to convert.

@return the N-Quads string.
8016
function _toNQuads(dataset) {
  var quads = [];
  for(var graphName in dataset) {
    var triples = dataset[graphName];
    for(var ti = 0; ti < triples.length; ++ti) {
      var triple = triples[ti];
      if(graphName === '@default') {
        graphName = null;
      }
      quads.push(_toNQuad(triple, graphName));
    }
  }
  quads.sort();
  return quads.join('');
}
26050
public void fit(Map<Object, URI> datasets) {
        TrainingParameters tp = (TrainingParameters) knowledgeBase.getTrainingParameters();
        Dataframe trainingData = Dataframe.Builder.parseTextFiles(datasets,
                AbstractTextExtractor.newInstance(tp.getTextExtractorParameters()),
                knowledgeBase.getConfiguration()
        );
        
        fit(trainingData);
        
        trainingData.close();
    }
269544
public static DatasetId of(String project, String dataset) {
    return new DatasetId(checkNotNull(project), checkNotNull(dataset));
  }
1096797
protected static void printDataSet(DataSet dataSet) {
        final String SPACER = "| \t |";

        if (dataSet == null) System.out.println("DataSet is null");
        if (dataSet.getRowCount() == 0) System.out.println("DataSet is empty");

        List<DataColumn> dataSetColumns = dataSet.getColumns();
        int colColunt = dataSetColumns.size();
        int rowCount = dataSet.getRowCount();

        System.out.println("********************************************************************************************************************************************************");
        for (int row = 0; row < rowCount; row++) {
            System.out.print(SPACER);
            for (int col= 0; col< colColunt; col++) {
                Object value = dataSet.getValueAt(row, col);
                String colId = dataSet.getColumnByIndex(col).getId();
                System.out.print(colId + ": " +  value);
                System.out.print(SPACER);
            }
            System.out.println("");
        }
        System.out.println("********************************************************************************************************************************************************");
    }
924037
public Dataset createDataset(String datasetName) {
    // [START bigquery_create_dataset]
    Dataset dataset = null;
    DatasetInfo datasetInfo = DatasetInfo.newBuilder(datasetName).build();
    try {
      // the dataset was created
      dataset = bigquery.create(datasetInfo);
    } catch (BigQueryException e) {
      // the dataset was not created
    }
    // [END bigquery_create_dataset]
    return dataset;
  }
1287028
private function buildFirstQuartile(Dataset $dataset): self
    {
        $this->firstQuartile = new Quartile($this->buildQuartile(
            new Number\Number(0.25),
            $dataset->ordinates()
        ));

        return $this;
    }
893619
def try_fix_dataset(dataset):
    """"""
    if isinstance(dataset, numpy.ndarray):
        if len(dataset.shape) == 3:  # NumPy 3D
            if dataset.shape[-1] == 3:
                return dataset.transpose((2, 0, 1))
        elif len(dataset.shape) == 4:  # NumPy 4D
            if dataset.shape[-1] == 3:
                return dataset.transpose((0, 3, 1, 2))
        # Otherwise couldn't fix it.
        return dataset
    # List of Numpy 3D arrays.
    for i, d in enumerate(dataset):
        if not isinstance(d, numpy.ndarray):
            return dataset
        if not (len(d.shape) == 3 and d.shape[-1] == 3):
            return dataset
        dataset[i] = d.transpose()
    return dataset
450824
def dataset_to_rdf(dataset, graph=None):
    '''
    
    '''
    # Use the unlocalized permalink to the dataset as URI when available
    # unless there is already an upstream URI
    if 'uri' in dataset.extras:
        id = URIRef(dataset.extras['uri'])
    elif dataset.id:
        id = URIRef(url_for('datasets.show_redirect',
                            dataset=dataset.id,
                            _external=True))
    else:
        id = BNode()
    # Expose upstream identifier if present
    if 'dct:identifier' in dataset.extras:
        identifier = dataset.extras['dct:identifier']
    else:
        identifier = dataset.id
    graph = graph or Graph(namespace_manager=namespace_manager)

    d = graph.resource(id)
    d.set(RDF.type, DCAT.Dataset)
    d.set(DCT.identifier, Literal(identifier))
    d.set(DCT.title, Literal(dataset.title))
    d.set(DCT.description, Literal(dataset.description))
    d.set(DCT.issued, Literal(dataset.created_at))
    d.set(DCT.modified, Literal(dataset.last_modified))

    if dataset.acronym:
        d.set(SKOS.altLabel, Literal(dataset.acronym))

    for tag in dataset.tags:
        d.add(DCAT.keyword, Literal(tag))

    for resource in dataset.resources:
        d.add(DCAT.distribution, resource_to_rdf(resource, dataset, graph))

    if dataset.owner:
        d.add(DCT.publisher, user_to_rdf(dataset.owner, graph))
    elif dataset.organization:
        d.add(DCT.publisher, organization_to_rdf(dataset.organization, graph))

    if dataset.temporal_coverage:
        d.set(DCT.temporal, temporal_to_rdf(dataset.temporal_coverage, graph))

    frequency = frequency_to_rdf(dataset.frequency)
    if frequency:
        d.set(DCT.accrualPeriodicity, frequency)

    return d
1261411
public static function split(DataSet $dataSet, float $split): array
    {
        if ($split <= 0 || $split > 1) {
            throw new WrongUsageException('The split must be between 0 and 1');
        }

        $data = $dataSet->getRawData();
        $dataCount = floor($dataSet->getSize() * $split);
        if ($dataCount == 0) {
            $dataCount++;
        }
        $randomKeys = array_rand($data, $dataCount);
        $randomKeys = is_array($randomKeys)? $randomKeys : [$randomKeys];
        $data1 = $data2 = [];

        foreach ($data as $index => $row) {
            if (in_array($index, $randomKeys)) {
                $data1[] = $row;
            } else {
                $data2[] = $row;
            }
        }


        $dataSet1 = self::create($data1);
        $dataSet1->prepare($dataSet->getMapper());

        $dataSet2 = self::create($data2);
        $dataSet2->prepare($dataSet->getMapper());

        return [$dataSet1, $dataSet2];
    }
1193555
private Set<Dataset> getDatasetsWithThrowables() {
    Set<Dataset> datasetsWithThrowables = Sets.newHashSet();
    for (Dataset dataset : this.datasets) {
      if (!dataset.throwables().isEmpty()) {
        datasetsWithThrowables.add(dataset);
      }
    }
    return datasetsWithThrowables;
  }
84570
public static <T> DataSet<Tuple2<Long, T>> zipWithIndex(DataSet<T> input) {

		DataSet<Tuple2<Integer, Long>> elementCount = countElementsPerPartition(input);

		return input.mapPartition(new RichMapPartitionFunction<T, Tuple2<Long, T>>() {

			long start = 0;

			@Override
			public void open(Configuration parameters) throws Exception {
				super.open(parameters);

				List<Tuple2<Integer, Long>> offsets = getRuntimeContext().getBroadcastVariableWithInitializer(
						"counts",
						new BroadcastVariableInitializer<Tuple2<Integer, Long>, List<Tuple2<Integer, Long>>>() {
							@Override
							public List<Tuple2<Integer, Long>> initializeBroadcastVariable(Iterable<Tuple2<Integer, Long>> data) {
								// sort the list by task id to calculate the correct offset
								List<Tuple2<Integer, Long>> sortedData = new ArrayList<>();
								for (Tuple2<Integer, Long> datum : data) {
									sortedData.add(datum);
								}
								Collections.sort(sortedData, new Comparator<Tuple2<Integer, Long>>() {
									@Override
									public int compare(Tuple2<Integer, Long> o1, Tuple2<Integer, Long> o2) {
										return o1.f0.compareTo(o2.f0);
									}
								});
								return sortedData;
							}
						});

				// compute the offset for each partition
				for (int i = 0; i < getRuntimeContext().getIndexOfThisSubtask(); i++) {
					start += offsets.get(i).f1;
				}
			}

			@Override
			public void mapPartition(Iterable<T> values, Collector<Tuple2<Long, T>> out) throws Exception {
				for (T value: values) {
					out.collect(new Tuple2<>(start++, value));
				}
			}
		}).withBroadcastSet(elementCount, "counts");
	}
896902
public HashMultimap<WordNetRelation, Synset> getRelatedSynsets(@NonNull Synset synset) {
        HashMultimap<WordNetRelation, Synset> map = HashMultimap.create();
        for (Map.Entry<String, WordNetRelation> entry : db
                                                            .getRelations(synset)
                                                            .entrySet()) {
            map.put(entry.getValue(), getSynsetFromId(entry.getKey()));
        }
        return map;
    }
654702
public void connecDataSet(IntermediateDataSet dataSet) {
		if (dataSet == null) {
			throw new NullPointerException();
		}
		if (this.source != null) {
			throw new IllegalStateException("The edge is already connected.");
		}
		if (!dataSet.getId().equals(sourceId)) {
			throw new IllegalArgumentException("The data set to connect does not match the sourceId.");
		}
		
		this.source = dataSet;
	}
695191
protected function _fromRDF($dataset, $options) {
    $default_graph = new stdClass();
    $graph_map = (object)array('@default' => $default_graph);
    $referenced_once = (object)array();

    foreach($dataset as $name => $graph) {
      if(!property_exists($graph_map, $name)) {
        $graph_map->{$name} = new stdClass();
      }
      if($name !== '@default' && !property_exists($default_graph, $name)) {
        $default_graph->{$name} = (object)array('@id' => $name);
      }
      $node_map = $graph_map->{$name};
      foreach($graph as $triple) {
        // get subject, predicate, object
        $s = $triple->subject->value;
        $p = $triple->predicate->value;
        $o = $triple->object;

        if(!property_exists($node_map, $s)) {
          $node_map->{$s} = (object)array('@id' => $s);
        }
        $node = $node_map->{$s};

        $object_is_id = ($o->type === 'IRI' || $o->type === 'blank node');
        if($object_is_id && !property_exists($node_map, $o->value)) {
          $node_map->{$o->value} = (object)array('@id' => $o->value);
        }

        if($p === self::RDF_TYPE && !$options['useRdfType'] && $object_is_id) {
          self::addValue(
            $node, '@type', $o->value, array('propertyIsArray' => true));
          continue;
        }

        $value = self::_RDFToObject($o, $options['useNativeTypes']);
        self::addValue($node, $p, $value, array('propertyIsArray' => true));

        // object may be an RDF list/partial list node but we can't know
        // easily until all triples are read
        if($object_is_id) {
          if($o->value === self::RDF_NIL) {
            $object = $node_map->{$o->value};
            if(!property_exists($object, 'usages')) {
              $object->usages = array();
            }
            $object->usages[] = (object)array(
              'node' => $node,
              'property' => $p,
              'value' => $value);
          } else if(property_exists($referenced_once, $o->value)) {
            // object referenced more than once
            $referenced_once->{$o->value} = false;
          } else {
            // track single reference
            $referenced_once->{$o->value} = (object)array(
              'node' => $node,
              'property' => $p,
              'value' => $value);
          }
        }
      }
    }

    // convert linked lists to @list arrays
    foreach($graph_map as $name => $graph_object) {
      // no @lists to be converted, continue
      if(!property_exists($graph_object, self::RDF_NIL)) {
        continue;
      }

      // iterate backwards through each RDF list
      $nil = $graph_object->{self::RDF_NIL};
      foreach($nil->usages as $usage) {
        $node = $usage->node;
        $property = $usage->property;
        $head = $usage->value;
        $list = array();
        $list_nodes = array();

        // ensure node is a well-formed list node; it must:
        // 1. Be referenced only once.
        // 2. Have an array for rdf:first that has 1 item.
        // 3. Have an array for rdf:rest that has 1 item.
        // 4. Have no keys other than: @id, rdf:first, rdf:rest, and,
        //   optionally, @type where the value is rdf:List.
        $node_key_count = count(array_keys((array)$node));
        while($property === self::RDF_REST &&
          property_exists($referenced_once, $node->{'@id'}) &&
          is_object($referenced_once->{$node->{'@id'}}) &&
          property_exists($node, self::RDF_FIRST) &&
          property_exists($node, self::RDF_REST) &&
          is_array($node->{self::RDF_FIRST}) &&
          is_array($node->{self::RDF_REST}) &&
          count($node->{self::RDF_FIRST}) === 1 &&
          count($node->{self::RDF_REST}) === 1 &&
          ($node_key_count === 3 || ($node_key_count === 4 &&
            property_exists($node, '@type') && is_array($node->{'@type'}) &&
            count($node->{'@type'}) === 1 &&
            $node->{'@type'}[0] === self::RDF_LIST))) {
          $list[] = $node->{self::RDF_FIRST}[0];
          $list_nodes[] = $node->{'@id'};

          // get next node, moving backwards through list
          $usage = $referenced_once->{$node->{'@id'}};
          $node = $usage->node;
          $property = $usage->property;
          $head = $usage->value;
          $node_key_count = count(array_keys((array)$node));

          // if node is not a blank node, then list head found
          if(strpos($node->{'@id'}, '_:') !== 0) {
            break;
          }
        }

        // list is nested in another list
        if($property === self::RDF_FIRST) {
          // empty list
          if($node->{'@id'} === self::RDF_NIL) {
            // can't convert rdf:nil to a @list object because it would
            // result in a list of lists which isn't supported
            continue;
          }

          // preserve list head
          $head = $graph_object->{$head->{'@id'}}->{self::RDF_REST}[0];
          array_pop($list);
          array_pop($list_nodes);
        }

        // transform list into @list object
        unset($head->{'@id'});
        $head->{'@list'} = array_reverse($list);
        foreach($list_nodes as $list_node) {
          unset($graph_object->{$list_node});
        }
      }

      unset($nil->usages);
    }

    $result = array();
    $subjects = array_keys((array)$default_graph);
    sort($subjects);
    foreach($subjects as $subject) {
      $node = $default_graph->{$subject};
      if(property_exists($graph_map, $subject)) {
        $node->{'@graph'} = array();
        $graph_object = $graph_map->{$subject};
        $subjects_ = array_keys((array)$graph_object);
        sort($subjects_);
        foreach($subjects_ as $subject_) {
          $node_ = $graph_object->{$subject_};
          // only add full subjects to top-level
          if(!self::_isSubjectReference($node_)) {
            $node->{'@graph'}[] = $node_;
          }
        }
      }
      // only add full subjects to top-level
      if(!self::_isSubjectReference($node)) {
        $result[] = $node;
      }
    }

    return $result;
  }
371016
def rdf(dataset):
    ''''''
    format = RDF_EXTENSIONS[negociate_content()]
    url = url_for('datasets.rdf_format', dataset=dataset.id, format=format)
    return redirect(url)
1006364
public static function toNQuads($dataset) {
    $quads = array();
    foreach($dataset as $graph_name => $triples) {
      foreach($triples as $triple) {
        if($graph_name === '@default') {
          $graph_name = null;
        }
        $quads[] = self::toNQuad($triple, $graph_name);
      }
    }
    sort($quads);
    return implode($quads);
  }
1126983
@Override
	public DataSet<Result<K>> runInternal(Graph<K, VV, EV> input)
			throws Exception {
		// u, v, w, bitmask
		DataSet<TriangleListing.Result<K>> triangles = input
			.run(new TriangleListing<K, VV, EV>()
				.setParallelism(parallelism));

		// u, edge count
		DataSet<Tuple2<K, LongValue>> triangleVertices = triangles
			.flatMap(new SplitTriangles<>())
				.name("Split triangle vertices");

		// u, triangle count
		DataSet<Tuple2<K, LongValue>> vertexTriangleCount = triangleVertices
			.groupBy(0)
			.reduce(new CountTriangles<>())
			.setCombineHint(CombineHint.HASH)
				.name("Count triangles")
				.setParallelism(parallelism);

		// u, deg(u)
		DataSet<Vertex<K, Degrees>> vertexDegree = input
			.run(new VertexDegrees<K, VV, EV>()
				.setIncludeZeroDegreeVertices(includeZeroDegreeVertices.get())
				.setParallelism(parallelism));

		// u, deg(u), triangle count
		return vertexDegree
			.leftOuterJoin(vertexTriangleCount)
			.where(0)
			.equalTo(0)
			.with(new JoinVertexDegreeWithTriangleCount<>())
				.setParallelism(parallelism)
				.name("Clustering coefficient");
	}