<commit_before>// @flow

import type { Media } from '../types/media-types';
import type {
  MultimediaMessageInfo,
  RawMultimediaMessageInfo,
} from '../types/message-types';
import type { PlatformDetails } from '../types/device-types';

import invariant from 'invariant';

const localhostRegex = /^http:\/\/localhost/;
function shimUploadURI(uri: string, platformDetails: ?PlatformDetails) {
  if (!platformDetails || platformDetails.platform !== "android") {
    return uri;
  }
  // We do this for testing in the Android emulator
  return uri.replace(localhostRegex, "http://10.0.2.2");
}

function contentStringForMediaArray(media: $ReadOnlyArray<Media>): string {
  invariant(media.length > 0, "there should be some media");
  if (media.length === 1) {
    return `a ${media[0].type}`;
  }
  let firstType;
  for (let single of media) {
    if (!firstType) {
      firstType = single.type;
    }
    if (firstType === single.type) {
      continue;
    } else {
      return "some media";
    }
  }
  invariant(firstType, "there should be some media");
  return `some ${firstType}s`;
}

function multimediaMessagePreview(
  messageInfo: MultimediaMessageInfo | RawMultimediaMessageInfo,
): string {
  const mediaContentString = contentStringForMediaArray(messageInfo.media);<commit_msg>[lib] Use "images" instead of "photos" in robotext<commit_after>// @flow

import type { Media } from '../types/media-types';
import type {
  MultimediaMessageInfo,
  RawMultimediaMessageInfo,
} from '../types/message-types';
import type { PlatformDetails } from '../types/device-types';

import invariant from 'invariant';

const localhostRegex = /^http:\/\/localhost/;
function shimUploadURI(uri: string, platformDetails: ?PlatformDetails) {
  if (!platformDetails || platformDetails.platform !== "android") {
    return uri;
  }
  // We do this for testing in the Android emulator
  return uri.replace(localhostRegex, "http://10.0.2.2");
}

function contentStringForMediaArray(media: $ReadOnlyArray<Media>): string {
  invariant(media.length > 0, "there should be some media");
  if (media.length === 1) {
    return `a ${media[0].type}`;
  }
  let firstType;
  for (let single of media) {
    if (!firstType) {
      firstType = single.type;
    }
    if (firstType === single.type) {
      continue;
    } else {
      return "some media";
    }
  }
  invariant(firstType, "there should be some media");
  if (firstType === "photo") {
    firstType = "image";
  }
  return `some ${firstType}s`;
}

function multimediaMessagePreview(
  messageInfo: MultimediaMessageInfo | RawMultimediaMessageInfo,
): string {
  const mediaContentString = contentStringForMediaArray(messageInfo.media);
{'fraction_non_alphanumeric': 0.1361432301380082, 'fraction_numerical': 0.005967922417008579, 'mean_word_length': 3.994413407821229, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '4791197', 'n_tokens_mistral': 808, 'n_tokens_neox': 798, 'n_words': 215}