text:
static NSUInteger globalRequestId = 0;

typedef NS_ENUM(NSUInteger,KFRequestMethod) {
    KFRequestMethodGet = 1,
    KFRequestMethodPost = 2,
    KFRequestMethodUpload = 3,
    KFRequestMethodDownload = 4,
};

typedef NS_ENUM(int, JYRequestErrors) {
    kKFRequestErrorTokenInvalid = 10,
    kKFRequestErrorCancelled = -999,
};

#pragma mark -
#pragma mark -

//////////////////////////////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////////////////////////////

@interface KFRequestInfo : NSObject

@property (nonatomic,copy) NSString *urlString;
@property (nonatomic,assign) KFRequestMethod requestMethod;
@property (nonatomic,strong) NSDictionary *params;
@property (nonatomic,copy) void (^success)(id result);
@property (nonatomic,copy) void (^failure)(id errorDesc);
@property (nonatomic,copy) void (^progress)(double fractionCompleted);
@property (nonatomic,copy) NSString *downloadMethod;
@property (nonatomic,copy) NSString *downloadDestinationPath;
@property (nonatomic,copy) void (^constructingBody)(id formData);

- (instancetype)initWithURLString:(NSString *)URLString
                    requestMethod:(KFRequestMethod)requestMethod
                           params:(NSDictionary *)params
                          success:(void(^)(id result))success
                          failure:(void(^)(NSString *errorDesc))failure
          downloadDestinationPath:(NSString *)downloadDestinationPath
                         progress:(void (^)(double fractionCompleted))progress
                   downloadMethod:(NSString *)downloadMethod
                 constructingBody:(void (^)(id formData))constructingBody;
@end

@implementation KFRequestInfo

- (instancetype)initWithURLString:(NSString *)URLString
                    requestMethod:(KFRequestMethod)requestMethod
                           params:(NSDictionary *)params
                          success:(void(^)(id result))success
                          failure:(void(^)(NSString *errorDesc))failure
          downloadDestinationPath:(NSString *)downloadDestinationPath
                         progress:(void (^)(double fractionCompleted))progress
                   downloadMethod:(NSString *)downloadMethod
                 constructingBody:(void (^)(id formData))constructingBody{
    self = [super init];
    if (self) {
        _urlString = URLString;
        _params = params;
        _success = success;
        _failure = failure;
        _requestMethod = requestMethod;
        _progress = progress;
        _downloadMethod = downloadMethod;
        _downloadDestinationPath = downloadDestinationPath;
        _constructingBody = constructingBody;
    }
    return self;
}

@end

//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark -

@interface KFRequestManager()

@property (nonatomic) NSMutableDictionary *requestInfoDic;              //requestID - KFRequestInfo pairs
@property (nonatomic) NSMutableDictionary *sessionTaskDic;              //requestID - session task pairs

@end

@implementation KFRequestManager

#pragma mark - init

- (instancetype)init
{
    self = [super init];
    if (self) {
        _httpSessionManager = [KFHTTPSessionManager sharedManager];
        _requestInfoDic = [NSMutableDictionary dictionary];
        _sessionTaskDic = [NSMutableDictionary dictionary];
    }
    return self;
}

#pragma mark - public methods

+ (instancetype) manager{
    return [[self alloc]init];
}

- (void)GET:(NSString *)URLString
  requestID:(NSString *)requestID
 parameters:(NSDictionary *)parameters
    success:(void (^)(id result))success
    failure:(void (^)(NSString *errorDesc))failure{
    if (!requestID) {
        requestID = [self autoRequestID];
    }

    BOOL addInfo = [self addRequestInfoWithRequestID:requestID URLString:URLString parameters:parameters success:success failure:failure requestMethod:KFRequestMethodGet downloadDestinationPath:nil progress:nil downloadMethod:nil constructingBody:nil];
    if (!addInfo) {
        return;
    }

    [self httpRequestWithMethod:KFRequestMethodGet URLString:URLString requestID:requestID parameters:parameters success:success failure:failure];

}

- (void)POST:(NSString *)URLString
   requestID:(NSString *)requestID
  parameters:(NSDictionary *)parameters
     success:(void (^)(id result))success
     failure:(void (^)(NSString *errorDesc))failure{
    if (!requestID) {
        requestID = [self autoRequestID];
    }

    BOOL addInfo = [self addRequestInfoWithRequestID:requestID URLString:URLString parameters:parameters success:success failure:failure requestMethod:KFRequestMethodPost downloadDestinationPath:nil progress:nil downloadMethod:nil constructingBody:nil];
    if (!addInfo) {
        return;
    }

    [self httpRequestWithMethod:KFRequestMethodPost URLString:URLString requestID:requestID parameters:parameters success:success failure:failure];
}

//+ (void)appendPartForFormData:(id)formData
//                     filePath:(NSString *)filePath
//                         name:(NSString *)name
//                     fileName:(NSString *)fileName
//                     mimeType:(NSString *)mimeType
//{
//    NSString *uploadName = name ? name : @"stream";
//    NSString *uploadFileName = fileName ? fileName : [filePath lastPathComponent];
//    NSString *uploadMIMEType = mimeType ? mimeType : @"application/octet-stream";
//
//    [formData appendPartWithFileURL:[NSURL fileURLWithPath:filePath] name:uploadName fileName:uploadFileName mimeType:uploadMIMEType error:nil];
//}
//
//+ (void)appendPartForFormData:(id)formData
//                     fileData:(NSData *)data
//                         name:(NSString *)name
//                     fileName:(NSString *)fileName
//                     mimeType:(NSString *)mimeType  //content-type
//{
//    NSString *uploadName = name ? name : @"stream";
//    NSString *uploadMIMEType = mimeType ? mimeType : @"application/octet-stream";
//
//    [formData appendPartWithFileData:data name:uploadName fileName:fileName mimeType:uploadMIMEType];
//}

