private static AwsTextDetection MapDetection(TextDetection t) { AwsTextDetection awsTextDetection = new AwsTextDetection(); awsTextDetection.Confidence = t.Confidence; awsTextDetection.DetectedText = t.DetectedText; awsTextDetection.Geometry = GetGeometry(t.Geometry); awsTextDetection.Type = t.Type.Value; return(awsTextDetection); }
static void Main(string[] args) { var textDetection = new TextDetection(); string vanik1 = "vanik hakobyan"; string vanik2 = "van hakobyan"; var similarity = textDetection.GetSimilarity(vanik1, vanik2, AlgorithmTypes.SmithWatermanGotohWindowedAffine); using (var db = new MonitoringEntities()) { var githubLinkedinCrossTables = db.GithubLinkedinCrossTables.ToList(); var gList = githubLinkedinCrossTables.Select(a => a.GithubUserId); var lList = githubLinkedinCrossTables.Select(a => a.LinkedinUserId); var githubProfiles = db.GithubProfiles.Where(x => !gList.Contains(x.Id)).ToList(); var linkedinProfiles = db.LinkedinProfiles.Where(x => !lList.Contains(x.Id)).ToList(); foreach (var githubProfile in githubProfiles) { if (string.IsNullOrEmpty(githubProfile.Name) || string.IsNullOrEmpty(githubProfile.UserName)) { continue; } foreach (var linkedinProfile in linkedinProfiles) { if (string.IsNullOrEmpty(linkedinProfile.FullName) || string.IsNullOrEmpty(linkedinProfile.Username)) { continue; } var similarityByName = textDetection.GetSimilarity(githubProfile.Name, linkedinProfile.FullName, AlgorithmTypes.OverlapCoefficient); var similarityByUserName = textDetection.GetSimilarity(githubProfile.UserName, linkedinProfile.Username, AlgorithmTypes.OverlapCoefficient); if (similarityByName > 0.9 && similarityByUserName > 0.9) { if (db.GithubLinkedinCrossTables.FirstOrDefault(x => x.GithubUserId == githubProfile.Id) == null) { db.GithubLinkedinCrossTables.Add(new GithubLinkedinCrossTable() { GithubUserId = githubProfile.Id, LinkedinUserId = linkedinProfile.Id }); db.SaveChanges(); } break; } } } } }
private static async void BotOnPhotoReceived(object sender, MessageEventArgs messageEventArgs) { message = messageEventArgs.Message; try { if (message == null || message.Type != MessageType.PhotoMessage) { return; } var fileId = message.Photo[message.Photo.Length - 1].FileId; var file = await Bot.GetFileAsync(fileId); var stream = file.FileStream; using (Stream output = new FileStream($"../../Photo/img{message.Chat.Id}{fileId}.jpg", FileMode.Append)) { byte[] buffer = new byte[32 * 1024]; int read; while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) { output.Write(buffer, 0, read); } } await Bot.SendChatActionAsync(message.Chat.Id, ChatAction.Typing); var FileUrl = @"D:\\128.jpg"; using (var streamm = System.IO.File.Open(FileUrl, FileMode.Open)) { FileToSend fts = new FileToSend(); fts.Content = streamm; fts.Filename = FileUrl.Split('\\').Last(); var test = await Bot.SendStickerAsync(message.Chat.Id, fts); } string imagePath = $"../../Photo/img{message.Chat.Id}{fileId}.jpg"; TextDetection newTD = new TextDetection(); string text = newTD.photo2string(imagePath); string result = ParseString(text); Console.WriteLine(Convert.ToDouble(result)); bill = Math.Abs(Convert.ToDouble(result)); var keyboard = new Telegram.Bot.Types.ReplyMarkups.InlineKeyboardMarkup(); keyboard.InlineKeyboard = new Telegram.Bot.Types.InlineKeyboardButtons.InlineKeyboardButton[][] { new Telegram.Bot.Types.InlineKeyboardButtons.InlineKeyboardButton[] { new KeyboardButton("Продукты питания"), new KeyboardButton("Техника"), }, new Telegram.Bot.Types.InlineKeyboardButtons.InlineKeyboardButton[] { new KeyboardButton("Транспорт"), new KeyboardButton("Мобильная связь") }, new Telegram.Bot.Types.InlineKeyboardButtons.InlineKeyboardButton[] { new KeyboardButton("Другое") }, }; await Bot.SendTextMessageAsync(message.Chat.Id, "Выберите категорию товара, который вы приобрели", replyMarkup : keyboard); await Bot.SendTextMessageAsync(message.Chat.Id, WalletKeeper.Constants.IT_IS_DONE); } catch (Exception e) { await Bot.SendTextMessageAsync(message.Chat.Id, WalletKeeper.Constants.FAILED); } }