Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the class <see cref="ClassifierApiProvider"/>.
        /// </summary>
        /// <param name="tasksApi">An object that provides methods for working with tasks.</param>
        /// <param name="resultParser">The object that extracts classification result.</param>
        public ClassifierApiProvider(IComprenoTasksApiProvider tasksApi, IClassificationResultParser resultParser)
        {
            if (tasksApi == null)
                throw new ArgumentNullException("tasksApi");
            if (resultParser == null)
                throw new ArgumentNullException("resultParser");

            _tasksApi = tasksApi;
            _resultParser = resultParser;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructs a new instance of <see cref="ComprenoTasksBatch"/>.
        /// </summary>
        /// <param name="tasksApiProvider">An object for working with tasks.</param>
        /// <param name="connectionLimitValidator">An object that implements <see cref="IConnectionLimitValidator"/>.</param>
        /// <param name="sources">Source texts.</param>
        /// <param name="taskSettings">Task settings.</param>
        public ComprenoTasksBatch(IComprenoTasksApiProvider tasksApiProvider, IConnectionLimitValidator connectionLimitValidator, 
			IEnumerable<BatchFileContainer> sources, ComprenoTaskSettings taskSettings)
        {
            if (tasksApiProvider == null)
                throw new ArgumentNullException("tasksApiProvider");
            if (connectionLimitValidator == null)
                throw new ArgumentNullException("connectionLimitValidator");
            if (sources == null)
                throw new ArgumentNullException("sources");
            if (taskSettings == null)
                throw new ArgumentNullException("taskSettings");

            _tasksApiProvider = tasksApiProvider;
            _connectionLimitValidator = connectionLimitValidator;
            _sources = sources;
            _taskSettings = taskSettings;

            DegreeOfParallelism = Environment.ProcessorCount;
            Timeout = System.Threading.Timeout.Infinite;
            CancellationToken = CancellationToken.None;
            ExecutionMode = BatchExecutionMode.Auto;
            PollingInterval = 500;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initiates a new instance of the <see cref="ComprenoClient"/> class.
        /// </summary>
        /// <param name="baseUri">The base URI of the ABBYY Compreno REST API.</param>
        /// <param name="userName">User name.</param>
        /// <param name="password">Password for the user with this name.</param>
        /// <param name="accountType">Type of user account.</param>
        /// <param name="proxy">Information about the proxy.</param>
        /// <param name="compressionEnabled">Includes the "Accept-Encoding: gzip, deflate" header if true, does not include this header if false.</param>
        /// <param name="timeout">Response timeout in milliseconds.</param>
        public ComprenoClient(Uri baseUri, string userName, string password, AccountType? accountType,
			IWebProxy proxy, bool compressionEnabled, TimeSpan timeout)
        {
            IConnectionLimitValidator connectionLimitValidator = new ServicePointConnectionLimitValidator(baseUri, proxy);

            HttpClient httpClient = createHttpClient(baseUri, userName, password, accountType, proxy, compressionEnabled, timeout);
            JsonMediaTypeFormatter jsonFormatter = createJsonFormatter();

            _restApiClient = new RestApiClient(httpClient, new[] { jsonFormatter }, jsonFormatter);

            _serverApiProvider = new ServerApiProvider(_restApiClient);
            _tasksApiProvider = new ComprenoTasksApiProvider(_restApiClient, _serverApiProvider, connectionLimitValidator);
            _userOntoDictionariesApiProvider = new UserOntoDictionariesApiProvider(_restApiClient);
            _userSemanticDictionariesApiProvider = new UserSemanticDictionariesApiProvider(_restApiClient);
            _classifierApiProvider = new ClassifierApiProvider(_tasksApiProvider, new ClassificationResultParser());
        }
Exemplo n.º 4
0
 /// <summary>
 /// Constructs a new instance of <see cref="SyncSourceProcessor"/>.
 /// </summary>
 /// <param name="tasksApiProvider">An object for working with tasks.</param>
 /// <param name="taskSettings">Task execution settings.</param>
 public SyncSourceProcessor(IComprenoTasksApiProvider tasksApiProvider, ComprenoTaskSettings taskSettings)
 {
     _tasksApiProvider = tasksApiProvider;
     _taskSettings = taskSettings;
 }
Exemplo n.º 5
0
            /// <summary>
            /// Constructs a new instance of <see cref="SyncSourceProcessor"/>.
            /// </summary>
            /// <param name="tasksApiProvider">An object for working with tasks.</param>
            /// <param name="taskSettings">Task settings.</param>
            /// <param name="pollingInterval">How often the server should be polled for the task's state.</param>
            public AsyncSourceProcessor(IComprenoTasksApiProvider tasksApiProvider, ComprenoTaskSettings taskSettings,
				int pollingInterval)
            {
                _tasksApiProvider = tasksApiProvider;
                _taskSettings = taskSettings;
                _pollingInterval = pollingInterval;
            }