- (void)UPLOAD:(NSString *)URLString
     requestID:(NSString *)requestID
    parameters:(NSDictionary *)parameters
constructingBody:(void (^)(id formData))constructingBody
      progress:(void (^)(double fractionCompleted))progress
       success:(void (^)(id result))success
       failure:(void (^)(NSString *errorDesc))failure{

    if (!requestID) {
        requestID = [self autoRequestID];
    }

    BOOL addInfo = [self addRequestInfoWithRequestID:requestID URLString:URLString parameters:parameters success:success failure:failure requestMethod:KFRequestMethodUpload downloadDestinationPath:URLString progress:progress downloadMethod:nil constructingBody:constructingBody];

    if (!addInfo) {
        return;
    }

    [self uploadTask:URLString requestID:requestID parameters:parameters constructingBody:constructingBody progress:progress success:success failure:failure];
}

- (void)DOWNLOAD:(NSString *)URLString
       requestID:(NSString *)requestID
          method:(NSString *)method
      parameters:(NSDictionary *)parameters
 destinationPath:(NSString *)destinationPath
        progress:(void (^)(double fractionCompleted))progress
         success:(void (^)(id result))success
         failure:(void (^)(NSString *errorDesc))failure
{
    if (!requestID) {
        requestID = [self autoRequestID];
    }

    BOOL result = [self addRequestInfoWithRequestID:requestID URLString:URLString parameters:parameters success:success failure:failure requestMethod:KFRequestMethodDownload downloadDestinationPath:URLString progress:progress downloadMethod:method constructingBody:nil];
    if (!result) {
        return;
    }

    [self downloadTask:URLString requestID:requestID method:method parameters:parameters destinationPath:destinationPath progress:progress success:success failure:failure];
}

- (void)refreshRequestsWithNewKey:(NSString *)key andValue:(id)value{
    NSArray *requestIDs = [self.requestInfoDic allKeys];
    for (NSString *requestID in requestIDs) {
        KFRequestInfo *requestInfo = [self.requestInfoDic objectForKey:requestID];

        NSMutableDictionary *newParams = [NSMutableDictionary dictionaryWithDictionary:requestInfo.params];
        newParams[key] = value;
        requestInfo.params = newParams;

        switch (requestInfo.requestMethod) {
            case KFRequestMethodGet:
            case KFRequestMethodPost:
                [self httpRequestWithMethod:requestInfo.requestMethod URLString:requestInfo.urlString requestID:requestID parameters:requestInfo.params success:requestInfo.success failure:requestInfo.failure];
                break;
            case KFRequestMethodDownload:
                [self downloadTask:requestInfo.urlString requestID:requestID method:requestInfo.downloadMethod parameters:requestInfo.params destinationPath:requestInfo.downloadMethod progress:requestInfo.progress success:requestInfo.success failure:requestInfo.failure];
                break;
            case KFRequestMethodUpload:
                [self uploadTask:requestInfo.urlString requestID:requestID parameters:requestInfo.params constructingBody:requestInfo.constructingBody progress:requestInfo.progress success:requestInfo.success failure:requestInfo.failure];
                break;
            default:
                break;
        }
    }
}

- (void)cancelRequest:(NSString *)requestID{
    NSURLSessionTask *sessionTask = self.sessionTaskDic[requestID];
    [sessionTask cancel];
    [self.sessionTaskDic removeObjectForKey:requestID];
    [self.requestInfoDic removeObjectForKey:requestID];
}

- (void)cancelAll{
    NSArray *allTasks = [self.sessionTaskDic allValues];
    [allTasks makeObjectsPerformSelector:@selector(cancel)];
    [self.sessionTaskDic removeAllObjects];
    [self.requestInfoDic removeAllObjects];
}

- (void)cancelRequestExceptFor:(NSArray *)requestIDs{
    [self.sessionTaskDic removeObjectsForKeys:requestIDs];
    [self cancelAll];
}

#pragma mark - private methods

#pragma mark request id

- (NSString *)autoRequestID{
    return [NSString stringWithFormat:@"%@.requestId.%@",kBundle,@(globalRequestId)];
}

#pragma mark add for request info dic
- (BOOL)addRequestInfoWithRequestID:(NSString *)requestID
                          URLString:(NSString *)URLString
                         parameters:(NSDictionary *)parameters
                            success:(void (^)(id result))success
                            failure:(void (^)(NSString *errorDesc))failure
                      requestMethod:(KFRequestMethod)requestMethod
            downloadDestinationPath:(NSString *)downloadDestinationPath
                           progress:(void (^)(double fractionCompleted))progress
                     downloadMethod:(NSString *)downloadMethod
                   constructingBody:(void (^)(id formData))constructingBody{
    if ([self.requestInfoDic objectForKey:requestID]) {
        return NO;
    }

    KFRequestInfo *requestInfo = [[KFRequestInfo alloc]initWithURLString:requestID
                                                           requestMethod:requestMethod
                                                                  params:parameters
                                                                 success:success
                                                                 failure:failure
                                                 downloadDestinationPath:downloadDestinationPath
                                                                progress:progress
                                                          downloadMethod:downloadMethod
                                                        constructingBody:constructingBody];
    [self.requestInfoDic setObject:requestInfo forKey:requestID];
    return YES;
}

#pragma mark add for session dic
- (BOOL)addSessionTaskWithRequestID:(NSString *)requestID
                        sessionTask:(id)sessionTask
{
    if ([self.sessionTaskDic objectForKey:requestID]) {
        return NO;
    }

    [self.sessionTaskDic setObject:sessionTask forKey:requestID];

    return YES;
}

