<commit_before>using System;

namespace NoRM
{
    using Responses;

    public class Mongo : IDisposable
    {
        private readonly IConnectionProvider _connectionProvider;
        private bool _disposed;
        private IConnection _connection;

        private readonly MongoDatabase _database;
        private readonly string _options;

        public MongoDatabase Database
        {
            get { return _database; }
        }

        public IConnectionProvider ConnectionProvider
        {
            get
            {
                return _connectionProvider;
            }
        }
        public static Mongo ParseConnection(string connectionString)
        {
            return ParseConnection(connectionString, "");
        }
        public static Mongo ParseConnection(string connectionString, string options)
        {
            return new Mongo(ConnectionProviderFactory.Create(connectionString), options);

        }
        public Mongo(IConnectionProvider provider, string options)
        {
            var parsed = provider.ConnectionString;
            _options = options;
            _connectionProvider = provider;
            _database = new MongoDatabase(parsed.Database, ServerConnection());
        }
        public Mongo() : this("", "127.0.0.1", "27017", "") { }
        public Mongo(string db) : this(db, "127.0.0.1", "27017", "") { }
        public Mongo(string db, string server) : this(db, server, "27017", "") { }
        public Mongo(string db, string server, string port) : this(db, server, port, "") { }
        public Mongo(string db, string server, string port, string options)
        {

            if (string.IsNullOrEmpty(options))
            {
                options = "strict=false";
            }
            var cstring = string.Format("mongodb://{0}:{1}/", server, port); ;
            _options = options;
            _connectionProvider = ConnectionProviderFactory.Create(cstring);

            _database = new MongoDatabase(db, ServerConnection());

        }

        internal IConnection ServerConnection()
        {
            if (_connection == null)
            {
                _connection = _connectionProvider.Open(_options);
            }
            return _connection;
        }

        public MongoCollection<T> GetCollection<T>() where T : class, new()
        {
            return _database.GetCollection<T>();
        }

        public MongoCollection<T> GetCollection<T>(string collectionName) where T : class, new()
        {
            return _database.GetCollection<T>(collectionName);
        }

        public MapReduce CreateMapReduce()
        {
            return new MapReduce(_database);
        }

        public LastErrorResponse LastError()<commit_msg>Removed constraints on GetCollection<commit_after>using System;

namespace NoRM
{
    using Responses;

    public class Mongo : IDisposable
    {
        private readonly IConnectionProvider _connectionProvider;
        private bool _disposed;
        private IConnection _connection;

        private readonly MongoDatabase _database;
        private readonly string _options;

        public MongoDatabase Database
        {
            get { return _database; }
        }

        public IConnectionProvider ConnectionProvider
        {
            get
            {
                return _connectionProvider;
            }
        }
        public static Mongo ParseConnection(string connectionString)
        {
            return ParseConnection(connectionString, "");
        }
        public static Mongo ParseConnection(string connectionString, string options)
        {
            return new Mongo(ConnectionProviderFactory.Create(connectionString), options);

        }
        public Mongo(IConnectionProvider provider, string options)
        {
            var parsed = provider.ConnectionString;
            _options = options;
            _connectionProvider = provider;
            _database = new MongoDatabase(parsed.Database, ServerConnection());
        }
        public Mongo() : this("", "127.0.0.1", "27017", "") { }
        public Mongo(string db) : this(db, "127.0.0.1", "27017", "") { }
        public Mongo(string db, string server) : this(db, server, "27017", "") { }
        public Mongo(string db, string server, string port) : this(db, server, port, "") { }
        public Mongo(string db, string server, string port, string options)
        {

            if (string.IsNullOrEmpty(options))
            {
                options = "strict=false";
            }
            var cstring = string.Format("mongodb://{0}:{1}/", server, port); ;
            _options = options;
            _connectionProvider = ConnectionProviderFactory.Create(cstring);

            _database = new MongoDatabase(db, ServerConnection());

        }

        internal IConnection ServerConnection()
        {
            if (_connection == null)
            {
                _connection = _connectionProvider.Open(_options);
            }
            return _connection;
        }

        public MongoCollection<T> GetCollection<T>()
        {
            return _database.GetCollection<T>();
        }

        public MongoCollection<T> GetCollection<T>(string collectionName)
        {
            return _database.GetCollection<T>(collectionName);
        }

        public MapReduce CreateMapReduce()
        {
            return new MapReduce(_database);
        }

        public LastErrorResponse LastError()
{'fraction_non_alphanumeric': 0.08866995073891626, 'fraction_numerical': 0.010582010582010581, 'mean_word_length': 1.9632432432432432, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '6906977', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1271, 'n_words': 328}