예제 #1
0
        static void Main(string[] args)
        {
            var net = ToxiNet.GetToxiNet();

            while (true)
            {
                var input = Console.ReadLine();

                foreach (var k in net.Predict(input))
                {
                    Console.WriteLine($"Type: {k.PredictionType.ToString()} Percent: {k.Prediction}");
                }
            }
        }
예제 #2
0
        public static async Task <bool> OnChatAsync(SocketMessage message)
        {
            if (Network == null)
            {
                Network = ToxiNet.GetToxiNet();
            }
            if (!Garden.TreeState.UnfilteredChannels.Contains(message.Channel.Id))
            {
                var             parsed        = ParseString(message.Content);
                ToxiNetResult[] minPrediction = null;
                string          parsedText    = "";
                float           minValue      = 100;

                foreach (string text in parsed)
                {
                    var result = Network.Predict(text);

                    if (result[0].Prediction <= minValue)
                    {
                        parsedText    = text;
                        minPrediction = result;
                        minValue      = result[0].Prediction;
                    }
                }

                if (minPrediction[0].Prediction < 0.3)
                {
                    if (minPrediction[0].Prediction < 0.1)
                    {
                        await message.DeleteAsync();

                        $"Message Deleted. {DsUtils.GetDiscordUsername(message.Author.Id)}, {parsedText}".Log();
                    }
                    else
                    {
                        await message.Channel.SendMessageAsync(embed : GetEmbed(minPrediction, message));

                        $"User Warned. {DsUtils.GetDiscordUsername(message.Author.Id)}, {parsedText}".Log();
                    }

                    return(false);
                }
            }

            return(true);
        }