#pragma mark deal with results
- (void)dealSuccessWithRequest:(NSString *)requestID responseObject:(id)responseObject success:(void(^)(id result))success{
    id result = responseObject;
    [self.sessionTaskDic removeObjectForKey:requestID];;
    [self.requestInfoDic removeObjectForKey:requestID];
    if (success) {
        success(result);
    }

}

- (void)dealFailureWithRequest:(NSString *)requestID errorDesc:(NSString *)errorDesc errorCode:(NSInteger)errorCode failure:(void(^)(NSString *errorDesc))failure{
    [self.sessionTaskDic removeObjectForKey:requestID];;
    [self.requestInfoDic removeObjectForKey:requestID];
    if(failure){
        failure(errorDesc);
    }
}

#pragma mark post & get
- (void)httpRequestWithMethod:(KFRequestMethod)requestMethod
                    URLString:(NSString *)URLString
                    requestID:(NSString *)requestID
                   parameters:(NSDictionary *)parameters
                      success:(void (^)(id result))success
                      failure:(void (^)(NSString *errorDesc))failure{
    void(^successBlock)(NSURLSessionTask *task, id responseObject) = ^(NSURLSessionTask *task, id responseObject){
        [self dealSuccessWithRequest:requestID responseObject:responseObject success:success];
    };

    void(^failureBlock)(NSURLSessionTask *task, NSError *error) = ^(NSURLSessionTask *task,NSError *error){
        [self dealFailureWithRequest:requestID errorDesc:error.localizedDescription errorCode:error.code failure:failure];
    };
    NSURLSessionDataTask * sessionTask = nil;
    switch (requestMethod) {
        case KFRequestMethodGet:
            sessionTask = [self.httpSessionManager GET:URLString parameters:parameters progress:nil success:successBlock failure:failureBlock];
            break;
        case KFRequestMethodPost:
            sessionTask = [self.httpSessionManager POST:URLString parameters:parameters progress:nil success:successBlock failure:failureBlock];
            break;
        default:
            break;
    }

    if (sessionTask) {
        [self addSessionTaskWithRequestID:requestID sessionTask:sessionTask];
    }

}

#pragma mark upload

- (void)uploadTask:(NSString *)URLString
         requestID:(NSString *)requestID
        parameters:(NSDictionary *)parameters
  constructingBody:(void (^)(id formData))constructingBody
          progress:(void (^)(double fractionCompleted))progress
           success:(void (^)(id result))success
           failure:(void (^)(NSString *errorDesc))failure
{
    if (self.httpSessionManager.baseURL) {
        URLString = [NSString stringWithFormat:@"%@%@",self.httpSessionManager.baseURL.absoluteString,URLString];
    }

    NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:URLString parameters:parameters constructingBodyWithBlock:constructingBody error:nil];

    NSString *tmpFileName = [NSString stringWithFormat:@"mlt_r_%f",[[NSDate date] timeIntervalSince1970]];
    NSURL *tmpFileURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:tmpFileName]];

    [[AFHTTPRequestSerializer serializer] requestWithMultipartFormRequest:request writingStreamContentsToFile:tmpFileURL completionHandler:^(NSError *error) {
        NSURLSessionUploadTask *uploadTask = [self.httpSessionManager uploadTaskWithRequest:request fromFile:tmpFileURL progress:^(NSProgress *uploadProgress) {
            if (progress) {
                progress(uploadProgress.fractionCompleted);
            }
        } completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
            [[NSFileManager defaultManager] removeItemAtURL:tmpFileURL error:nil];

            if (error) {
                [self dealFailureWithRequest:requestID errorDesc:error.localizedDescription errorCode:error.code failure:failure];
                return;
            }

            [self dealSuccessWithRequest:requestID responseObject:responseObject success:success];
        }];

        [uploadTask resume];

        if (uploadTask) {
            [self addSessionTaskWithRequestID:requestID sessionTask:uploadTask];
        }
    }];
}

#pragma mark download
- (NSString *)downloadDefaultPathWithMIMEType:(NSString *)MIMEType requestID:(NSString *)requestID {
    NSString *fileName = [NSString stringWithFormat:@"%@.%@",requestID,MIMEType];
    return [kDefaultCachePath stringByAppendingPathComponent:fileName];
}

- (void)downloadTask:(NSString *)URLString
           requestID:(NSString *)requestID
              method:(NSString *)method
          parameters:(NSDictionary *)parameters
     destinationPath:(NSString *)destinationPath
            progress:(void (^)(double fractionCompleted))progress
             success:(void (^)(id result))success
             failure:(void (^)(NSString *errorDesc))failure
{
    if (self.httpSessionManager.baseURL) {
        URLString = [NSString stringWithFormat:@"%@%@",self.httpSessionManager.baseURL,URLString];
    }

    NSURLRequest *request = [[AFHTTPRequestSerializer serializer]requestWithMethod:method URLString:URLString parameters:parameters error:nil];
    NSURLSessionDownloadTask *downloadTask = [self.httpSessionManager downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) {
        if (progress) {
//            NSLog(@"%@",downloadProgress);
            progress(downloadProgress.fractionCompleted);
        }
    } destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) {
        if (destinationPath) {
            return [NSURL fileURLWithPath:destinationPath];
        }
        NSString *defaultPath = [self downloadDefaultPathWithMIMEType:response.MIMEType requestID:requestID];
        return [NSURL fileURLWithPath:defaultPath];
    } completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
        if(error){
            [self dealFailureWithRequest:requestID errorDesc:error.localizedDescription errorCode:error.code failure:failure];
            return;
        }

        if (!filePath) {
            [self dealFailureWithRequest:requestID errorDesc:@"下载路径为空" errorCode:0 failure:failure];
            return;
        }

        [self dealSuccessWithRequest:requestID responseObject:filePath success:success];

    }];

    [downloadTask resume];

    if (downloadTask) {
        [self addSessionTaskWithRequestID:requestID sessionTask:downloadTask];
    }
}

