Git Product home page Git Product logo

cognitive-textanalytics-dotnet's Introduction

cognitive-textanalytics-dotnet's People

Contributors

joaopsousa avatar microsoftopensource avatar msftgits avatar prombouts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cognitive-textanalytics-dotnet's Issues

Rework TextRequest Documents

I think this abstraction is pretty broken. The Documents list here should be made protected and each derived request should enforce the correct model that it's expecting.

For example, in the SentimentRequest. The constructor should take IEnumerable and add those to the Documents property. The problem occurs when you supply an "incorrect" Document type for that request like so:

                var request = new SentimentRequest();
                request.Documents.Add(new KeyPhraseDocument
                {
                    Id = Guid.NewGuid().ToString(),
                    Text = "foo",
                });

This is compiling but the request is performing a very dangerous cast here and obviously throwing a null reference exception.

The above fix will solve that. Alternatively, the property can be moved to each derived request but the validation logic will be duplicated.

Client should throw on 401/404

If supplying the wrong endpoint or the client uses the fallback incorrectly (i.e. when you don't have a text analytics in west us) see #5 . The rest call will get a 401. This should be thrown as some reasonable exception as every subsequent request will fail (wrong region/key).

It's not clear when you receive an empty array of results as to why it failed.

Support for other region endpoints

Hey there, nice job on the wrapper! Any chance of extra *Client constructors that take a URL endpoint parameter as well as the API key please? Currently we're just limited to West US. Thanks!

(I realise you can still just set the Url property of the *Client after construction, but a single constructor call would be cleaner/nice to have.)

Create a clientFactory or merge the clients

It would be very helpful to have a client factory or a single combined client to work with. I don't see a reason to have the following:

                var client = new SentimentClient("")
                {
                    Url = "https://westeurope.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment"
                };

                var client = new KeyPhraseClient("")
                {
                    Url = "https://westeurope.api.cognitive.microsoft.com/text/analytics/v2.0/keyPhrases"
                };

When something like the following would be much easier:

    public class ClientFactory
    {
        private readonly string _key;
        private readonly string _region;

        public ClientFactory(string key, string region)
        {
            _key = key;
            _region = $"https://{region}.api.cognitive.microsoft.com/text/analytics/v2.0/";
        }

        public SentimentClient CreateSentimentClient() => new SentimentClient(_key)
        {
            Url = _region + "sentiment"
        };

        public KeyPhraseClient CreateKeyPhraseClient() => new KeyPhraseClient(_key)
        {
            Url = _region + "keyPhrases"
        };
    }

Sentiment analysis broken in pt

Last week I realized that Sentiment analysis stoped to work properly for portuguese language.

It always respond with 50%, I attach a positive and a negative cases below as evidence.

Someone can fix this, please?

negative
positive

sentiment analysis is not working

I've did a test using the following code and the response has 0 documents and of course, don't have the sentiment.

using System;
using Microsoft.ProjectOxford.Text.Core;
using Microsoft.ProjectOxford.Text.Sentiment;
using Microsoft.ProjectOxford.Text;

namespace ExemploAnaliseDeTexto
{
    class Program
    {
        static void Main(string[] args)
        {
            SentimentDocument document = new SentimentDocument
            {
                Id = "1",
                Language = "en",
                Text = "I don't like when examples don't work."
            };

            SentimentRequest request = new SentimentRequest();
            request.Documents.Add(document);

            SentimentClient client = new SentimentClient("{my-api-key-here}");
            var response = client.GetSentiment(request);

            Console.Read();
        }
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.