Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

135 lines
3.2 KiB

  1. #include "volcanop.h"
  2. #include "res.h"
  3. #include "brknet.h"
  4. // Segmentation stuff
  5. BBOX_PROB_TABLE *g_pProbTable;
  6. // Default language model code
  7. UNIGRAM_INFO g_unigramInfo;
  8. BIGRAM_INFO g_bigramInfo;
  9. CLASS_BIGRAM_INFO g_classBigramInfo;
  10. TTUNE_INFO g_ttuneInfo;
  11. wchar_t g_pLocale[16];
  12. wchar_t g_pLocaleDir[1024];
  13. wchar_t g_pRecogDir[1024];
  14. VOLCANO_PARAMS_INFO g_vtuneInfo;
  15. VOLCANO_CONFIG g_volcanoConfig;
  16. CENTIPEDE_INFO g_centipedeInfo;
  17. BOOL LoadSegmNetFromResource (HINSTANCE hInst, int nResID, int nType);
  18. BOOL LoadCharDetFromResource (HINSTANCE hInst, int nResID, int nType);
  19. // Load up everything for the lattice search
  20. // Loads the following databases: unigrams, bigrams, class bigrams, tuning, centipede, free input
  21. BOOL LatticeConfig(HINSTANCE hInstanceDll)
  22. {
  23. BOOL fError = FALSE;
  24. LatticeConfigInit();
  25. // Tuning parameters (can probably be removed for the non-insurance version)
  26. if (!fError && !TTuneLoadRes(
  27. &g_ttuneInfo, hInstanceDll, RESID_TTUNE, VOLCANO_RES
  28. )) {
  29. fError = TRUE;
  30. ASSERT(("Error in TTuneLoadRes", FALSE));
  31. }
  32. if (!fError && !VTuneLoadRes(&g_vtuneInfo, hInstanceDll, RESID_VTUNE, VOLCANO_RES))
  33. {
  34. fError = TRUE;
  35. ASSERT(("Error in VTuneLoadRes", FALSE));
  36. }
  37. // Load unigrams
  38. if (!fError && !UnigramLoadRes(
  39. &g_locRunInfo, &g_unigramInfo,
  40. hInstanceDll, RESID_UNIGRAM, VOLCANO_RES
  41. )) {
  42. fError = TRUE;
  43. ASSERT(("Error in UnigramLoadRes", FALSE));
  44. }
  45. // Load bigrams only if we're in WinCE
  46. # if !defined(WINCE) && !defined(FAKE_WINCE)
  47. if (!fError && !BigramLoadRes(
  48. &g_locRunInfo, &g_bigramInfo, hInstanceDll, RESID_BIGRAM,
  49. VOLCANO_RES
  50. )) {
  51. fError = TRUE;
  52. ASSERT(("Error in BigramLoadRes", FALSE));
  53. }
  54. # endif
  55. // Load class bigrams
  56. if (!fError && !ClassBigramLoadRes(
  57. &g_locRunInfo, &g_classBigramInfo, hInstanceDll,
  58. RESID_CLASS_BIGRAM, VOLCANO_RES
  59. )) {
  60. fError = TRUE;
  61. ASSERT(("Error in ClassBigramLoadRes", FALSE));
  62. }
  63. // Load up centipede
  64. if (!fError) {
  65. if (!CentipedeLoadRes(&g_centipedeInfo, hInstanceDll, RESID_CENTIPEDE, VOLCANO_RES, &g_locRunInfo)) {
  66. fError = TRUE;
  67. ASSERT(("Error in CentipedeLoadRes", FALSE));
  68. }
  69. }
  70. // Load the bbox prob table for pre-segmentation
  71. if (!fError) {
  72. g_pProbTable = LoadBBoxProbTableRes(
  73. hInstanceDll, RESID_BBOX_PROBS, VOLCANO_RES
  74. );
  75. // Failure to load here is not an error, we just won't support free input.
  76. }
  77. // Try to load up IIMLanguage
  78. #ifdef USE_IFELANG3
  79. // LatticeConfigIFELang3();
  80. #endif
  81. // Don't bother trying to load other free input databases if the basic
  82. // one is not available.
  83. if (g_pProbTable != NULL)
  84. {
  85. // try to load the break net
  86. if (LoadBrkNetFromResource (hInstanceDll, RESID_BRKNET, VOLCANO_RES))
  87. {
  88. // load the segmnet, optional
  89. if (!LoadSegmNetFromResource (hInstanceDll, RESID_SEGMNET, VOLCANO_RES))
  90. {
  91. // fError = TRUE;
  92. // ASSERT(("Error in LoadSegmNetFromResource", FALSE));
  93. }
  94. // load the char detector, not optional
  95. if (!LoadCharDetFromResource (hInstanceDll, RESID_CHARDET, VOLCANO_RES))
  96. {
  97. fError = TRUE;
  98. ASSERT(("Error in LoadCharDetFromResource", FALSE));
  99. }
  100. }
  101. }
  102. // Did everything load correctly?
  103. if (fError)
  104. {
  105. return FALSE;
  106. }
  107. return TRUE;
  108. }
  109. // Unload those things that can be unloaded
  110. BOOL LatticeUnconfig()
  111. {
  112. return TRUE;
  113. }