#pragma mark - dealloc

- (void)dealloc{
    NSLog(@"KFRequestManager Dealloc");
}

@end


text:
package pl.edu.agh.two.parser.events.getters;

/**
 * Created by Michal Mrowczyk on 11/24/2015.
 */
public class RawGetterItem {
    private String item;

    public String getItem() {
        return item;
    }

    public void setItem(String item) {
        this.item = item;
    }
}

redpajama_set_name: RedPajamaGithub


text:
using NRules.Fluent.Dsl;
using NRules.IntegrationTests.TestAssets;

namespace NRules.IntegrationTests.TestRules
{
    [Priority(100)]
    public class PriorityHighRule : BaseRule
    {
        public override void Define()
        {
            FactType2 fact2 = null;

            When()
                .Match<FactType2>(() => fact2, f => f.TestProperty.StartsWith("Valid"));
            Then()
                .Do(ctx => Action());
        }
    }
}


text:
$KCODE = 'U'
require 'json/editor'

filename, encoding = ARGV
JSON::Editor.start(encoding) do |window|
  if filename
    window.file_open(filename)
  end
end
  # vim: set et sw=2 ts=2:


text:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using Azure.AI.TextAnalytics.Models;

namespace Azure.AI.TextAnalytics
{
    internal static class Transforms
    {
        #region Common

        internal static TextAnalyticsError ConvertToError(TextAnalyticsErrorInternal error)
        {
            string errorCode = error.Code;
            string message = error.Message;
            string target = error.Target;
            InnerError innerError = error.Innererror;

            if (innerError != null)
            {
                // Return the innermost error, which should be only one level down.
                return new TextAnalyticsError(innerError.Code, innerError.Message, innerError.Target);
            }

            return new TextAnalyticsError(errorCode, message, target);
        }

        internal static List<TextAnalyticsError> ConvertToErrors(IReadOnlyList<TextAnalyticsErrorInternal> internalErrors)
        {
            var errors = new List<TextAnalyticsError>();

            if (internalErrors == null)
            {
                return errors;
            }

            foreach (TextAnalyticsErrorInternal error in internalErrors)
            {
                errors.Add(ConvertToError(error));
            }
            return errors;
        }

        internal static List<TextAnalyticsWarning> ConvertToWarnings(IReadOnlyList<TextAnalyticsWarningInternal> internalWarnings)
        {
            var warnings = new List<TextAnalyticsWarning>();

            if (internalWarnings == null)
            {
                return warnings;
            }

            foreach (TextAnalyticsWarningInternal warning in internalWarnings)
            {
                warnings.Add(new TextAnalyticsWarning(warning));
            }
            return warnings;
        }

        #endregion

        #region DetectLanguage

        internal static DetectedLanguage ConvertToDetectedLanguage(DocumentLanguage documentLanguage)
        {
            return new DetectedLanguage(documentLanguage.DetectedLanguage, ConvertToWarnings(documentLanguage.Warnings));
        }

        internal static DetectLanguageResultCollection ConvertToDetectLanguageResultCollection(LanguageResult results, IDictionary<string, int> idToIndexMap)
        {
            var detectedLanguages = new List<DetectLanguageResult>();

            //Read errors
            foreach (DocumentError error in results.Errors)
            {
                detectedLanguages.Add(new DetectLanguageResult(error.Id, ConvertToError(error.Error)));
            }

            //Read languages
            foreach (DocumentLanguage language in results.Documents)
            {
                detectedLanguages.Add(new DetectLanguageResult(language.Id, language.Statistics ?? default, ConvertToDetectedLanguage(language)));
            }

            detectedLanguages = SortHeterogeneousCollection(detectedLanguages, idToIndexMap);

            return new DetectLanguageResultCollection(detectedLanguages, results.Statistics, results.ModelVersion);
        }

        #endregion

        #region AnalyzeSentiment

        internal static AnalyzeSentimentResultCollection ConvertToAnalyzeSentimentResultCollection(SentimentResponse results, IDictionary<string, int> idToIndexMap)
        {
            var analyzedSentiments = new List<AnalyzeSentimentResult>();

            //Read errors
            foreach (DocumentError error in results.Errors)
            {
                analyzedSentiments.Add(new AnalyzeSentimentResult(error.Id, ConvertToError(error.Error)));
            }

            //Read sentiments
            foreach (DocumentSentimentInternal docSentiment in results.Documents)
            {
                analyzedSentiments.Add(new AnalyzeSentimentResult(docSentiment.Id, docSentiment.Statistics ?? default, new DocumentSentiment(docSentiment)));
            }

            analyzedSentiments = SortHeterogeneousCollection(analyzedSentiments, idToIndexMap);

            return new AnalyzeSentimentResultCollection(analyzedSentiments, results.Statistics, results.ModelVersion);
        }

        #endregion

        #region KeyPhrases

        internal static KeyPhraseCollection ConvertToKeyPhraseCollection(DocumentKeyPhrases documentKeyPhrases)
        {
            return new KeyPhraseCollection(documentKeyPhrases.KeyPhrases.ToList(), ConvertToWarnings(documentKeyPhrases.Warnings));
        }

