LanguageAnalysis.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:15k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       LanguageAnalysis.h
  3.  
  4.      Contains:   Language Analysis Manager Interfaces
  5.  
  6.      Version:    Technology: Mac OS 8
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1996-2001 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:      For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __LANGUAGEANALYSIS__
  18. #define __LANGUAGEANALYSIS__
  19. #ifndef __MACTYPES__
  20. #include "MacTypes.h"
  21. #endif
  22. #ifndef __FILES__
  23. #include "Files.h"
  24. #endif
  25. #ifndef __AEREGISTRY__
  26. #include "AERegistry.h"
  27. #endif
  28. #ifndef __DICTIONARY__
  29. #include "Dictionary.h"
  30. #endif
  31. #ifndef __TEXTCOMMON__
  32. #include "TextCommon.h"
  33. #endif
  34. #ifndef __MACERRORS__
  35. #include "MacErrors.h"
  36. #endif
  37. #if PRAGMA_ONCE
  38. #pragma once
  39. #endif
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. #if PRAGMA_IMPORT
  44. #pragma import on
  45. #endif
  46. #if PRAGMA_STRUCT_ALIGN
  47.     #pragma options align=power
  48. #elif PRAGMA_STRUCT_PACKPUSH
  49.     #pragma pack(push, 2)
  50. #elif PRAGMA_STRUCT_PACK
  51.     #pragma pack(2)
  52. #endif
  53. typedef struct OpaqueLAEnvironmentRef*  LAEnvironmentRef;
  54. typedef struct OpaqueLAContextRef*      LAContextRef;
  55. typedef AEKeyword                       LAPropertyKey;
  56. typedef DescType                        LAPropertyType;
  57. /*
  58.     Data structure for high level API
  59. */
  60. struct LAMorphemeRec {
  61.     ByteCount                       sourceTextLength;
  62.     LogicalAddress                  sourceTextPtr;
  63.     ByteCount                       morphemeTextLength;
  64.     LogicalAddress                  morphemeTextPtr;
  65.     UInt32                          partOfSpeech;
  66. };
  67. typedef struct LAMorphemeRec            LAMorphemeRec;
  68. struct LAMorphemesArray {
  69.     ItemCount                       morphemesCount;
  70.     ByteCount                       processedTextLength;
  71.     ByteCount                       morphemesTextLength;
  72.     LAMorphemeRec                   morphemes[1];
  73. };
  74. typedef struct LAMorphemesArray         LAMorphemesArray;
  75. typedef LAMorphemesArray *              LAMorphemesArrayPtr;
  76. enum {
  77.     kLAMorphemesArrayVersion    = 0
  78. };
  79. /*
  80.     Definitions for result path/bundle structure
  81. */
  82. typedef AERecord                        LAMorphemeBundle;
  83. typedef AERecord                        LAMorphemePath;
  84. typedef AERecord                        LAMorpheme;
  85. typedef AERecord                        LAHomograph;
  86. enum {
  87.     keyAELAMorphemeBundle       = FOUR_CHAR_CODE('lmfb'),
  88.     keyAELAMorphemePath         = FOUR_CHAR_CODE('lmfp'),
  89.     keyAELAMorpheme             = FOUR_CHAR_CODE('lmfn'),
  90.     keyAELAHomograph            = FOUR_CHAR_CODE('lmfh')
  91. };
  92. enum {
  93.     typeLAMorphemeBundle        = typeAERecord,
  94.     typeLAMorphemePath          = typeAERecord,
  95.     typeLAMorpheme              = typeAEList,
  96.     typeLAHomograph             = typeAEList
  97. };
  98. /*
  99.     Definitions for morpheme/homograph information
  100. */
  101. enum {
  102.     keyAEMorphemePartOfSpeechCode = FOUR_CHAR_CODE('lamc'),
  103.     keyAEMorphemeTextRange      = FOUR_CHAR_CODE('lamt')
  104. };
  105. enum {
  106.     typeAEMorphemePartOfSpeechCode = FOUR_CHAR_CODE('lamc'),
  107.     typeAEMorphemeTextRange     = FOUR_CHAR_CODE('lamt')
  108. };
  109. typedef UInt32                          MorphemePartOfSpeech;
  110. struct MorphemeTextRange {
  111.     UInt32                          sourceOffset;
  112.     UInt32                          length;
  113. };
  114. typedef struct MorphemeTextRange        MorphemeTextRange;
  115. /*
  116.     Mask for High level API convert flags 
  117. */
  118. enum {
  119.     kLAEndOfSourceTextMask      = 0x00000001
  120. };
  121. /*
  122.     Constants for leading/trailing path of analysis function
  123. */
  124. enum {
  125.     kLADefaultEdge              = 0,
  126.     kLAFreeEdge                 = 1,
  127.     kLAIncompleteEdge           = 2
  128. };
  129. /*
  130.     Constants for confirm and shift function
  131. */
  132. enum {
  133.     kLAAllMorphemes             = 0
  134. };
  135. /*
  136.     Library version
  137. */
  138. EXTERN_API( UInt32 )
  139. LALibraryVersion                (void);
  140. /*
  141.     High level API
  142. */
  143. EXTERN_API( OSStatus )
  144. LATextToMorphemes               (LAContextRef           context,
  145.                                  TextEncoding           preferedEncoding,
  146.                                  ByteCount              textLength,
  147.                                  ConstLogicalAddress    sourceText,
  148.                                  ByteCount              bufferSize,
  149.                                  OptionBits             convertFlags,
  150.                                  UInt32                 structureVersion,
  151.                                  ByteCount *            acceptedLength,
  152.                                  LAMorphemesArrayPtr    resultBuffer);
  153. /*
  154.     Handling Context
  155. */
  156. EXTERN_API( OSStatus )
  157. LAOpenAnalysisContext           (LAEnvironmentRef       environ,
  158.                                  LAContextRef *         context);
  159. EXTERN_API( OSStatus )
  160. LACloseAnalysisContext          (LAContextRef           context);
  161. /*
  162.     Handling Environment
  163. */
  164. EXTERN_API( OSStatus )
  165. LAGetEnvironmentList            (UInt32                 maxCount,
  166.                                  UInt32 *               actualCount,
  167.                                  LAEnvironmentRef       environmentList[]);
  168. EXTERN_API( OSStatus )
  169. LAGetEnvironmentName            (LAEnvironmentRef       environment,
  170.                                  Str63                  environmentName);
  171. EXTERN_API( OSStatus )
  172. LAGetEnvironmentRef             (ConstStr63Param        targetEnvironmentName,
  173.                                  LAEnvironmentRef *     environment);
  174. EXTERN_API( OSStatus )
  175. LACreateCustomEnvironment       (LAEnvironmentRef       baseEnvironment,
  176.                                  ConstStr63Param        newEnvironmentName,
  177.                                  Boolean                persistent,
  178.                                  LAEnvironmentRef *     newEnvironment);
  179. EXTERN_API( OSStatus )
  180. LADeleteCustomEnvironment       (LAEnvironmentRef       environment);
  181. /*
  182.     Handling dictionries
  183. */
  184. EXTERN_API( OSStatus )
  185. LAOpenDictionary                (LAEnvironmentRef       environ,
  186.                                  const FSSpec *         dictionary);
  187. EXTERN_API( OSStatus )
  188. LACloseDictionary               (LAEnvironmentRef       environ,
  189.                                  const FSSpec *         dictionary);
  190. EXTERN_API( OSStatus )
  191. LAListAvailableDictionaries     (LAEnvironmentRef       environ,
  192.                                  ItemCount              maxCount,
  193.                                  ItemCount *            actualCount,
  194.                                  FSSpec                 dictionaryList[],
  195.                                  Boolean                opened[]);
  196. EXTERN_API( OSStatus )
  197. LAAddNewWord                    (LAEnvironmentRef       environ,
  198.                                  const FSSpec *         dictionary,
  199.                                  const AEDesc *         dataList);
  200. /*
  201.     Analyzing text
  202. */
  203. EXTERN_API( OSStatus )
  204. LAMorphemeAnalysis              (LAContextRef           context,
  205.                                  ConstUniCharArrayPtr   text,
  206.                                  UniCharCount           textLength,
  207.                                  LAMorphemePath *       leadingPath,
  208.                                  LAMorphemePath *       trailingPath,
  209.                                  ItemCount              pathCount,
  210.                                  LAMorphemeBundle *     result);
  211. EXTERN_API( OSStatus )
  212. LAContinuousMorphemeAnalysis    (LAContextRef           context,
  213.                                  ConstUniCharArrayPtr   text,
  214.                                  UniCharCount           textLength,
  215.                                  Boolean                incrementalText,
  216.                                  LAMorphemePath *       leadingPath,
  217.                                  LAMorphemePath *       trailingPath,
  218.                                  Boolean *              modified);
  219. EXTERN_API( OSStatus )
  220. LAGetMorphemes                  (LAContextRef           context,
  221.                                  LAMorphemePath *       result);
  222. EXTERN_API( OSStatus )
  223. LAShiftMorphemes                (LAContextRef           context,
  224.                                  ItemCount              morphemeCount,
  225.                                  LAMorphemePath *       path,
  226.                                  UniCharCount *         shiftedLength);
  227. EXTERN_API( OSStatus )
  228. LAResetAnalysis                 (LAContextRef           context);
  229. /*
  230.     Check Language Analysis Manager availability
  231. */
  232. #if TARGET_RT_MAC_CFM
  233. #ifdef __cplusplus
  234.     inline pascal Boolean LALanguageAnalysisAvailable() { return (LALibraryVersion != (void*)kUnresolvedCFragSymbolAddress); }
  235. #else
  236.     #define LALanguageAnalysisAvailable()   ((LALibraryVersion != (void*)kUnresolvedCFragSymbolAddress)
  237. #endif
  238. #elif TARGET_RT_MAC_MACHO
  239. /* Language Analysis Manager is always available on OS X */
  240. #ifdef __cplusplus
  241.     inline pascal Boolean LALanguageAnalysisAvailable() { return true; }
  242. #else
  243.     #define LALanguageAnalysisAvailable()   (true)
  244. #endif
  245. #endif  /*  */
  246. /*
  247. =============================================================================================
  248.     Definitions for Japanese Analysis Module
  249. =============================================================================================
  250. */
  251. /*
  252.     Names for default environments for Japanese analysis
  253. */
  254. #define kLAJapaneseKanaKanjiEnvironment             "pKanaKanjiConversion"
  255. #define kLAJapaneseMorphemeAnalysisEnvironment      "pJapaneseMorphemeAnalysis"
  256. #define kLAJapaneseTTSEnvironment                   "pJapaneseTextToSpeech"
  257. /*
  258.     File cretor for dictionary of Apple Japanese access method
  259. */
  260. enum {
  261.     kAppleJapaneseDictionarySignature = FOUR_CHAR_CODE('jlan')
  262. };
  263. /*
  264.     Engine limitations
  265. */
  266. enum {
  267.     kMaxInputLengthOfAppleJapaneseEngine = 200
  268. };
  269. /*
  270.     Definitions of information in the path/bundle
  271. */
  272. typedef MorphemePartOfSpeech            JapanesePartOfSpeech;
  273. typedef UInt16                          HomographWeight;
  274. typedef UInt8                           HomographAccent;
  275. /*
  276.     AE keywords and type definitions for morpheme/homograph information
  277. */
  278. enum {
  279.     keyAEHomographDicInfo       = FOUR_CHAR_CODE('lahd'),
  280.     keyAEHomographWeight        = FOUR_CHAR_CODE('lahw'),
  281.     keyAEHomographAccent        = FOUR_CHAR_CODE('laha')
  282. };
  283. enum {
  284.     typeAEHomographDicInfo      = FOUR_CHAR_CODE('lahd'),
  285.     typeAEHomographWeight       = typeShortInteger,
  286.     typeAEHomographAccent       = FOUR_CHAR_CODE('laha')
  287. };
  288. /*
  289.     Structure for dictionary information of homograph
  290. */
  291. struct HomographDicInfoRec {
  292.     DCMDictionaryID                 dictionaryID;
  293.     DCMUniqueID                     uniqueID;
  294. };
  295. typedef struct HomographDicInfoRec      HomographDicInfoRec;
  296. /*
  297. =============================================================================================
  298.     Definitions for Japanese part of speeches
  299. =============================================================================================
  300. */
  301. /*
  302.     Masks for part of speeches
  303. */
  304. enum {
  305.     kLASpeechRoughClassMask     = 0x0000F000,
  306.     kLASpeechMediumClassMask    = 0x0000FF00,
  307.     kLASpeechStrictClassMask    = 0x0000FFF0,
  308.     kLASpeechKatsuyouMask       = 0x0000000F
  309. };
  310. /*
  311.     Part of speeches
  312. */
  313. enum {
  314.     kLASpeechMeishi             = 0x00000000,                   /* noun */
  315.     kLASpeechFutsuuMeishi       = 0x00000000,                   /* general noun */
  316.     kLASpeechJinmei             = 0x00000100,                   /* person name */
  317.     kLASpeechJinmeiSei          = 0x00000110,                   /* family name */
  318.     kLASpeechJinmeiMei          = 0x00000120,                   /* first name */
  319.     kLASpeechChimei             = 0x00000200,                   /* place name */
  320.     kLASpeechSetsubiChimei      = 0x00000210,                   /* place name with suffix */
  321.     kLASpeechSoshikimei         = 0x00000300,                   /* organization name */
  322.     kLASpeechKoyuuMeishi        = 0x00000400,                   /* proper noun */
  323.     kLASpeechSahenMeishi        = 0x00000500,                   /* special noun */
  324.     kLASpeechKeidouMeishi       = 0x00000600,                   /* special noun */
  325.     kLASpeechRentaishi          = 0x00001000,
  326.     kLASpeechFukushi            = 0x00002000,                   /* adverb */
  327.     kLASpeechSetsuzokushi       = 0x00003000,                   /* conjunction */
  328.     kLASpeechKandoushi          = 0x00004000,
  329.     kLASpeechDoushi             = 0x00005000,                   /* verb */
  330.     kLASpeechGodanDoushi        = 0x00005000,
  331.     kLASpeechKagyouGodan        = 0x00005000,
  332.     kLASpeechSagyouGodan        = 0x00005010,
  333.     kLASpeechTagyouGodan        = 0x00005020,
  334.     kLASpeechNagyouGodan        = 0x00005030,
  335.     kLASpeechMagyouGodan        = 0x00005040,
  336.     kLASpeechRagyouGodan        = 0x00005050,
  337.     kLASpeechWagyouGodan        = 0x00005060,
  338.     kLASpeechGagyouGodan        = 0x00005070,
  339.     kLASpeechBagyouGodan        = 0x00005080,
  340.     kLASpeechIchidanDoushi      = 0x00005100,
  341.     kLASpeechKahenDoushi        = 0x00005200,
  342.     kLASpeechSahenDoushi        = 0x00005300,
  343.     kLASpeechZahenDoushi        = 0x00005400,
  344.     kLASpeechKeiyoushi          = 0x00006000,                   /* adjective */
  345.     kLASpeechKeiyoudoushi       = 0x00007000,
  346.     kLASpeechSettougo           = 0x00008000,                   /* prefix*/
  347.     kLASpeechSuujiSettougo      = 0x00008100,                   /* prefix for numbers */
  348.     kLASpeechSetsubigo          = 0x00009000,                   /* suffix */
  349.     kLASpeechJinmeiSetsubigo    = 0x00009100,                   /* suffix for person name */
  350.     kLASpeechChimeiSetsubigo    = 0x00009200,                   /* suffix for place name */
  351.     kLASpeechSoshikimeiSetsubigo = 0x00009300,                  /* suffix for organization name */
  352.     kLASpeechSuujiSetsubigo     = 0x00009400,                   /* suffix for numbers */
  353.     kLASpeechMuhinshi           = 0x0000A000,                   /* no category */
  354.     kLASpeechTankanji           = 0x0000A000,                   /* character */
  355.     kLASpeechKigou              = 0x0000A100,                   /* symbol */
  356.     kLASpeechKuten              = 0x0000A110,
  357.     kLASpeechTouten             = 0x0000A120,
  358.     kLASpeechSuushi             = 0x0000A200,                   /* numbers */
  359.     kLASpeechDokuritsugo        = 0x0000A300,
  360.     kLASpeechSeiku              = 0x0000A400,
  361.     kLASpeechJodoushi           = 0x0000B000,                   /* auxiliary verb */
  362.     kLASpeechJoshi              = 0x0000C000                    /* postpositional particle */
  363. };
  364. /*
  365.     Conjugations
  366.  */
  367. enum {
  368.     kLASpeechKatsuyouGokan      = 0x00000001,                   /* stem */
  369.     kLASpeechKatsuyouMizen      = 0x00000002,
  370.     kLASpeechKatsuyouRenyou     = 0x00000003,
  371.     kLASpeechKatsuyouSyuushi    = 0x00000004,
  372.     kLASpeechKatsuyouRentai     = 0x00000005,
  373.     kLASpeechKatsuyouKatei      = 0x00000006,
  374.     kLASpeechKatsuyouMeirei     = 0x00000007
  375. };
  376. #if PRAGMA_STRUCT_ALIGN
  377.     #pragma options align=reset
  378. #elif PRAGMA_STRUCT_PACKPUSH
  379.     #pragma pack(pop)
  380. #elif PRAGMA_STRUCT_PACK
  381.     #pragma pack()
  382. #endif
  383. #ifdef PRAGMA_IMPORT_OFF
  384. #pragma import off
  385. #elif PRAGMA_IMPORT
  386. #pragma import reset
  387. #endif
  388. #ifdef __cplusplus
  389. }
  390. #endif
  391. #endif /* __LANGUAGEANALYSIS__ */