コード例 #1
0
        public static PImage ToImage(this NSData data, CGSize destSize, nfloat destScale, Configuration config, TaskParameter parameters, BaseDecoder.RCTResizeMode resizeMode = BaseDecoder.RCTResizeMode.ScaleAspectFit, ImageInformation imageinformation = null, bool allowUpscale = false)
        {
            var decoded = BaseDecoder.SourceRegfToDecodedImage(data, destSize, destScale, config, parameters, resizeMode, imageinformation, allowUpscale);

            PImage result;

            if (decoded.IsAnimated)
            {
#if __IOS__
                result = PImage.CreateAnimatedImage(decoded.AnimatedImages
                                                    .Select(v => v.Image)
                                                    .Where(v => v?.CGImage != null).ToArray(), decoded.AnimatedImages.Sum(v => v.Delay) / 100.0);
#elif __MACOS__
                result = new PImage();
                var repr = decoded.AnimatedImages
                           .Select(v => v.Image.Representations().First())
                           .ToArray();
                result.AddRepresentations(repr);
#endif
            }
            else
            {
                result = decoded.Image;
            }

            return(result);
        }
コード例 #2
0
        static SECoreImpl CreateLearningCoreImpl(string root)
        {
            string path = Path.Combine(root, @"model\sentiment\learning\");

            string subFeatureSetFilePath             = Path.Combine(path, @"sub.fv");
            string subjectivityModelFilePath         = Path.Combine(path, @"sub.model");
            BaseFeatureExtractor subFeatureExtractor = null;
            BaseDecoder          sub_decoder         = null;

            if (File.Exists(subFeatureSetFilePath) && File.Exists(subjectivityModelFilePath))
            {
                subFeatureExtractor = new SubjectivityFeatureExtractor(subFeatureSetFilePath);
                sub_decoder         = CreateDecoder(subjectivityModelFilePath, classifier);
            }

            string polFeatureSetFilePath             = Path.Combine(path, @"pol.fv");
            BaseFeatureExtractor polFeatureExtractor = new PolarityFeatureExtractor(polFeatureSetFilePath);

            string      polarityModelFilePath = Path.Combine(path, @"pol.model");
            BaseDecoder pol_decoder           = CreateDecoder(polarityModelFilePath, classifier);

            SELearningCoreImpl coreImpl = new SELearningCoreImpl(subFeatureExtractor, polFeatureExtractor,
                                                                 sub_decoder, pol_decoder);

            return(coreImpl);
        }
コード例 #3
0
ファイル: ClientManager.cs プロジェクト: blakepell/Towser
        /// <summary>
        /// Wait for data from the telnet server and send it to the emulation.
        /// </summary>
        public async Task ReadLoop(string connectionId, BaseDecoder decoder, CancellationToken ct)
        {
            var client = Get(connectionId);

            if (client == null)
            {
                return;
            }

            var loginPrompt    = WebConfigurationManager.AppSettings["loginPrompt"];
            var login          = WebConfigurationManager.AppSettings["login"];
            var passwordPrompt = WebConfigurationManager.AppSettings["passwordPrompt"];
            var password       = WebConfigurationManager.AppSettings["password"];

            var loginAuto    = (!String.IsNullOrEmpty(loginPrompt) && !String.IsNullOrEmpty(login));
            var passwordAuto = (!String.IsNullOrEmpty(passwordPrompt) && !String.IsNullOrEmpty(password));

            decoder.ScriptFunc = async(string str) =>
            {
                if (!String.IsNullOrEmpty(str))
                {
                    if (loginAuto && str.EndsWith(loginPrompt, StringComparison.Ordinal))
                    {
                        await client.StreamWriter.WriteAsync(login + "\r\n");

                        loginAuto = false;
                        str       = str.Remove(str.Length - loginPrompt.Length);
                    }

                    if (passwordAuto && str.EndsWith(passwordPrompt, StringComparison.Ordinal))
                    {
                        await client.StreamWriter.WriteAsync(password + "\r\n");

                        passwordAuto = false;
                        str          = str.Remove(str.Length - passwordPrompt.Length);
                    }
                }
                return(str);
            };

            const int bufferSize = 4096;

            while (client.IsConnected && !ct.IsCancellationRequested)
            {
                var inBytes = await client.ReadAsync(bufferSize, ct);

                foreach (var b in inBytes)
                {
                    await decoder.AddByte(b);
                }
                await decoder.Flush();
            }

            Disconnect(connectionId);
        }
コード例 #4
0
ファイル: ClientManager.cs プロジェクト: blakepell/Towser
        /// <summary>
        /// Initialise a new telnet connection based on the web config.
        /// </summary>
        public async Task Init(string connectionId, BaseDecoder decoder, string termtype = null)
        {
            var server = WebConfigurationManager.AppSettings["server"];
            var port   = Int32.Parse(WebConfigurationManager.AppSettings["port"]);

            termtype = termtype ?? WebConfigurationManager.AppSettings["termtype"];
            var encodingName    = WebConfigurationManager.AppSettings["encoding"];
            var altEncodingName = WebConfigurationManager.AppSettings["altencoding"];

            decoder.SetEncoding(encodingName, altEncodingName);

            var client = await Connect(connectionId, server, port, termtype, encodingName);
        }
コード例 #5
0
        static BaseDecoder CreateDecoder(string model, string classifier)
        {
            BaseDecoder decoder = null;

            if (classifier == "LIBLINEAER")
            {
                decoder = new LibLinearDecoder(model);
            }
            else
            {
                decoder = new SVMDecoder(model);
            }

            return(decoder);
        }
コード例 #6
0
ファイル: Saver.cs プロジェクト: Jither/SCUMMRevLib
 public abstract void Execute(BaseDecoder decoder, Chunk chunk, string filename);
コード例 #7
0
ファイル: Saver.cs プロジェクト: Jither/SCUMMRevLib
 public abstract List <FileTypeInfo> GetFileTypes(BaseDecoder decoder, Chunk chunk);
コード例 #8
0
ファイル: Saver.cs プロジェクト: Jither/SCUMMRevLib
 public abstract string GetActionText(BaseDecoder decoder, Chunk chunk);
コード例 #9
0
 public ActionParameters(Chunk chunk, BaseDecoder decoder, IViewer viewer)
 {
     this.Chunk   = chunk;
     this.Decoder = decoder;
     this.Viewer  = viewer;
 }