        internal static ExtractKeyPhrasesResultCollection ConvertToExtractKeyPhrasesResultCollection(KeyPhraseResult results, IDictionary<string, int> idToIndexMap)
        {
            var keyPhrases = new List<ExtractKeyPhrasesResult>();

            //Read errors
            foreach (DocumentError error in results.Errors)
            {
                keyPhrases.Add(new ExtractKeyPhrasesResult(error.Id, ConvertToError(error.Error)));
            }

            //Read Key phrases
            foreach (DocumentKeyPhrases docKeyPhrases in results.Documents)
            {
                keyPhrases.Add(new ExtractKeyPhrasesResult(docKeyPhrases.Id, docKeyPhrases.Statistics ?? default, ConvertToKeyPhraseCollection(docKeyPhrases)));
            }

            keyPhrases = SortHeterogeneousCollection(keyPhrases, idToIndexMap);

            return new ExtractKeyPhrasesResultCollection(keyPhrases, results.Statistics, results.ModelVersion);
        }

        #endregion

        #region Recognize Entities

        internal static List<CategorizedEntity> ConvertToCategorizedEntityList(List<Entity> entities)
            => entities.Select((entity) => new CategorizedEntity(entity)).ToList();

        internal static CategorizedEntityCollection ConvertToCategorizedEntityCollection(DocumentEntities documentEntities)
        {
            return new CategorizedEntityCollection(ConvertToCategorizedEntityList(documentEntities.Entities.ToList()), ConvertToWarnings(documentEntities.Warnings));
        }

        internal static RecognizeEntitiesResultCollection ConvertToRecognizeEntitiesResultCollection(EntitiesResult results, IDictionary<string, int> idToIndexMap)
        {
            var recognizeEntities = new List<RecognizeEntitiesResult>();

            //Read errors
            foreach (DocumentError error in results.Errors)
            {
                recognizeEntities.Add(new RecognizeEntitiesResult(error.Id, ConvertToError(error.Error)));
            }

            //Read document entities
            foreach (DocumentEntities docEntities in results.Documents)
            {
                recognizeEntities.Add(new RecognizeEntitiesResult(docEntities.Id, docEntities.Statistics ?? default, ConvertToCategorizedEntityCollection(docEntities)));
            }

            recognizeEntities = SortHeterogeneousCollection(recognizeEntities, idToIndexMap);

            return new RecognizeEntitiesResultCollection(recognizeEntities, results.Statistics, results.ModelVersion);
        }

        #endregion

        #region Recognize PII Entities

        internal static List<PiiEntity> ConvertToPiiEntityList(List<Entity> entities)
            => entities.Select((entity) => new PiiEntity(entity)).ToList();

        internal static PiiEntityCollection ConvertToPiiEntityCollection(PiiDocumentEntities documentEntities)
        {
            return new PiiEntityCollection(ConvertToPiiEntityList(documentEntities.Entities.ToList()), documentEntities.RedactedText, ConvertToWarnings(documentEntities.Warnings));
        }

        internal static RecognizePiiEntitiesResultCollection ConvertToRecognizePiiEntitiesResultCollection(PiiEntitiesResult results, IDictionary<string, int> idToIndexMap)
        {
            var recognizeEntities = new List<RecognizePiiEntitiesResult>();

            //Read errors
            foreach (DocumentError error in results.Errors)
            {
                recognizeEntities.Add(new RecognizePiiEntitiesResult(error.Id, ConvertToError(error.Error)));
            }

            //Read document entities
            foreach (PiiDocumentEntities docEntities in results.Documents)
            {
                recognizeEntities.Add(new RecognizePiiEntitiesResult(docEntities.Id, docEntities.Statistics ?? default, ConvertToPiiEntityCollection(docEntities)));
            }

            recognizeEntities = SortHeterogeneousCollection(recognizeEntities, idToIndexMap);

            return new RecognizePiiEntitiesResultCollection(recognizeEntities, results.Statistics, results.ModelVersion);
        }

        #endregion

        #region Recognize Linked Entities

        internal static LinkedEntityCollection ConvertToLinkedEntityCollection(DocumentLinkedEntities documentEntities)
        {
            return new LinkedEntityCollection(documentEntities.Entities.ToList(), ConvertToWarnings(documentEntities.Warnings));
        }

        internal static RecognizeLinkedEntitiesResultCollection ConvertToRecognizeLinkedEntitiesResultCollection(EntityLinkingResult results, IDictionary<string, int> idToIndexMap)
        {
            var recognizeEntities = new List<RecognizeLinkedEntitiesResult>();

            //Read errors
            foreach (DocumentError error in results.Errors)
            {
                recognizeEntities.Add(new RecognizeLinkedEntitiesResult(error.Id, ConvertToError(error.Error)));
            }

            //Read document linked entities
            foreach (DocumentLinkedEntities docEntities in results.Documents)
            {
                recognizeEntities.Add(new RecognizeLinkedEntitiesResult(docEntities.Id, docEntities.Statistics ?? default, ConvertToLinkedEntityCollection(docEntities)));
            }

            recognizeEntities = SortHeterogeneousCollection(recognizeEntities, idToIndexMap);

            return new RecognizeLinkedEntitiesResultCollection(recognizeEntities, results.Statistics, results.ModelVersion);
        }

        #endregion

        #region Healthcare

        internal static List<HealthcareEntity> ConvertToHealthcareEntityCollection(IEnumerable<HealthcareEntityInternal> healthcareEntities, IEnumerable<HealthcareRelationInternal> healthcareRelations)
        {
            var entities = healthcareEntities.Select((entity) => new HealthcareEntity(entity)).ToList();
            foreach (HealthcareRelationInternal relation in healthcareRelations) {
                string relationType = relation.RelationType;
                int sourceIndex = ParseHealthcareEntityIndex(relation.Source);
                int targetIndex = ParseHealthcareEntityIndex(relation.Target);
                HealthcareEntity sourceEntity = entities[sourceIndex];
                HealthcareEntity targetEntity = entities[targetIndex];
                sourceEntity.RelatedEntities.Add(targetEntity, relationType);
                if (relation.Bidirectional)
                {
                    targetEntity.RelatedEntities.Add(sourceEntity, relationType);
                }
            }
            return entities;
        }

