static void Main(string[] args) { // Log into client with credentials AmazonComprehendClient client = new AmazonComprehendClient(Amazon.RegionEndpoint.USEast1); // Load XML doc XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load("phrases.xml"); XmlElement rootElement = xmlDoc.DocumentElement; XmlNodeList rootsChildren = rootElement.ChildNodes; foreach (XmlNode node in rootsChildren) { DetectKeyPhrasesRequest request = new DetectKeyPhrasesRequest { Text = node.InnerText, LanguageCode = "en" }; DetectKeyPhrasesResponse response = client.DetectKeyPhrases(request); Console.WriteLine(node.InnerText); foreach (KeyPhrase kp in response.KeyPhrases) { Console.Write("\t" + kp.Text + " (" + kp.Score + ") \n"); } Console.WriteLine(); } Console.ReadLine(); }
private static string DetectKeyPhrases(string text, AmazonComprehendClient comprehendClient) { var stringBuilder = new StringBuilder(); var detectKeyPhrasesRequest = new DetectKeyPhrasesRequest() { Text = text, LanguageCode = "en" }; var detectKeyPhrasesResponse = comprehendClient.DetectKeyPhrases(detectKeyPhrasesRequest); stringBuilder.AppendLine("Detect Key Phrases:"); stringBuilder.AppendLine("=========================="); foreach (var keyPhrase in detectKeyPhrasesResponse.KeyPhrases) { stringBuilder.AppendLine(string.Format("Text: {0}, Score: {1}, BeginOffset: {2}, EndOffset: {3}", keyPhrase.Text, keyPhrase.Score, keyPhrase.BeginOffset, keyPhrase.EndOffset)); } Console.WriteLine("DetectKeyPhrases => Done\n"); return(stringBuilder.ToString()); }
public DataTable KeyPhrases(string Text, string Encoding = "en") { DataTable DT = null; DetectKeyPhrasesRequest request = new DetectKeyPhrasesRequest(); request.LanguageCode = Encoding; request.Text = Text; AmazonComprehendClient client = new AmazonComprehendClient(AccessKeyId, SecretAccessKey, Amazon.RegionEndpoint.USWest2); var RES = client.DetectKeyPhrases(request); DT = FromEntity(RES.KeyPhrases); DT.TableName = "KeyPhrases"; return(DT); }
private void getKeyPhrases(string mailbody) { const string collectionUri = "https://dev.azure.com/codeletehackathon"; const string projectName = "secondproject"; const string repoName = "secondproject"; const string pat = "4rm4d2q2wq452n7ce2mqgfj4yyqajoipmez63nvxoveijuphckxq"; var creds = new VssBasicCredential(string.Empty, pat); // Connect to Azure DevOps Services var connection = new VssConnection(new Uri(collectionUri), creds); // Get a GitHttpClient to talk to the Git endpoints var gitClient = connection.GetClient <GitHttpClient>(); // Get data about a specific repository var repo = gitClient.GetRepositoryAsync(projectName, repoName).Result; var repoid = repo.Id; string collectionuris = "https://dev.azure.com/codeletehackathon/secondproject/_apis/git/repositories/506f6d44-0a42-4a10-9f75-c89c450c3740/commits?api-version=6.0"; //String text = "Thank you for helping your project manager, Angela Parmar, on the latest project. Your work reflects your dedication to the project and the organisation."; AmazonComprehendClient comprehendClient = new AmazonComprehendClient(Amazon.RegionEndpoint.USWest2); // Call DetectKeyPhrases API Console.WriteLine("Calling DetectKeyPhrases"); DetectKeyPhrasesRequest detectKeyPhrasesRequest = new DetectKeyPhrasesRequest() { Text = mailbody, LanguageCode = "en" }; DetectKeyPhrasesResponse detectKeyPhrasesResponse = comprehendClient.DetectKeyPhrases(detectKeyPhrasesRequest); DetectSyntaxRequest dsr; DetectSyntaxResponse dsresp; List <string> lkeyPhrases = new List <string>(); string strKeyPhrases = string.Empty; foreach (KeyPhrase kp in detectKeyPhrasesResponse.KeyPhrases) { lkeyPhrases.Add(kp.Text); strKeyPhrases = strKeyPhrases + ',' + kp.Text; } var values = new object[2]; values[0] = "Key Phrases"; values[1] = strKeyPhrases.Substring(1); dtTextAnalytic.Rows.Add(values); Console.WriteLine("Done"); }
public static void Sample() { String text = "It is raining today in Seattle"; var comprehendClient = new AmazonComprehendClient(Amazon.RegionEndpoint.USWest2); // Call DetectKeyPhrases API Console.WriteLine("Calling DetectKeyPhrases"); var detectKeyPhrasesRequest = new DetectKeyPhrasesRequest() { Text = text, LanguageCode = "en" }; var detectKeyPhrasesResponse = comprehendClient.DetectKeyPhrases(detectKeyPhrasesRequest); foreach (var kp in detectKeyPhrasesResponse.KeyPhrases) { Console.WriteLine("Text: {1}, Type: {1}, BeginOffset: {2}, EndOffset: {3}", kp.Text, kp.Text, kp.BeginOffset, kp.EndOffset); } Console.WriteLine("Done"); }