//获取所有翻译类别 private MappingService[] GetSpecifiedMappingServices(string CategoryName) { MappingService[] transliterationServices = null; try { MappingEnumOptions enumOptions = new MappingEnumOptions() { Category = CategoryName }; transliterationServices = MappingService.GetServices(enumOptions); } catch (LinguisticException exc) { MessageBox.Show(exc.Message); } return(transliterationServices); }
private MappingService[] GetSpecifiedMappingServices(string CategoryName) { MappingService[] transliterationServices = null; try { MappingEnumOptions enumOptions = new MappingEnumOptions() { Category = CategoryName }; transliterationServices = MappingService.GetServices(enumOptions); } catch (LinguisticException exc) { ShowErrorMessage(String.Format("Error calling ELS: {0}, HResult: {1}", exc.ResultState.ErrorMessage, exc.ResultState.HResult)); } return(transliterationServices); }
public static void TransliterationEnumSample() { try { MappingEnumOptions enumOptions = new MappingEnumOptions(); enumOptions.Category = "Transliteration"; MappingService[] transliterationServices = MappingService.GetServices(enumOptions); foreach (MappingService service in transliterationServices) { Console.WriteLine("Service: {0}", service.Description); } } catch (LinguisticException exc) { Console.WriteLine("Error calling ELS: {0}, HResult: {1}", exc.ResultState.ErrorMessage, exc.ResultState.HResult); } }
public static void CyrlToLatinTransUsageSample2() { try { MappingEnumOptions enumOptions = new MappingEnumOptions(); enumOptions.InputScript = "Cyrl"; enumOptions.OutputScript = "Latn"; enumOptions.Category = "Transliteration"; MappingService[] cyrlToLatin = MappingService.GetServices(enumOptions); using (MappingPropertyBag bag = cyrlToLatin[0].RecognizeText("АБВГД.", null)) { string transliterated = bag.GetResultRanges()[0].FormatData(new StringFormatter()); Console.WriteLine("Transliterated text: {0}", transliterated); } } catch (LinguisticException exc) { Console.WriteLine("Error calling ELS: {0}, HResult: {1}", exc.ResultState.ErrorMessage, exc.ResultState.HResult); } }
public void GetServicesOfNullReturnsKnownServices() { MappingService[] ss = MappingService.GetServices(null); Guid[] guids = new Guid[] { MappingAvailableServices.LanguageDetection, MappingAvailableServices.ScriptDetection, MappingAvailableServices.TransliterationBengaliToLatin, MappingAvailableServices.TransliterationCyrillicToLatin, MappingAvailableServices.TransliterationDevanagariToLatin, MappingAvailableServices.TransliterationHansToHant, MappingAvailableServices.TransliterationHantToHans, MappingAvailableServices.TransliterationMalayalamToLatin }; foreach (MappingService s in ss) { Assert.True(s.BuildVersion >= 0); Assert.NotEqual <string>(s.Category, String.Empty); Assert.NotEqual <string>(s.Category, ""); Assert.NotNull(s.Category); Assert.NotEqual <string>(s.Copyright, String.Empty); Assert.NotEqual <string>(s.Copyright, ""); Assert.NotNull(s.Copyright); Assert.NotEqual <string>(s.Description, String.Empty); Assert.NotEqual <string>(s.Description, ""); Assert.NotNull(s.Description); Assert.Contains <Guid>(s.Guid, guids); Assert.NotEmpty(s.InputContentTypes); Assert.True(s.MajorVersion >= 0 && s.MinorVersion >= 0); Assert.NotEmpty(s.OutputContentTypes); } }
public void GetServicesOfNullReturnsMoreThanZeroServices() { MappingService[] ss = MappingService.GetServices(null); Assert.True(ss.Length >= 0); }