<commit_before>/**
 * Copyright 2017, Google, Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict';

function detectFaces (fileName) {
  // [START vision_face_detection]
  // Imports the Google Cloud client library
  const Vision = require('@google-cloud/vision');

  // Instantiates a client
  const vision = Vision();

  // The path to the local image file, e.g. "/path/to/image.png"
  // const fileName = '/path/to/image.png';

  vision.faceDetection({ source: { filename: fileName } })
    .then((results) => {
      const faces = results[0].faceAnnotations;

      console.log('Faces:');
      faces.forEach((face, i) => {
        console.log(`  Face #${i + 1}:`);
        console.log(`    Joy: ${face.joyLikelihood}`);
        console.log(`    Anger: ${face.angerLikelihood}`);
        console.log(`    Sorrow: ${face.sorrowLikelihood}`);
        console.log(`    Surprise: ${face.surpriseLikelihood}`);
      });
    })
    .catch((err) => {
      console.error('ERROR:', err);
    });
  // [END vision_face_detection]
}

function detectFacesGCS (bucketName, fileName) {
  // [START vision_face_detection_gcs]
  // Imports the Google Cloud client libraries
  const Vision = require('@google-cloud/vision');

  // Instantiates clients
  const vision = Vision();

  // The name of the bucket where the file resides, e.g. "my-bucket"
  // const bucketName = 'my-bucket';

  // The path to the file within the bucket, e.g. "path/to/image.png"
  // const fileName = 'path/to/image.png';

  const gcsPath = `gs://${bucketName}/${fileName}`;

  // Performs face detection on the gcs file
  vision.faceDetection({ source: { imageUri: gcsPath } })
    .then((results) => {
      const faces = results[0].faceAnnotations;

      console.log('Faces:');
      faces.forEach((face, i) => {
        console.log(`  Face #${i + 1}:`);
        console.log(`    Joy: ${face.joyLikelihood}`);
        console.log(`    Anger: ${face.angerLikelihood}`);
        console.log(`    Sorrow: ${face.sorrowLikelihood}`);
        console.log(`    Surprise: ${face.surpriseLikelihood}`);
      });
    })
    .catch((err) => {
      console.error('ERROR:', err);
    });
  // [END vision_face_detection_gcs]
}

function detectLabels (fileName) {
  // [START vision_label_detection]
  // Imports the Google Cloud client library
  const Vision = require('@google-cloud/vision');

  // Instantiates a client
  const vision = Vision();

  // The path to the local image file, e.g. "/path/to/image.png"
  // const fileName = '/path/to/image.png';

  // Performs label detection on the local file
  vision.labelDetection({ source: { filename: fileName } })
    .then((results) => {
      const labels = results[0].labelAnnotations;
      console.log('Labels:');
      labels.forEach((label) => console.log(label));
    })
    .catch((err) => {
      console.error('ERROR:', err);
    });
  // [END vision_label_detection]
}

function detectLabelsGCS (bucketName, fileName) {
  // [START vision_label_detection_gcs]
  // Imports the Google Cloud client libraries
  const Vision = require('@google-cloud/vision');

  // Instantiates clients
  const vision = Vision();

  // The name of the bucket where the file resides, e.g. "my-bucket"
  // const bucketName = 'my-bucket';

  // The path to the file within the bucket, e.g. "path/to/image.png"
  // const fileName = 'path/to/image.png';

  const gcsPath = `gs://${bucketName}/${fileName}`;

  // Performs label detection on the gcs file
  vision.labelDetection({ source: { imageUri: gcsPath } })
    .then((results) => {
      const labels = results[0].labelAnnotations;
      console.log('Labels:');
      labels.forEach((label) => console.log(label));
    })
    .catch((err) => {
      console.error('ERROR:', err);
    });
  // [END vision_label_detection]
}

function detectLandmarks (fileName) {
  // [START vision_landmark_detection]
  const Vision = require('@google-cloud/vision');

  // Instantiates a client<commit_msg>Fixed region tag.<commit_after>/**
 * Copyright 2017, Google, Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict';

function detectFaces (fileName) {
  // [START vision_face_detection]
  // Imports the Google Cloud client library
  const Vision = require('@google-cloud/vision');

  // Instantiates a client
  const vision = Vision();

  // The path to the local image file, e.g. "/path/to/image.png"
  // const fileName = '/path/to/image.png';

  vision.faceDetection({ source: { filename: fileName } })
    .then((results) => {
      const faces = results[0].faceAnnotations;

      console.log('Faces:');
      faces.forEach((face, i) => {
        console.log(`  Face #${i + 1}:`);
        console.log(`    Joy: ${face.joyLikelihood}`);
        console.log(`    Anger: ${face.angerLikelihood}`);
        console.log(`    Sorrow: ${face.sorrowLikelihood}`);
        console.log(`    Surprise: ${face.surpriseLikelihood}`);
      });
    })
    .catch((err) => {
      console.error('ERROR:', err);
    });
  // [END vision_face_detection]
}

function detectFacesGCS (bucketName, fileName) {
  // [START vision_face_detection_gcs]
  // Imports the Google Cloud client libraries
  const Vision = require('@google-cloud/vision');

  // Instantiates clients
  const vision = Vision();

  // The name of the bucket where the file resides, e.g. "my-bucket"
  // const bucketName = 'my-bucket';

  // The path to the file within the bucket, e.g. "path/to/image.png"
  // const fileName = 'path/to/image.png';

  const gcsPath = `gs://${bucketName}/${fileName}`;

  // Performs face detection on the gcs file
  vision.faceDetection({ source: { imageUri: gcsPath } })
    .then((results) => {
      const faces = results[0].faceAnnotations;

      console.log('Faces:');
      faces.forEach((face, i) => {
        console.log(`  Face #${i + 1}:`);
        console.log(`    Joy: ${face.joyLikelihood}`);
        console.log(`    Anger: ${face.angerLikelihood}`);
        console.log(`    Sorrow: ${face.sorrowLikelihood}`);
        console.log(`    Surprise: ${face.surpriseLikelihood}`);
      });
    })
    .catch((err) => {
      console.error('ERROR:', err);
    });
  // [END vision_face_detection_gcs]
}

function detectLabels (fileName) {
  // [START vision_label_detection]
  // Imports the Google Cloud client library
  const Vision = require('@google-cloud/vision');

  // Instantiates a client
  const vision = Vision();

  // The path to the local image file, e.g. "/path/to/image.png"
  // const fileName = '/path/to/image.png';

  // Performs label detection on the local file
  vision.labelDetection({ source: { filename: fileName } })
    .then((results) => {
      const labels = results[0].labelAnnotations;
      console.log('Labels:');
      labels.forEach((label) => console.log(label));
    })
    .catch((err) => {
      console.error('ERROR:', err);
    });
  // [END vision_label_detection]
}

function detectLabelsGCS (bucketName, fileName) {
  // [START vision_label_detection_gcs]
  // Imports the Google Cloud client libraries
  const Vision = require('@google-cloud/vision');

  // Instantiates clients
  const vision = Vision();

  // The name of the bucket where the file resides, e.g. "my-bucket"
  // const bucketName = 'my-bucket';

  // The path to the file within the bucket, e.g. "path/to/image.png"
  // const fileName = 'path/to/image.png';

  const gcsPath = `gs://${bucketName}/${fileName}`;

  // Performs label detection on the gcs file
  vision.labelDetection({ source: { imageUri: gcsPath } })
    .then((results) => {
      const labels = results[0].labelAnnotations;
      console.log('Labels:');
      labels.forEach((label) => console.log(label));
    })
    .catch((err) => {
      console.error('ERROR:', err);
    });
  // [END vision_label_detection_gcs]
}

function detectLandmarks (fileName) {
  // [START vision_landmark_detection]
  const Vision = require('@google-cloud/vision');

  // Instantiates a client
{'fraction_non_alphanumeric': 0.15145089285714286, 'fraction_numerical': 0.003125, 'mean_word_length': 3.058423913043478, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '780684', 'n_tokens_mistral': 2774, 'n_tokens_neox': 2739, 'n_words': 755}