<commit_before>package org.yamcs.client;

import java.time.Instant;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.yamcs.protobuf.Yamcs.NamedObjectId;
import org.yamcs.protobuf.Yamcs.Value;

import com.google.protobuf.Timestamp;

public class Helpers {

    public static Instant toInstant(Timestamp timestamp) {
        return Instant.ofEpochSecond(timestamp.getSeconds(), timestamp.getNanos());
    }

    public static NamedObjectId toNamedObjectId(String name) {
        // Some API calls still require NamedObjectId objects, which are bothersome.
        // This method automatically generates them from a name which can either be the qualified name (preferred)
        // or some alias in the form NAMESPACE/NAME
        if (name.startsWith("/")) {
            return NamedObjectId.newBuilder().setName(name).build();
        } else {
            String[] parts = name.split("\\/", 1);
            if (parts.length < 2) {
                throw new IllegalArgumentException(String.format("'%s' is not a valid name."
                        + " Use fully-qualified names or, alternatively,"
                        + " an alias in the format NAMESPACE/NAME", name));
            }
            return NamedObjectId.newBuilder().setNamespace(parts[0]).setName(parts[1]).build();
        }
    }

    public static String toName(NamedObjectId id) {<commit_msg>Fix split of namespaced parameter strings<commit_after>package org.yamcs.client;

import java.time.Instant;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.yamcs.protobuf.Yamcs.NamedObjectId;
import org.yamcs.protobuf.Yamcs.Value;

import com.google.protobuf.Timestamp;

public class Helpers {

    public static Instant toInstant(Timestamp timestamp) {
        return Instant.ofEpochSecond(timestamp.getSeconds(), timestamp.getNanos());
    }

    public static NamedObjectId toNamedObjectId(String name) {
        // Some API calls still require NamedObjectId objects, which are bothersome.
        // This method automatically generates them from a name which can either be the qualified name (preferred)
        // or some alias in the form NAMESPACE/NAME
        if (name.startsWith("/")) {
            return NamedObjectId.newBuilder().setName(name).build();
        } else {
            String[] parts = name.split("\\/", 2);
            if (parts.length < 2) {
                throw new IllegalArgumentException(String.format("'%s' is not a valid name."
                        + " Use fully-qualified names or, alternatively,"
                        + " an alias in the format NAMESPACE/NAME", name));
            }
            return NamedObjectId.newBuilder().setNamespace(parts[0]).setName(parts[1]).build();
        }
    }

    public static String toName(NamedObjectId id) {
{'fraction_non_alphanumeric': 0.10380622837370242, 'fraction_numerical': 0.002768166089965398, 'mean_word_length': 2.725515463917526, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7657000', 'n_tokens_mistral': 800, 'n_tokens_neox': 780, 'n_words': 217}