Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ public static Body GetListBody(Content c)
/// <param name="contentType"></param>
/// <param name="textContent"></param>
/// <returns></returns>
public static Responses GetTextResponse(ContentModeratorClient client, ContentModeratorAPI api, string listid, string textContent, string contentType = "text/plain", string language = "eng",bool? isAutoCorrect = false, bool? isPii = false, bool? isClassify = false)
public static Responses GetTextResponse(ContentModeratorClient client, ContentModeratorAPI api, string listid, Stream textContent, string contentType = "text/plain", string language = "eng",bool? isAutoCorrect = false, bool? isPii = false, bool? isClassify = false)
{
Responses r = new Responses();
Utilities u = new Utilities();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.10.0.0")]
[assembly: AssemblyFileVersion("0.10.0.0")]
[assembly: AssemblyVersion("0.11.0.0")]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not update the AssemblyVersion

[assembly: AssemblyFileVersion("0.11.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
"RequestUri": "/contentmoderator/moderate/v1.0/ProcessText/DetectLanguage",
"EncodedRequestUri": "L2NvbnRlbnRtb2RlcmF0b3IvbW9kZXJhdGUvdjEuMC9Qcm9jZXNzVGV4dC9EZXRlY3RMYW5ndWFnZQ==",
"RequestMethod": "POST",
"RequestBody": "\"Ciao buongiorno stronzo\"",
"RequestBody": "Ciao buongiorno stronzo",
"RequestHeaders": {
"Content-Type": [
"text/plain"
],
"Content-Length": [
"25"
"23"
],
"Ocp-Apim-Subscription-Key": [

"a79e5f9eeafa4f059ac507a93e1a9ff1"
],
"User-Agent": [
"FxVersion/4.7.2600.0",
"FxVersion/4.7.2633.0",
"OSName/Windows10Enterprise",
"OSVersion/6.3.16299",
"Microsoft.CognitiveServices.ContentModerator.ContentModeratorClient/0.0.0.0"
]
},
"ResponseBody": "{\r\n \"DetectedLanguage\": \"eng\",\r\n \"Status\": {\r\n \"Code\": 3000,\r\n \"Description\": \"OK\",\r\n \"Exception\": null\r\n },\r\n \"TrackingId\": \"5e7b225a-9c00-43d4-b717-ab905ce755e9\"\r\n}",
"ResponseBody": "{\r\n \"DetectedLanguage\": \"ita\",\r\n \"Status\": {\r\n \"Code\": 3000,\r\n \"Description\": \"OK\",\r\n \"Exception\": null\r\n },\r\n \"TrackingId\": \"49b157be-661d-4095-b235-8bbe5c5f41bf\"\r\n}",
"ResponseHeaders": {
"Content-Length": [
"137"
Expand All @@ -37,7 +37,7 @@
"no-cache"
],
"apim-request-id": [
"c52f5cf6-ebb7-4752-bf33-5a74491894a6"
"1404e6d2-dd9a-4b29-90fe-7dad568d85df"
],
"Strict-Transport-Security": [
"max-age=31536000; includeSubDomains; preload"
Expand All @@ -49,7 +49,7 @@
"no-cache"
],
"Date": [
"Fri, 15 Dec 2017 22:18:36 GMT"
"Fri, 06 Apr 2018 18:39:11 GMT"
],
"X-AspNet-Version": [
"4.0.30319"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@
"RequestUri": "/contentmoderator/moderate/v1.0/ProcessText/Screen/?language=eng&autocorrect=false&PII=false&listId=&classify=false",
"EncodedRequestUri": "L2NvbnRlbnRtb2RlcmF0b3IvbW9kZXJhdGUvdjEuMC9Qcm9jZXNzVGV4dC9TY3JlZW4vP2xhbmd1YWdlPWVuZyZhdXRvY29ycmVjdD1mYWxzZSZQSUk9ZmFsc2UmbGlzdElkPSZjbGFzc2lmeT1mYWxzZQ==",
"RequestMethod": "POST",
"RequestBody": "\"Ciao buongiorno stronzo sucks!\"",
"RequestBody": "crap 764-87-9887",
"RequestHeaders": {
"Content-Type": [
"text/plain"
],
"Content-Length": [
"32"
"16"
],
"Ocp-Apim-Subscription-Key": [

"a79e5f9eeafa4f059ac507a93e1a9ff1"
],
"User-Agent": [
"FxVersion/4.7.2600.0",
"FxVersion/4.7.2633.0",
"OSName/Windows10Enterprise",
"OSVersion/6.3.16299",
"Microsoft.CognitiveServices.ContentModerator.ContentModeratorClient/0.0.0.0"
]
},
"ResponseBody": "{\r\n \"OriginalText\": \"\\\"Ciao buongiorno stronzo sucks!\\\"\",\r\n \"NormalizedText\": \"\\\" Ciao buongiorno stronzo sucks! \\\"\",\r\n \"Misrepresentation\": null,\r\n \"Language\": \"eng\",\r\n \"Terms\": [\r\n {\r\n \"Index\": 25,\r\n \"OriginalIndex\": 25,\r\n \"ListId\": 0,\r\n \"Term\": \"sucks\"\r\n }\r\n ],\r\n \"Status\": {\r\n \"Code\": 3000,\r\n \"Description\": \"OK\",\r\n \"Exception\": null\r\n },\r\n \"TrackingId\": \"822d73e9-f2f2-411c-bd8d-e4f5214f47aa\"\r\n}",
"ResponseBody": "{\r\n \"OriginalText\": \"crap 764-87-9887\",\r\n \"NormalizedText\": \"crap 764- 87- 9887\",\r\n \"Misrepresentation\": null,\r\n \"Language\": \"eng\",\r\n \"Terms\": [\r\n {\r\n \"Index\": 0,\r\n \"OriginalIndex\": 0,\r\n \"ListId\": 0,\r\n \"Term\": \"crap\"\r\n }\r\n ],\r\n \"Status\": {\r\n \"Code\": 3000,\r\n \"Description\": \"OK\",\r\n \"Exception\": null\r\n },\r\n \"TrackingId\": \"fdf029a7-fba5-434e-a9b7-0d1d4a8841ca\"\r\n}",
"ResponseHeaders": {
"Content-Length": [
"330"
"291"
],
"Content-Type": [
"application/json; charset=utf-8"
Expand All @@ -37,7 +37,7 @@
"no-cache"
],
"apim-request-id": [
"87fc350c-1040-4b98-95f1-571548591f09"
"8e04a65e-c7ec-4818-82e9-263a40275886"
],
"Strict-Transport-Security": [
"max-age=31536000; includeSubDomains; preload"
Expand All @@ -49,7 +49,7 @@
"no-cache"
],
"Date": [
"Fri, 15 Dec 2017 22:18:42 GMT"
"Fri, 06 Apr 2018 18:33:51 GMT"
],
"X-AspNet-Version": [
"4.0.30319"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
using Xunit;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using Microsoft.Azure.Test.HttpRecorder;
using System.IO;
using System.Text;

namespace ContentModeratorTests
{
Expand Down Expand Up @@ -65,10 +67,11 @@ public void DetectLanguage()
HttpMockServer.Initialize("TextModerator", "DetectLanguage");
wait(2);
TermListId = "";
string textContent = "Ciao buongiorno stronzo";
byte[] byteArray = Encoding.UTF8.GetBytes("Ciao buongiorno stronzo");
MemoryStream stream = new MemoryStream(byteArray);
api = ContentModeratorAPI.DETECT_LANGUAGE;
client = Constants.GenerateClient(api, HttpMockServer.CreateInstance());
results = Constants.GetTextResponse(client, api, TermListId, textContent);
results = Constants.GetTextResponse(client, api, TermListId, stream);

var detectLanguage = results.DetectLanguage;
Assert.NotNull(detectLanguage);
Expand All @@ -93,10 +96,11 @@ public void ScreenText()
{
HttpMockServer.Initialize("TextModerator", "ScreenText");
TermListId = "";
string textContent = "Ciao buongiorno stronzo sucks!";
byte[] byteArray = Encoding.UTF8.GetBytes("crap 764-87-9887");
MemoryStream stream = new MemoryStream(byteArray);
api = ContentModeratorAPI.SCREEN_TEXT;
client = Constants.GenerateClient(api, HttpMockServer.CreateInstance());
results = Constants.GetTextResponse(client, api, TermListId, textContent);
results = Constants.GetTextResponse(client, api, TermListId, stream);
var screenText = results.ScreenText;
Assert.NotNull(screenText);
Assert.Equal(HttpStatusCode.OK, screenText.Response.StatusCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Microsoft.CognitiveServices.ContentModerator
using Models;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;

Expand Down Expand Up @@ -62,7 +63,7 @@ public partial interface ITextModeration
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<Screen>> ScreenTextWithHttpMessagesAsync(string language, string textContentType, string textContent, bool? autocorrect = false, bool? pII = false, string listId = default(string), bool? classify = false, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
Task<HttpOperationResponse<Screen>> ScreenTextWithHttpMessagesAsync(string language, string textContentType, Stream textContent, bool? autocorrect = false, bool? pII = false, string listId = default(string), bool? classify = false, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// This operation will detect the language of given input content.
/// Returns the &lt;a
Expand Down Expand Up @@ -92,6 +93,6 @@ public partial interface ITextModeration
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<DetectedLanguage>> DetectLanguageWithHttpMessagesAsync(string textContentType, string textContent, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
Task<HttpOperationResponse<DetectedLanguage>> DetectLanguageWithHttpMessagesAsync(string textContentType, Stream textContent, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ public PII()
/// <summary>
/// Initializes a new instance of the PII class.
/// </summary>
public PII(IList<Email> email = default(IList<Email>), IList<IPA> iPA = default(IList<IPA>), IList<Phone> phone = default(IList<Phone>), IList<Address> address = default(IList<Address>))
public PII(IList<Email> email = default(IList<Email>), IList<SSN> sSN = default(IList<SSN>), IList<IPA> iPA = default(IList<IPA>), IList<Phone> phone = default(IList<Phone>), IList<Address> address = default(IList<Address>))
{
Email = email;
SSN = sSN;
IPA = iPA;
Phone = phone;
Address = address;
Expand All @@ -46,6 +47,11 @@ public PII()
[JsonProperty(PropertyName = "Email")]
public IList<Email> Email { get; set; }

/// <summary>
/// </summary>
[JsonProperty(PropertyName = "SSN")]
public IList<SSN> SSN { get; set; }

/// <summary>
/// </summary>
[JsonProperty(PropertyName = "IPA")]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// <auto-generated>
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>

namespace Microsoft.CognitiveServices.ContentModerator.Models
{
using Newtonsoft.Json;
using System.Linq;

/// <summary>
/// Detected SSN details.
/// </summary>
public partial class SSN
{
/// <summary>
/// Initializes a new instance of the SSN class.
/// </summary>
public SSN()
{
CustomInit();
}

/// <summary>
/// Initializes a new instance of the SSN class.
/// </summary>
/// <param name="text">Detected SSN in the input text content.</param>
/// <param name="index">Index(Location) of the SSN in the input text
/// content.</param>
public SSN(string text = default(string), int? index = default(int?))
{
Text = text;
Index = index;
CustomInit();
}

/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();

/// <summary>
/// Gets or sets detected SSN in the input text content.
/// </summary>
[JsonProperty(PropertyName = "Text")]
public string Text { get; set; }

/// <summary>
/// Gets or sets index(Location) of the SSN in the input text content.
/// </summary>
[JsonProperty(PropertyName = "Index")]
public int? Index { get; set; }

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

using System;
using System.Collections.Generic;
using System.Linq;

internal static partial class SdkInfo
{
public static IEnumerable<Tuple<string, string, string>> ApiInfo_ContentModeratorClient
{
get
{
return new Tuple<string, string, string>[]
{
new Tuple<string, string, string>("ContentModeratorClient", "ImageModeration", "1.0"),
new Tuple<string, string, string>("ContentModeratorClient", "ListManagementImage", "1.0"),
new Tuple<string, string, string>("ContentModeratorClient", "ListManagementImageLists", "1.0"),
new Tuple<string, string, string>("ContentModeratorClient", "ListManagementTerm", "1.0"),
new Tuple<string, string, string>("ContentModeratorClient", "ListManagementTermLists", "1.0"),
new Tuple<string, string, string>("ContentModeratorClient", "Reviews", "1.0"),
new Tuple<string, string, string>("ContentModeratorClient", "TextModeration", "1.0"),
}.AsEnumerable();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public TextModeration(ContentModeratorClient client)
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<HttpOperationResponse<Screen>> ScreenTextWithHttpMessagesAsync(string language, string textContentType, string textContent, bool? autocorrect = false, bool? pII = false, string listId = default(string), bool? classify = false, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<HttpOperationResponse<Screen>> ScreenTextWithHttpMessagesAsync(string language, string textContentType, Stream textContent, bool? autocorrect = false, bool? pII = false, string listId = default(string), bool? classify = false, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (Client.BaseUrl == null)
{
Expand Down Expand Up @@ -182,11 +182,14 @@ public TextModeration(ContentModeratorClient client)

// Serialize Request
string _requestContent = null;
if(textContent != null)
if(textContent == null)
{
_requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(textContent, Client.SerializationSettings);
_httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("text/plain");
throw new System.ArgumentNullException("textContent");
}
if (textContent != null && textContent != Stream.Null)
{
_httpRequest.Content = new StreamContent(textContent);
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse(textContentType);
}
// Set Credentials
if (Client.Credentials != null)
Expand Down Expand Up @@ -300,7 +303,7 @@ public TextModeration(ContentModeratorClient client)
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<HttpOperationResponse<DetectedLanguage>> DetectLanguageWithHttpMessagesAsync(string textContentType, string textContent, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<HttpOperationResponse<DetectedLanguage>> DetectLanguageWithHttpMessagesAsync(string textContentType, Stream textContent, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (Client.BaseUrl == null)
{
Expand Down Expand Up @@ -352,11 +355,14 @@ public TextModeration(ContentModeratorClient client)

// Serialize Request
string _requestContent = null;
if(textContent != null)
if(textContent == null)
{
throw new System.ArgumentNullException("textContent");
}
if (textContent != null && textContent != Stream.Null)
{
_requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(textContent, Client.SerializationSettings);
_httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("text/plain");
_httpRequest.Content = new StreamContent(textContent);
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse(textContentType);
}
// Set Credentials
if (Client.Credentials != null)
Expand Down
Loading