public ClientContext(IProcessingPipeline pipeline, SessionContext context, IAspectSerializer aspectSerializer, INRCDictionary nrcDictionary) { Pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); Context = context ?? throw new ArgumentNullException(nameof(context)); AspectSerializer = aspectSerializer ?? throw new ArgumentNullException(nameof(aspectSerializer)); NrcDictionary = nrcDictionary ?? throw new ArgumentNullException(nameof(nrcDictionary)); }
public async Task ProductTest(SentimentAspectData data) { log.LogInformation("ProductTest: {0}", data); var aspectHandler = new MainAspectHandler(new AspectContextFactory()); var runner = new TestRunner(TestHelper.Instance, data.Sentiment); var semaphore = new SemaphoreSlim(Environment.ProcessorCount / 2, Environment.ProcessorCount / 2); IObservable <IParsedDocumentHolder> result = runner.Load().ObserveOn(TaskPoolScheduler.Default).Select(review => ProcessItem(semaphore, aspectHandler, review)).Merge(); await result; IAspectSerializer serializer = TestHelper.Instance.ContainerHelper.Resolve <IAspectSerializer>(); serializer.Serialize(aspectHandler).Save(Path.Combine(TestContext.CurrentContext.TestDirectory, data.Sentiment.Product + ".xml")); Text.Words.IWordItem[] features = aspectHandler.GetFeatures(10).ToArray(); Text.Words.IWordItem[] attributes = aspectHandler.GetAttributes(10).ToArray(); for (var i = 0; i < data.Features.Items.Length; i++) { Assert.IsTrue(features.Any(item => string.Compare(item.Text, data.Features.Items[i], StringComparison.OrdinalIgnoreCase) == 0)); } for (var i = 0; i < data.Attributes.Items.Length; i++) { Assert.IsTrue(attributes.Any(item => string.Compare(item.Text, data.Attributes.Items[i], StringComparison.OrdinalIgnoreCase) == 0)); } }