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); }
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); }
/// <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); }
/// <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); }
static BaseDecoder CreateDecoder(string model, string classifier) { BaseDecoder decoder = null; if (classifier == "LIBLINEAER") { decoder = new LibLinearDecoder(model); } else { decoder = new SVMDecoder(model); } return(decoder); }
public abstract void Execute(BaseDecoder decoder, Chunk chunk, string filename);
public abstract List <FileTypeInfo> GetFileTypes(BaseDecoder decoder, Chunk chunk);
public abstract string GetActionText(BaseDecoder decoder, Chunk chunk);
public ActionParameters(Chunk chunk, BaseDecoder decoder, IViewer viewer) { this.Chunk = chunk; this.Decoder = decoder; this.Viewer = viewer; }