<commit_before>package edu.nyu.proto;

import com.google.protobuf.Message;
import com.google.protobuf.TextFormat;
import java.io.*;

/** General utilites for protos. */
public final class Protos {
  private Protos() {}

  /** Returns a protobuf parsed from the given file. */
  public static <P extends Message> P loadFromFile(File file, P example) throws IOException {
    return parseText(new BufferedReader(new FileReader(file)), example);
  }

  /** Returns a protobuf parsed from the given reader. */
  @SuppressWarnings("unchecked") /* OK - as example used to get builder. */
  public static <P extends Message> P parseText(Reader reader, P example) throws IOException {
    Message.Builder builder = example.newBuilderForType();
    TextFormat.merge(reader, builder);
    return (P) builder.build();
  }

  /**
   * Returns a protobuf parsed from the given String using the example (usually
   * P.getDefaultInstance()).
   */
  public static <P extends Message> P parseText(String input, P example) throws IOException {
    return parseText(new StringReader(input), example);
  }
}<commit_msg>add convenience method Protos.parseUnchecked<commit_after>package edu.nyu.proto;

import com.google.protobuf.Message;
import com.google.protobuf.TextFormat;
import java.io.*;

/** General utilites for protos. */
public final class Protos {
  private Protos() {}

  /** Returns a protobuf parsed from the given file. */
  public static <P extends Message> P loadFromFile(File file, P example) throws IOException {
    return parseText(new BufferedReader(new FileReader(file)), example);
  }

  /** Returns a protobuf parsed from the given reader. */
  @SuppressWarnings("unchecked") /* OK - as example used to get builder. */
  public static <P extends Message> P parseText(Reader reader, P example) throws IOException {
    Message.Builder builder = example.newBuilderForType();
    TextFormat.merge(reader, builder);
    return (P) builder.build();
  }

  /**
   * Returns a protobuf parsed from the given String using the example (usually
   * P.getDefaultInstance()).
   */
  public static <P extends Message> P parseText(String input, P example) throws IOException {
    return parseText(new StringReader(input), example);
  }

  /**
   * Returns a protobuf parsed from the given String using the example (usually
   * P.getDefaultInstance()).
   */
  public static <P extends Message> P parseUnchecked(String input, P example) {
    try {
      return parseText(new StringReader(input), example);
    } catch (IOException e) {
      throw new IllegalArgumentException(String.format("unable to parse input '%s'", input), e);
    }
  }
}
{'fraction_non_alphanumeric': 0.10677773570617191, 'fraction_numerical': 0.0, 'mean_word_length': 3.947565543071161, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '3078142', 'n_tokens_mistral': 717, 'n_tokens_neox': 713, 'n_words': 259}