Team Fortress 2 Source Code as on 22/4/2020
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.

624 lines
16 KiB

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