        internal static AnalyzeHealthcareEntitiesResultCollection ConvertToAnalyzeHealthcareEntitiesResultCollection(HealthcareResult results, IDictionary<string, int> idToIndexMap)
        {
            var healthcareEntititesResults = new List<AnalyzeHealthcareEntitiesResult>();

            //Read errors
            foreach (DocumentError error in results.Errors)
            {
                healthcareEntititesResults.Add(new AnalyzeHealthcareEntitiesResult(error.Id, ConvertToError(error.Error)));
            }

            //Read entities
            foreach (DocumentHealthcareEntitiesInternal documentHealthcareEntities in results.Documents)
            {
                healthcareEntititesResults.Add(new AnalyzeHealthcareEntitiesResult(
                    documentHealthcareEntities.Id,
                    documentHealthcareEntities.Statistics ?? default,
                    ConvertToHealthcareEntityCollection(documentHealthcareEntities.Entities, documentHealthcareEntities.Relations),
                    ConvertToWarnings(documentHealthcareEntities.Warnings)));
            }

            healthcareEntititesResults = healthcareEntititesResults.OrderBy(result => idToIndexMap[result.Id]).ToList();

            return new AnalyzeHealthcareEntitiesResultCollection(healthcareEntititesResults, results.Statistics, results.ModelVersion);
        }

        private static int ParseHealthcareEntityIndex(string reference)
        {
            Match healthcareEntityMatch = _healthcareEntityRegex.Match(reference);
            if (healthcareEntityMatch.Success)
            {
                return int.Parse(healthcareEntityMatch.Groups["entityIndex"].Value, CultureInfo.InvariantCulture);
            }

            throw new InvalidOperationException($"Failed to parse element reference: {reference}");
        }

        private static Regex _healthcareEntityRegex = new Regex(@"\#/results/documents\/(?<documentIndex>\d*)\/entities\/(?<entityIndex>\d*)$", RegexOptions.Compiled, TimeSpan.FromSeconds(2));

        #endregion

        #region Analyze Operation

        internal static PiiTask ConvertToPiiTask(RecognizePiiEntitiesOptions option)
        {
            return new PiiTask()
            {
                Parameters = new PiiTaskParameters()
                {
                    Domain = option.DomainFilter.GetString(),
                    ModelVersion = !string.IsNullOrEmpty(option.ModelVersion) ? option.ModelVersion : "latest",
                    StringIndexType = option.StringIndexType
                }
            };
        }

        internal static EntitiesTask ConvertToEntitiesTask(RecognizeEntitiesOptions option)
        {
            return new EntitiesTask()
            {
                Parameters = new EntitiesTaskParameters()
                {
                    ModelVersion = !string.IsNullOrEmpty(option.ModelVersion) ? option.ModelVersion : "latest",
                    StringIndexType = option.StringIndexType
                }
            };
        }

        internal static KeyPhrasesTask ConvertToKeyPhrasesTask(ExtractKeyPhrasesOptions option)
        {
            return new KeyPhrasesTask()
            {
                Parameters = new KeyPhrasesTaskParameters()
                {
                    ModelVersion = !string.IsNullOrEmpty(option.ModelVersion) ? option.ModelVersion : "latest",
                }
            };
        }

        internal static IList<EntitiesTask> ConvertFromEntityOptionsToTasks(IReadOnlyCollection<RecognizeEntitiesOptions> recognizeEntitiesOptions)
        {
            List<EntitiesTask> list = new List<EntitiesTask>();

            foreach (RecognizeEntitiesOptions option in recognizeEntitiesOptions)
            {
                list.Add(ConvertToEntitiesTask(option));
            }

            return list;
        }

        internal static IList<KeyPhrasesTask> ConvertFromKeyPhrasesOptionsToTasks(IReadOnlyCollection<ExtractKeyPhrasesOptions> extractKeyPhrasesOptions)
        {
            List<KeyPhrasesTask> list = new List<KeyPhrasesTask>();

            foreach (ExtractKeyPhrasesOptions option in extractKeyPhrasesOptions)
            {
                list.Add(ConvertToKeyPhrasesTask(option));
            }

            return list;
        }

        internal static IList<PiiTask> ConvertFromPiiEntityOptionsToTasks(IReadOnlyCollection<RecognizePiiEntitiesOptions> recognizePiiEntityOptions)
        {
            List <PiiTask> list = new List<PiiTask>();

            foreach (RecognizePiiEntitiesOptions option in recognizePiiEntityOptions)
            {
                list.Add(ConvertToPiiTask(option));
            }

            return list;
        }

        internal static AnalyzeBatchActionsResult ConvertToAnalyzeOperationResult(AnalyzeJobState jobState, IDictionary<string, int> map)
        {
            return new AnalyzeBatchActionsResult(jobState, map);
        }

        internal static IReadOnlyList<KeyPhraseExtractionTasksItem> ConvertToKeyPhraseExtractionTasks(IReadOnlyList<KeyPhraseExtractionTasksItem> keyPhraseExtractionTasks, IDictionary<string, int> idToIndexMap)
        {
            var collection = new List<KeyPhraseExtractionTasksItem>();
            foreach (KeyPhraseExtractionTasksItem task in keyPhraseExtractionTasks)
            {
                collection.Add(new KeyPhraseExtractionTasksItem(task, idToIndexMap));
            }

            return collection;
        }

        internal static IReadOnlyList<EntityRecognitionPiiTasksItem> ConvertToEntityRecognitionPiiTasks(IReadOnlyList<EntityRecognitionPiiTasksItem> entityRecognitionPiiTasks, IDictionary<string, int> idToIndexMap)
        {
            var collection = new List<EntityRecognitionPiiTasksItem>();
            foreach (EntityRecognitionPiiTasksItem task in entityRecognitionPiiTasks)
            {
                collection.Add(new EntityRecognitionPiiTasksItem(task, idToIndexMap));
            }

            return collection;
        }

