Skip to content

Instantly share code, notes, and snippets.

View arafattehsin's full-sized avatar
🎯
Focusing

Arafat Tehsin arafattehsin

🎯
Focusing
View GitHub Profile
@arafattehsin
arafattehsin / data.csv
Created May 4, 2019 07:26
This data is used for the SentimentAnalyzer for .NET Standard apps
We can't make this file beautiful and searchable because it's too large.
Label,TweetId,Date,Query,User,Tweet
0,2252799415,Sat Jun 20 07:01:14 PDT 2009,NO_QUERY,uhohcaitie,Well that was a major let down was expecting somthing good
0,2252799527,Sat Jun 20 07:01:15 PDT 2009,NO_QUERY,SeaSunSky,i was fugly on thursday nite
0,2252799546,Sat Jun 20 07:01:15 PDT 2009,NO_QUERY,Baby_KeL_KeL,Girly Nite 2nite with face masks and takeaway. Last nite hanging wuth my sister
0,2252799810,Sat Jun 20 07:01:17 PDT 2009,NO_QUERY,nigelhoney,"@peterlyle oh plus two tripods and reflectors, a backpack plus small shoulder bag. Would take those primes and macros if I owned them "
0,2252800004,Sat Jun 20 07:01:18 PDT 2009,NO_QUERY,myschel,Are u sure its summer??? It feels like spring to me
0,2252802749,Sat Jun 20 07:01:37 PDT 2009,NO_QUERY,formaggio,No hummus tasting today I'm sure we'll see Samira again soon! Angus is still coming to taste out some of his wine at around 1pm.
0,2252802810,Sat Jun 20 07:01:37 PDT 2009,NO_QUERY,caitlin_bruce,@tommcfly naughty dougie!! i wanna get tickets to come see u
@arafattehsin
arafattehsin / VABotService.cs
Created October 30, 2019 06:29
This is core class to connect Dynamics 365 Virtual Agent for Customer Service with Microsoft Bot Framework
public class VABotService
{
private readonly HttpClient _httpClient;
public VABotService(VABotEndpoint endpoint, string botName)
{
Endpoint = endpoint;
BotName = botName;
ChannelData = new VABotChannelData(endpoint.BotId, endpoint.TenantId);
_httpClient = new HttpClient();
@arafattehsin
arafattehsin / BotServices.cs
Created October 30, 2019 06:46
Class to read configuration and assigning them to the respective language models and knowledge sources such as LUIS, QnA and Virtual Agent
public class BotServices : IBotServices
{
public BotServices(IConfiguration configuration)
{
// Read the setting for cognitive services (LUIS, QnA) from the appsettings.json
// If includeApiResults is set to true, the full response from the LUIS api (LuisResult)
// will be made available in the properties collection of the RecognizerResult
VABotDispatch = new LuisRecognizer(new LuisApplication(
configuration["LuisAppId"],
configuration["LuisAPIKey"],
@arafattehsin
arafattehsin / VABot.cs
Created October 30, 2019 06:53
Excerpt from the main Bot class; for complete code, please refer to CognitiveRocket repo.
private async Task ProcessVABotAsync(ITurnContext<Microsoft.Bot.Schema.IMessageActivity> turnContext, CancellationToken cancellationToken)
{
var token = await _botServices.VABotService.GetTokenAsync();
using (var directLineClient = new DirectLineClient(token))
{
var conversation = await directLineClient.Conversations.StartConversationAsync();
var conversationtId = conversation.ConversationId;
var response = await directLineClient.Conversations.PostActivityAsync(conversationtId, new Microsoft.Bot.Connector.DirectLine.Activity()
@arafattehsin
arafattehsin / Immersive Reader (Cognitive Service) Controller
Created December 9, 2019 01:18
This is a sample Controller for obtaining a token for Immersive Reader Cognitive Service
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using ImmersiveReaderDemo.Models;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
@arafattehsin
arafattehsin / GetFlightDetails.cs
Created February 23, 2020 08:45
This is a sample Azure function without any real API implementation for Flight Tracker.
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System.Net.Http;
@arafattehsin
arafattehsin / UserSimulator.cs
Created October 27, 2022 23:01
This is a sample User Simulator class for Azure Personalizer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Simulator
{
public class UserSimulator
{
@arafattehsin
arafattehsin / Simulator.cs
Created October 31, 2022 12:13
This is a sample for the Simulator used for Azure Personalizer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Simulator
{
public class Simulator
{
public async Task<List<Country>> LoadCountries()
{
try
{
using var stream = await FileSystem.OpenAppPackageFileAsync("countries.json");
using var reader = new StreamReader(stream);
var contents = reader.ReadToEnd();
var countries = JsonSerializer.Deserialize<List<Country>>(contents);
return countries;
}
public bool SetSettingsToStorage(Settings settings)
{
Preferences.Default.Set(nameof(settings.Model), settings.Model);
Preferences.Default.Set(nameof(settings.EndpointKey), settings.EndpointKey);
Preferences.Default.Set(nameof(settings.IsUseOpenAI), settings.IsUseOpenAI);
Preferences.Default.Set(nameof(settings.EndpointURL), settings.EndpointURL);
Preferences.Default.Set(nameof(settings.EmbeddingModel), settings.EmbeddingModel);
Preferences.Default.Set(nameof(settings.OrgId), settings.OrgId);
return true;
}