<commit_before>using System;
using System.Collections.Generic;
using System.Linq;
using Plugin.Connectivity.Abstractions;
using Windows.Networking.Connectivity;
using System.Threading.Tasks;
using Windows.Networking.Sockets;
using Windows.Networking;
using System.Diagnostics;
using Windows.ApplicationModel.Core;

namespace Plugin.Connectivity
{
    /// <summary>
    /// Connectivity Implementation for WinRT
    /// </summary>
    public class ConnectivityImplementation : BaseConnectivity
    {
        bool isConnected;
        /// <summary>
        /// Default constructor
        /// </summary>
        public ConnectivityImplementation()
        {
            isConnected = IsConnected;
            NetworkInformation.NetworkStatusChanged += NetworkStatusChanged;
        }

        async void NetworkStatusChanged(object sender)
        {
            var previous = isConnected;
            var newConnected = IsConnected;
            if (previous == newConnected)
                return;


            var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;
            if (dispatcher != null)
            {
                await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    OnConnectivityChanged(new ConnectivityChangedEventArgs { IsConnected = newConnected });

                });
            }
            else
            {
                OnConnectivityChanged(new ConnectivityChangedEventArgs { IsConnected = newConnected });
            }
        }

        /// <summary>
        /// Gets if there is an active internet connection
        /// </summary>
        public override bool IsConnected
        {
            get
            {
                var profile = NetworkInformation.GetInternetConnectionProfile();
                if (profile == null)
                    isConnected = false;
                else
                    isConnected = profile.GetNetworkConnectivityLevel() != NetworkConnectivityLevel.None;

                return isConnected;
            }
        }
               

        /// <summary>
        /// Checks if remote is reachable. RT apps cannot do loopback so this will alway return false.
        /// You can use it to check remote calls though.
        /// </summary>
        /// <param name="host"></param>
        /// <param name="msTimeout"></param>
        /// <returns></returns>
        public override async Task<bool> IsReachable(string host, int msTimeout = 5000)
        {
            if (string.IsNullOrEmpty(host))
                throw new ArgumentNullException("host");

            if (!IsConnected)
                return false;

            try
            {
                var serverHost = new HostName(host);
                using (var client = new StreamSocket())
                {
                    await client.ConnectAsync(serverHost, "http");
                    return true;
                }


            }
            catch (Exception ex)
            {
                Debug.WriteLine("Unable to reach: " + host + " Error: " + ex);
                return false;
            }
        }

        /// <summary>
        /// Tests if a remote host name is reachable 
        /// </summary>
        /// <param name="host">Host name can be a remote IP or URL of website</param>
        /// <param name="port">Port to attempt to check is reachable.</param>
        /// <param name="msTimeout">Timeout in milliseconds.</param>
        /// <returns></returns>
        public override async Task<bool> IsRemoteReachable(string host, int port = 80, int msTimeout = 5000)
        {
            if (string.IsNullOrEmpty(host))
                throw new ArgumentNullException("host");

            if (!IsConnected)
                return false;

            host = host.Replace("http://www.", string.Empty).
              Replace("http://", string.Empty).
              Replace("https://www.", string.Empty).
              Replace("https://", string.Empty).
              TrimEnd("/");<commit_msg>should be a char not a string<commit_after>using System;
using System.Collections.Generic;
using System.Linq;
using Plugin.Connectivity.Abstractions;
using Windows.Networking.Connectivity;
using System.Threading.Tasks;
using Windows.Networking.Sockets;
using Windows.Networking;
using System.Diagnostics;
using Windows.ApplicationModel.Core;

namespace Plugin.Connectivity
{
    /// <summary>
    /// Connectivity Implementation for WinRT
    /// </summary>
    public class ConnectivityImplementation : BaseConnectivity
    {
        bool isConnected;
        /// <summary>
        /// Default constructor
        /// </summary>
        public ConnectivityImplementation()
        {
            isConnected = IsConnected;
            NetworkInformation.NetworkStatusChanged += NetworkStatusChanged;
        }

        async void NetworkStatusChanged(object sender)
        {
            var previous = isConnected;
            var newConnected = IsConnected;
            if (previous == newConnected)
                return;


            var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;
            if (dispatcher != null)
            {
                await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    OnConnectivityChanged(new ConnectivityChangedEventArgs { IsConnected = newConnected });

                });
            }
            else
            {
                OnConnectivityChanged(new ConnectivityChangedEventArgs { IsConnected = newConnected });
            }
        }

        /// <summary>
        /// Gets if there is an active internet connection
        /// </summary>
        public override bool IsConnected
        {
            get
            {
                var profile = NetworkInformation.GetInternetConnectionProfile();
                if (profile == null)
                    isConnected = false;
                else
                    isConnected = profile.GetNetworkConnectivityLevel() != NetworkConnectivityLevel.None;

                return isConnected;
            }
        }
               

        /// <summary>
        /// Checks if remote is reachable. RT apps cannot do loopback so this will alway return false.
        /// You can use it to check remote calls though.
        /// </summary>
        /// <param name="host"></param>
        /// <param name="msTimeout"></param>
        /// <returns></returns>
        public override async Task<bool> IsReachable(string host, int msTimeout = 5000)
        {
            if (string.IsNullOrEmpty(host))
                throw new ArgumentNullException("host");

            if (!IsConnected)
                return false;

            try
            {
                var serverHost = new HostName(host);
                using (var client = new StreamSocket())
                {
                    await client.ConnectAsync(serverHost, "http");
                    return true;
                }


            }
            catch (Exception ex)
            {
                Debug.WriteLine("Unable to reach: " + host + " Error: " + ex);
                return false;
            }
        }

        /// <summary>
        /// Tests if a remote host name is reachable 
        /// </summary>
        /// <param name="host">Host name can be a remote IP or URL of website</param>
        /// <param name="port">Port to attempt to check is reachable.</param>
        /// <param name="msTimeout">Timeout in milliseconds.</param>
        /// <returns></returns>
        public override async Task<bool> IsRemoteReachable(string host, int port = 80, int msTimeout = 5000)
        {
            if (string.IsNullOrEmpty(host))
                throw new ArgumentNullException("host");

            if (!IsConnected)
                return false;

            host = host.Replace("http://www.", string.Empty).
              Replace("http://", string.Empty).
              Replace("https://www.", string.Empty).
              Replace("https://", string.Empty).
              TrimEnd('/');
{'fraction_non_alphanumeric': 0.09945705824284304, 'fraction_numerical': 0.0024679170779861796, 'mean_word_length': 1.5787464206172446, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 57, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5456230', 'n_tokens_mistral': 1967, 'n_tokens_neox': 1858, 'n_words': 499}