        internal static IReadOnlyList<EntityRecognitionTasksItem> ConvertToEntityRecognitionTasks(IReadOnlyList<EntityRecognitionTasksItem> entityRecognitionTasks, IDictionary<string, int> idToIndexMap)
        {
            var collection = new List<EntityRecognitionTasksItem>();
            foreach (EntityRecognitionTasksItem task in entityRecognitionTasks)
            {
                collection.Add(new EntityRecognitionTasksItem(task, idToIndexMap));
            }

            return collection;
        }

        private static string[] parseActionErrorTarget(string targetReference)
        {
            if (string.IsNullOrEmpty(targetReference))
            {
                throw new InvalidOperationException("Expected an error with a target field referencing an action but did not get one");
            }
            Regex _targetRegex = new Regex("#/tasks/(keyPhraseExtractionTasks|entityRecognitionPiiTasks|entityRecognitionTasks)/(\\d+)", RegexOptions.Compiled, TimeSpan.FromSeconds(2));

            // action could be failed and the target reference is "#/tasks/keyPhraseExtractionTasks/0";
            Match targetMatch = _targetRegex.Match(targetReference);

            string[] taskNameIdPair = new string[2];
            if (targetMatch.Success && targetMatch.Groups.Count == 3)
            {
                taskNameIdPair[0] = targetMatch.Groups[1].Value;
                taskNameIdPair[1] = targetMatch.Groups[2].Value;
            }
            return taskNameIdPair;
        }

        internal static AnalyzeBatchActionsResult ConvertToAnalyzeBatchActionsResult(AnalyzeJobState jobState, IDictionary<string, int> map)
        {
            IDictionary<int, TextAnalyticsErrorInternal> keyPhraseErrors = new Dictionary<int, TextAnalyticsErrorInternal>();
            IDictionary<int, TextAnalyticsErrorInternal> entitiesRecognitionErrors = new Dictionary<int, TextAnalyticsErrorInternal>();
            IDictionary<int, TextAnalyticsErrorInternal> entitiesPiiRecognitionErrors = new Dictionary<int, TextAnalyticsErrorInternal>();

            if (jobState.Errors.Any())
            {
                foreach (TextAnalyticsErrorInternal error in jobState.Errors)
                {
                    string[] targetPair = parseActionErrorTarget(error.Target);
                    string taskName = targetPair[0];
                    int taskIndex = int.Parse(targetPair[1], CultureInfo.InvariantCulture);

                    if ("entityRecognitionTasks".Equals(taskName))
                    {
                        entitiesRecognitionErrors.Add(taskIndex, error);
                    }
                    else if ("entityRecognitionPiiTasks".Equals(taskName))
                    {
                        entitiesPiiRecognitionErrors.Add(taskIndex, error);
                    }
                    else if ("keyPhraseExtractionTasks".Equals(taskName))
                    {
                        keyPhraseErrors.Add(taskIndex, error);
                    }
                    else
                    {
                        throw new InvalidOperationException($"Invalid task name in target reference - {taskName}");
                    }
                }
            }

            var extractKeyPhrasesActionResult = ConvertToExtractKeyPhrasesActionResults(jobState, map, keyPhraseErrors);
            var recognizeEntitiesActionResults = ConvertToRecognizeEntitiesActionsResults(jobState, map, entitiesRecognitionErrors);
            var recognizePiiEntitiesActionResults = ConvertToRecognizePiiEntitiesActionsResults(jobState, map, entitiesPiiRecognitionErrors);

            return new AnalyzeBatchActionsResult(extractKeyPhrasesActionResult, recognizeEntitiesActionResults, recognizePiiEntitiesActionResults, jobState.Statistics);
        }

        internal static IReadOnlyCollection<ExtractKeyPhrasesActionResult> ConvertToExtractKeyPhrasesActionResults(AnalyzeJobState jobState, IDictionary<string, int> idToIndexMap, IDictionary<int, TextAnalyticsErrorInternal> errors)
        {
            var collection = new List<ExtractKeyPhrasesActionResult>();
            int index = 0;
            foreach (KeyPhraseExtractionTasksItem task in jobState.Tasks.KeyPhraseExtractionTasks)
            {
                TextAnalyticsErrorInternal error;
                errors.TryGetValue(index, out error);

                collection.Add(new ExtractKeyPhrasesActionResult(ConvertToExtractKeyPhrasesResultCollection(task.ResultsInternal, idToIndexMap), task.LastUpdateDateTime, error));

                index++;
            }

            return collection;
        }

        internal static IReadOnlyCollection<RecognizePiiEntitiesActionResult> ConvertToRecognizePiiEntitiesActionsResults(AnalyzeJobState jobState, IDictionary<string, int> idToIndexMap, IDictionary<int, TextAnalyticsErrorInternal> errors)
        {
            var collection = new List<RecognizePiiEntitiesActionResult>();
            int index = 0;
            foreach (EntityRecognitionPiiTasksItem task in jobState.Tasks.EntityRecognitionPiiTasks)
            {
                TextAnalyticsErrorInternal error;
                errors.TryGetValue(index, out error);

                collection.Add(new RecognizePiiEntitiesActionResult(ConvertToRecognizePiiEntitiesResultCollection(task.ResultsInternal, idToIndexMap), task.LastUpdateDateTime, error));
                index++;
            }

            return collection;
        }

