public List <ResponseRecord> ExtractResult(AnalyzeActionsResult analyzeActionsResult) { var documents = ExtractDocumentsClassificationResult(analyzeActionsResult); return(documents.Select(document => { var documentRecord = new ResponseRecord { RecordId = document.Id }; if (document.HasError) { documentRecord.Errors.Add(new ErrorWarning() { Message = $"Error processing the request record : {document.Error.Message}" }); } else { var classification = GetClassification(document); var key = Constants.ResponseSingleClassKey; documentRecord.Data.Add(key, classification); } return documentRecord; }).ToList()); }
public List <ResponseRecord> ExtractResult(AnalyzeActionsResult analyzeActionsResult) { var documents = ExtractDocumentEntityResult(analyzeActionsResult); return(documents.Select(document => { var documentRecord = new ResponseRecord { RecordId = document.Id }; if (document.HasError) { documentRecord.Errors.Add(new ErrorWarning() { Message = $"Error processing the request record : {document.Error.Message}" }); } else { // group entities by category var entitiesResult = GetEntities(document); // entity.category -> list(entity.text) // add to result var key = Constants.ResponseEntitiesKey; documentRecord.Data.Add(key, entitiesResult); } return documentRecord; }).ToList()); }
private ResponseRecord SendFrame(Api api, byte[] payload, UInt64 address = 0UL) { var frameId = GetNextFrameId(); var payloadLen = payload.Length; int idx = 0; _sendBuffer[idx++] = 0x7e; _sendBuffer[idx++] = 0x00; _sendBuffer[idx++] = 0x00; _sendBuffer[idx++] = (byte)api; _sendBuffer[idx++] = frameId; if (api == Api.Tx64 || api == Api.TransmitRequest) { _sendBuffer[idx++] = (byte)(address >> 56); _sendBuffer[idx++] = (byte)(address >> 48); _sendBuffer[idx++] = (byte)(address >> 40); _sendBuffer[idx++] = (byte)(address >> 32); _sendBuffer[idx++] = (byte)(address >> 24); _sendBuffer[idx++] = (byte)(address >> 16); _sendBuffer[idx++] = (byte)(address >> 8); _sendBuffer[idx++] = (byte)(address & 0xff); if (api == Api.TransmitRequest) { _sendBuffer[idx++] = 0xFF; _sendBuffer[idx++] = 0xFE; _sendBuffer[idx++] = 0x00; // radius } _sendBuffer[idx++] = 0x00; // options } Array.Copy(payload, 0, _sendBuffer, idx, payloadLen); idx += payloadLen; // Update the length var len = idx - 3; _sendBuffer[1] = (byte)(len >> 8); _sendBuffer[2] = (byte)(len & 0xff); int sum = 0; for (int i = 3; i < idx; ++i) { sum += _sendBuffer[i]; } _sendBuffer[idx++] = (byte)(0xff - (byte)(sum & 0xff)); WriteFrame(_sendBuffer, 0, idx); var rr = new ResponseRecord(frameId); _responseRecords.Add(frameId, rr); return(rr); }
private List <ResponseRecord> ExtractResults(AnalyzeActionsResult operationResult, List <ITextAnalyticsTask> targetTasks) { // extract action results var allActionsResult = targetTasks.SelectMany(task => task.ExtractResult(operationResult)); // group results by document id var documentGroups = allActionsResult.GroupBy(record => record.RecordId); // extract action results return(documentGroups.ToList().Select(documentGroup => { var res = new ResponseRecord() { RecordId = documentGroup.Key }; documentGroup.ToList().ForEach(action => { action.Data.ToList().ForEach(entry => res.Data.Add(entry.Key, entry.Value)); res.Errors.AddRange(action.Errors); }); return res; }).ToList()); }
private ResponseRecord SendFrame(Api api, byte[] payload, UInt64 address = 0UL) { var frameId = GetNextFrameId(); var payloadLen = payload.Length; int idx = 0; _sendBuffer[idx++] = 0x7e; _sendBuffer[idx++] = 0x00; _sendBuffer[idx++] = 0x00; _sendBuffer[idx++] = (byte)api; _sendBuffer[idx++] = frameId; if (api==Api.Tx64 || api==Api.TransmitRequest) { _sendBuffer[idx++] = (byte)(address >> 56); _sendBuffer[idx++] = (byte)(address >> 48); _sendBuffer[idx++] = (byte)(address >> 40); _sendBuffer[idx++] = (byte)(address >> 32); _sendBuffer[idx++] = (byte)(address >> 24); _sendBuffer[idx++] = (byte)(address >> 16); _sendBuffer[idx++] = (byte)(address >> 8); _sendBuffer[idx++] = (byte)(address & 0xff); if (api==Api.TransmitRequest) { _sendBuffer[idx++] = 0xFF; _sendBuffer[idx++] = 0xFE; _sendBuffer[idx++] = 0x00; // radius } _sendBuffer[idx++] = 0x00; // options } Array.Copy(payload, 0, _sendBuffer, idx, payloadLen); idx += payloadLen; // Update the length var len = idx - 3; _sendBuffer[1] = (byte)(len >> 8); _sendBuffer[2] = (byte)(len & 0xff); int sum = 0; for (int i = 3 ; i<idx; ++i) { sum += _sendBuffer[i]; } _sendBuffer[idx++] = (byte)(0xff - (byte)(sum & 0xff)); WriteFrame(_sendBuffer, 0, idx); var rr = new ResponseRecord(frameId); _responseRecords.Add(frameId, rr); return rr; }
public static OutputStreetAddress ProcessResponseRecord(ResponseRecord respRec, ParseResultDictionary _msgDict ) { var o = new OutputStreetAddress() { AddressDeliveryInstallation = respRec.AddressDeliveryInstallation, AddressExtras = respRec.AddressExtras, AddressHouseNumber = respRec.AddressHouseNumber, AddressKey = respRec.AddressKey, AddressLine1 = respRec.AddressLine1, AddressLine2 = respRec.AddressLine2, AddressLockBox = respRec.AddressLockBox, AddressPostDirection = respRec.AddressPostDirection, AddressPreDirection = respRec.AddressPreDirection, AddressPrivateMailboxName = respRec.AddressPrivateMailboxName, AddressPrivateMailboxRange = respRec.AddressPrivateMailboxRange, AddressRouteService = respRec.AddressRouteService, AddressStreetName = respRec.AddressStreetName, AddressStreetSuffix = respRec.AddressStreetSuffix, AddressSuiteName = respRec.AddressSuiteName, AddressSuiteNumber = respRec.AddressSuiteNumber, AddressTypeCode = respRec.AddressTypeCode, AreaCode = respRec.AreaCode, CBSACode = respRec.CBSACode, CBSADivisionCode = respRec.CBSADivisionCode, CBSADivisionLevel = respRec.CBSADivisionLevel, CBSADivisionTitle = respRec.CBSADivisionTitle, CBSALevel = respRec.CBSALevel, CBSATitle = respRec.CBSATitle, CarrierRoute = respRec.CarrierRoute, CensusBlock = respRec.CensusBlock, CensusTract = respRec.CensusTract, City = respRec.City, CityAbbreviation = respRec.CityAbbreviation, CompanyName = respRec.CompanyName, CongressionalDistrict = respRec.CongressionalDistrict, CountryCode = respRec.CountryCode, CountryName = respRec.CountryName, CountyFIPS = respRec.CountyFIPS, CountyName = respRec.CountyName, DateOfBirth = respRec.DateOfBirth, DateOfDeath = respRec.DateOfDeath, DeliveryIndicator = respRec.DeliveryIndicator, DeliveryPointCheckDigit = respRec.DeliveryPointCheckDigit, DeliveryPointCode = respRec.DeliveryPointCode, DemographicsGender = respRec.DemographicsGender, DemographicsResults = respRec.DemographicsResults, DomainName = respRec.DomainName, EmailAddress = respRec.EmailAddress, Gender = respRec.Gender, Gender2 = respRec.Gender2, HouseholdIncome = respRec.HouseholdIncome, Latitude = respRec.Latitude, LengthOfResidence = respRec.LengthOfResidence, Longitude = respRec.Longitude, MailboxName = respRec.MailboxName, MaritalStatus = respRec.MaritalStatus, NameFirst = respRec.NameFirst, NameFirst2 = respRec.NameFirst2, NameFull = respRec.NameFull, NameLast = respRec.NameLast, NameLast2 = respRec.NameLast2, NameMiddle = respRec.NameMiddle, NameMiddle2 = respRec.NameMiddle2, NamePrefix = respRec.NamePrefix, NamePrefix2 = respRec.NamePrefix2, NameSuffix = respRec.NameSuffix, NameSuffix2 = respRec.NameSuffix2, NewAreaCode = respRec.NewAreaCode, Occupation = respRec.Occupation, OwnRent = respRec.OwnRent, PhoneExtension = respRec.PhoneExtension, PhoneNumber = respRec.PhoneNumber, PhonePrefix = respRec.PhonePrefix, PhoneSuffix = respRec.PhoneSuffix, PlaceCode = respRec.PlaceCode, PlaceName = respRec.PlaceName, Plus4 = respRec.Plus4, PostalCode = respRec.PostalCode, PresenceOfChildren = respRec.PresenceOfChildren, PrivateMailBox = respRec.PrivateMailBox, RecordExtras = respRec.RecordExtras, Results = _msgDict.LookupCodeList(respRec.Results.Split(',')).ToList(), Salutation = respRec.Salutation, State = respRec.State, StateName = respRec.StateName, Suite = respRec.Suite, TopLevelDomain = respRec.TopLevelDomain, UTC = respRec.UTC, UrbanizationName = respRec.UrbanizationName }; var i = SetIDS(respRec.RecordID); o.RecordID = i[0]; o.ID = (int) int.Parse(i[1]); return o; }
protected ResponseRecord populateResponseRecord(HttpWebResponse response) { Stream responseStream = response.GetResponseStream(); ResponseRecord responseRecord = new ResponseRecord(); responseRecord.ResponseHeaders = response.Headers; responseRecord.ResponseStream = responseStream; return responseRecord; }