public PerspectiveTextAnalyser(string perspectiveAPITokenFile, string configFileName, GoogleTranslator translator) { PerspectiveApiToken = File.ReadAllText(perspectiveAPITokenFile); PerspectiveApiUrl = "https://commentanalyzer.googleapis.com/v1alpha1"; Translator = translator; Config = new PerspectiveTextAnalyserConfig(configFileName); Categories = Config.Categories; AllowedLanguage = Config.AllowedLanguage; }
private async Task InitAsync() { if (!File.Exists("Keys/token.txt") || !File.Exists("Keys/perspectiveAPI.txt") || !File.Exists("Keys/googleAPI.json")) { throw new FileNotFoundException("Missing Key file"); } if (!File.Exists("Config/saltForHash.txt")) { throw new FileNotFoundException("Missing Config file"); } await InitVariables(File.ReadAllText("Keys/token.txt"), File.ReadAllText("Config/saltForHash.txt")); Translator = new API.GoogleTranslator("Keys/googleAPI.json"); TextAnalyser = new API.PerspectiveTextAnalyser("Keys/perspectiveAPI.txt", "Config/PerspectiveTextAnalyserConfig.xml", Translator); ImageAnalyser = new API.GoogleVisionV1ImageAnalyser("Keys/googleAPI.json"); AutoResetEvent autoEvent = new AutoResetEvent(false); LaunchServer(autoEvent); autoEvent.WaitOne(); }