        internal static IReadOnlyCollection<RecognizeEntitiesActionResult> ConvertToRecognizeEntitiesActionsResults(AnalyzeJobState jobState, IDictionary<string, int> idToIndexMap, IDictionary<int, TextAnalyticsErrorInternal> errors)
        {
            var collection = new List<RecognizeEntitiesActionResult>();
            int index = 0;
            foreach (EntityRecognitionTasksItem task in jobState.Tasks.EntityRecognitionTasks)
            {
                TextAnalyticsErrorInternal error;
                errors.TryGetValue(index, out error);

                collection.Add(new RecognizeEntitiesActionResult(ConvertToRecognizeEntitiesResultCollection(task.ResultsInternal, idToIndexMap), task.LastUpdateDateTime, error));
                index++;
            }

            return collection;
        }

        #endregion

        private static List<T> SortHeterogeneousCollection<T>(List<T> collection, IDictionary<string, int> idToIndexMap) where T : TextAnalyticsResult
        {
            return collection.OrderBy(result => idToIndexMap[result.Id]).ToList();
        }
    }
}


text:
{% extends "base.html" %}
{% load wagtailcore_tags navigation_tags %}
{% load djangove-cms_utils %}

{% block content %}

{{ self.title }}

{{ self.subtitle }}

            {% include "pages/includes/intro.html" with intro=self.intro only %}

            {% include "pages/includes/standard_carousel.html" with image_items=self.image_items.all only %}

            {% include "pages/includes/body.html" with body=self.body only %}

              {% secondary_menu calling_page=self %}

News Feed

              {% news_feed %}

Upcoming Events

              {% upcoming_events %}

{% endblock %}


text:
layout: post
date: '2015-12-01'
title: "Halter Pretty Maids 22382 Short Chiffon Bridesmaids Dress"
category: Halter
tags: [Halter]
---
### Halter Pretty Maids 22382 Short Chiffon Bridesmaids Dress
Just **$213.99**
###

Buy it: [https://www.eudances.com/en/halter/1832-pretty-maids-22382-short-chiffon-bridesmaids-dress.html](https://www.eudances.com/en/halter/1832-pretty-maids-22382-short-chiffon-bridesmaids-dress.html)


text:
const styleCheck_Re = /[\x00-\x1F]/;
const back_re = /^(\d{1,2})(,(\d{1,2}))?/;
const colourKey = '\x03';
const colour_re = /\x03/g;
const styleBreak = '\x0F'; // breaks all open styles ^O (\x0F)

let styles = [
	['normal', '\x00', ''], ['underline', '\x1F'],
	['bold', '\x02'], ['italic', '\x1D']
].map(function(style) {
	var escaped = encodeURI(style[1]).replace('%', '\\x');
	return {
		name: style[0],
		style: style[2] != null ? style[2] : 'irc-' + style[0],
		key: style[1],
		keyregex: new RegExp(escaped + '(.*?)(' + escaped + '|$)')
	};
});

//http://www.mirc.com/colors.html
let colors = [
	'white', 'black', 'navy', 'green', 'red', 'brown',
	'purple', 'olive', 'yellow', 'lightgreen', 'teal',
	'cyan', 'blue', 'pink', 'gray', 'lightgrey'
].reduce(function(memo, name, index) {
	memo[index] = {
		name: name,
		fore: 'irc-fg' + index,
		back: 'irc-bg' + index,
		key: index
	};
	return memo;
}, {});

function stylize(line) {
	// Recheck
	if (!styleCheck_Re.test(line)) return line;

	// split up by the irc style break character ^O
	if (line.indexOf(styleBreak) >= 0) {
		return line.split(styleBreak).map(stylize).join('');
	}

	var result = line;
	var parseArr = result.split(colourKey);
	var text, match, colour, background = '';
	for (var i = 0; i < parseArr.length; i++) {
		text = parseArr[i];
		match = text.match(back_re);
		colour = match && colors[+match[1]];
		if (!match || !colour) {
			// ^C (no colour) ending. Escape current colour and carry on
			background = '';
			continue;
		}
		// set the background colour
		// we don't overide the background local var to support nesting
		if (colors[+match[3]]) {
			background = ' ' + colors[+match[3]].back;
		}
		// update the parsed text result
		result = result.replace(colourKey + text,
			'{1}'.format(colour.fore + background, text.slice(match[0].length)));
	}

	// Matching styles (italics/bold/underline)
	// if only colors were this easy...
	styles.forEach(function(style) {
		if (result.indexOf(style.key) < 0) return;
		result = result.replace(style.keyregex, function(match, text) {
			return '{1}'.format(style.style, text);
		});
	});

	//replace the reminent colour terminations and be done with it
	return result.replace(colour_re, '');
}

module.exports = stylize;


text:
using System;
using System.IO;
using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.NRefactory.TypeSystem;

namespace OmniSharp.Solution
{
    public class CSharpFile
    {
        public string FileName;

        public ITextSource Content;
        public SyntaxTree SyntaxTree;
        public IUnresolvedFile ParsedFile;

        public StringBuilderDocument Document { get; set; }

        public CSharpFile(IProject project, string fileName) : this(project, fileName, File.ReadAllText(fileName))
        {
        }

        public CSharpFile(IProject project, string fileName, string source)
        {
            Parse(project, fileName, source);
        }

        public void Parse(IProject project, string fileName, string source)
        {
            this.FileName = fileName;
            this.Content = new StringTextSource(source);
            this.Document = new StringBuilderDocument(this.Content);
            this.Project = project;
            CSharpParser p = project.CreateParser();
            this.SyntaxTree = p.Parse(Content.CreateReader(), fileName);
            this.ParsedFile = this.SyntaxTree.ToTypeSystem();
            if(this.Project.ProjectContent != null)
                this.Project.ProjectContent.AddOrUpdateFiles(this.ParsedFile);
        }

        protected IProject Project { get; set; }

    }
}