diff --git a/documentation-samples/quickstarts/ContentModerator/README.md b/documentation-samples/quickstarts/ContentModerator/README.md deleted file mode 100644 index d0d4186..0000000 --- a/documentation-samples/quickstarts/ContentModerator/README.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -topic: - - sample -languages: - - Java -products: - - Azure - - Cognitive Services - - Content Moderator ---- - -# Sample Code for Content Moderator - -This sample code shows you how to moderate images with Content Moderator. - -## Contents - -| File/folder | Description | -|-------------|-------------| -| `src\main\java` | Java source code. | -| `README.md` | This README file. | -| `src\main\Resources\ImageFiles.txt` | URLs for the images to moderate. | -| `src\main\Resources\ModerationOutput.json`| Program output. The sample also writes to standard output. | - -## Prerequisites - -- Java development environment -- Maven - -## Setup - -- [Clone this sample repository](https://github.com/Azure-Samples/cognitive-services-samples-pr.git). - -## Modifying the Sample for your Configuration - -1. Store your Content Moderator API key in the `AZURE_CONTENTMODERATOR_KEY` environment variable. -2. Store your Azure endpoint in the `AZURE_ENDPOINT` environment variable. (optional) - -## Building and Running the Sample - -1. From the command line, navigate to the samples root directory: `...\cognitive-services-samples-pr\java\ContentModerator`. -2. Enter `mvn compile exec:java -Dexec.cleanupDaemonThreads=false`. - -## Next steps - -You can learn more about image moderation with Content Moderator at the [official documentation site](https://docs.microsoft.com/en-us/azure/cognitive-services/content-moderator/). diff --git a/documentation-samples/quickstarts/ContentModerator/pom.xml b/documentation-samples/quickstarts/ContentModerator/pom.xml deleted file mode 100644 index 85ece11..0000000 --- a/documentation-samples/quickstarts/ContentModerator/pom.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - 4.0.0 - com.microsoft.azure - azure-contentmoderator-sample - 0.0.1-SNAPSHOT - ContentModeratorQuickstart.java - - https://github.com/Azure/bing-search-java - - UTF-8 - - - - - org.codehaus.mojo - exec-maven-plugin - 1.4.0 - - ContentModeratorQuickstart - - - - maven-compiler-plugin - 3.0 - - 1.7 - 1.7 - - - - maven-assembly-plugin - - - package - - attached - - - - jar-with-dependencies - - - - ContentModeratorQuickstart - - - - - - - - - - - com.fasterxml.jackson.core - jackson-databind - 2.9.10.3 - - - com.microsoft.azure - azure - 1.3.0 - - - commons-net - commons-net - 3.3 - - - com.microsoft.azure.cognitiveservices - azure-cognitiveservices-contentmoderator - 1.0.2-beta - - - diff --git a/documentation-samples/quickstarts/ContentModerator/src/main/java/ContentModeratorQuickstart.java b/documentation-samples/quickstarts/ContentModerator/src/main/java/ContentModeratorQuickstart.java deleted file mode 100644 index d2ece35..0000000 --- a/documentation-samples/quickstarts/ContentModerator/src/main/java/ContentModeratorQuickstart.java +++ /dev/null @@ -1,97 +0,0 @@ -import com.google.gson.*; - -import com.microsoft.azure.cognitiveservices.vision.contentmoderator.*; -import com.microsoft.azure.cognitiveservices.vision.contentmoderator.models.*; - -import java.io.*; -import java.lang.Object.*; -import java.util.*; - -/** - * 1. Obtain Azure Face resource - * 2. Ensure correct Java version, ex: Java 8 or later - * 3. Follow IDE or command line instruction - * For Maven: install and configure - https://maven.apache.org/install.html - * - To list dependencies for this sample, execute from command line: mvn dependency:list - * - From ModerateImages folder: mvn compile exec:java -Dexec.cleanupDaemonThreads=false - * 4. Add your Face subscription key and endpoint region (replace 'westus', if necessary) - * - * This sample reads two URL images from file, then moderates them. A successful response shows - * a JSON representation of the moderation results. - */ - -public class ContentModeratorQuickstart { - - // Contains the image moderation results for an image, including text and face detection. - public static class EvaluationData { - // The URL of the evaluated image. - public String ImageUrl; - // The image moderation results. - public Evaluate ImageModeration; - // The text detection results. - public OCR TextDetection; - // The face detection results; - public FoundFaces FaceDetection; - } - - public static void main(String[] args) { - /** - * Authenticate - */ - // Create a variable called AZURE_CONTENTMODERATOR_KEY in your environment settings, with your key as its value. - // Replace the region (westus) with your own, if needed. - ContentModeratorClient client = ContentModeratorManager - .authenticate(new AzureRegionBaseUrl() - .fromString("https://westus.api.cognitive.microsoft.com"), System.getenv("AZURE_CONTENTMODERATOR_KEY")); - - // Create an object in which to store the image moderation results. - List evaluationData = new ArrayList(); - - /** - * Read image URLs from the input file and evaluate/moderate each one. - */ - // ImageFiles.txt is the file that contains the image URLs to evaluate. - // Relative paths are relative to the execution directory. - try (BufferedReader inputStream = new BufferedReader(new FileReader(new File("src\\main\\resources\\ImageFiles.txt")))){ - String line; - while ((line = inputStream.readLine()) != null) { - if (line.length() > 0) { - // Evalutate each line of text - BodyModelModel url = new BodyModelModel(); - url.withDataRepresentation("URL"); - url.withValue(line); - EvaluationData imageData = new EvaluationData(); - imageData.ImageUrl = url.value(); - - // Evaluate for adult and racy content. - imageData.ImageModeration = client.imageModerations().evaluateUrlInput("application/json", url, new EvaluateUrlInputOptionalParameter().withCacheImage(true)); - Thread.sleep(1000); - - // Detect and extract text. - imageData.TextDetection = client.imageModerations().oCRUrlInput("eng", "application/json", url, new OCRUrlInputOptionalParameter().withCacheImage(true)); - Thread.sleep(1000); - - // Detect faces. - imageData.FaceDetection = client.imageModerations().findFacesUrlInput("application/json", url, new FindFacesUrlInputOptionalParameter().withCacheImage(true)); - Thread.sleep(1000); - - evaluationData.add(imageData); - } - } - - // Save the moderation results to a file. - // ModerationOutput.json is the file to contain the output from the evaluation. - // Relative paths are relative to the execution directory. - BufferedWriter writer = new BufferedWriter(new FileWriter(new File("src\\main\\resources\\ModerationOutput.json"))); - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - System.out.println("adding imageData to file: " + gson.toJson(evaluationData).toString()); - writer.write(gson.toJson(evaluationData).toString()); - - } catch (Exception e) { - System.out.println(e.getMessage()); - e.printStackTrace(); - } - } -} -// END - Moderate Image with URL images in a file - diff --git a/documentation-samples/quickstarts/ContentModerator/src/main/resources/ImageFiles.txt b/documentation-samples/quickstarts/ContentModerator/src/main/resources/ImageFiles.txt deleted file mode 100644 index 122f4ef..0000000 --- a/documentation-samples/quickstarts/ContentModerator/src/main/resources/ImageFiles.txt +++ /dev/null @@ -1,2 +0,0 @@ -https://moderatorsampleimages.blob.core.windows.net/samples/sample2.jpg -https://moderatorsampleimages.blob.core.windows.net/samples/sample5.png diff --git a/documentation-samples/quickstarts/ContentModerator/src/main/resources/ModerationOutput.json b/documentation-samples/quickstarts/ContentModerator/src/main/resources/ModerationOutput.json deleted file mode 100644 index e69de29..0000000