home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Mac OS / AIAT / Headers / HighLevel / Abstractor.h next >
Encoding:
Text File  |  1998-04-16  |  4.5 KB  |  160 lines  |  [TEXT/CWIE]

  1. //----------------------------------------------------------------
  2. //    Abstractor
  3. //    Copyright:    © 1997 - 1998 by Apple Computer, Inc., all rights reserved.
  4. //----------------------------------------------------------------
  5.  
  6. #pragma once
  7. #ifndef Abstractor_h
  8. #define Abstractor_h
  9.  
  10. #pragma import on
  11.  
  12. #if PRAGMA_STRUCT_ALIGN
  13.     #pragma options align=power
  14. #endif
  15.  
  16. #include "IAExtentCorpus.h"
  17. #include "VectorAccessor.h"    
  18. #include <time.h>
  19.  
  20. #pragma IA_BEGIN_EXPORTS
  21.  
  22. class LetterTree;
  23.  
  24. const uint32 MAXSENTENCES =1000;
  25.  
  26. class IAExtentParser : public IAObject
  27. {
  28.     public:
  29.                      IAExtentParser();
  30.                      IAExtentParser(byte* buffer, uint32 bufferLength, bool removezReturns = true);
  31.                                     
  32.         virtual     ~IAExtentParser();
  33.         
  34.         void        SetBuffer(byte* buffer, uint32 bufferLength);
  35.         
  36.         byte*        GetBuffer()         const     {return fBuffer;}
  37.         uint32         GetBufferLength()     const     {return fBufferLength;}
  38.         
  39.         void        SetStartOfExtent(byte* start) {fStartOfSent = start;}
  40.         byte*        GetStartOfExtent()     const    {return fStartOfSent;}
  41.         
  42.         void        SetExtentLength(uint32 length) {fSentLength = length;}
  43.         uint32        GetExtentLength()     const    {return fSentLength;}
  44.  
  45.         void        SetStartOfNext(byte* start)  {fStartOfNext = start;}
  46.         byte*        GetStartOfNext()     const    {return fStartOfNext;}
  47.         
  48.         void        SetBytesLeft(uint32 length)  { fCurrentLength = length;}
  49.         uint32        GetBytesLeft()         const    {return fCurrentLength;}
  50.     
  51.         void        SetGroupNumber(uint32 gNum)    {fParagraphNumber = gNum;}
  52.         uint32        GetGroupNumber() const    {return fParagraphNumber;}
  53.  
  54.         void        SetOrderNumber(uint32 oNum)    {fOrderOfSent = oNum;}        
  55.         uint32        GetOrderNumber()     const    {return fOrderOfSent;}
  56.  
  57.         bool        IsCancelled() const {return fDidCancel;}
  58.         
  59.         bool        AreReturnsRemoved() const {return fRemoveReturns;}
  60.         
  61.         virtual     IAExtentDoc* GetNextExtent(RankedProgressFn* progfn, clock_t progFrequency, void* callerData);
  62.         
  63.     protected:
  64.         virtual     IAExtentDoc* GettingNextExtent (RankedProgressFn* progfn, clock_t progFrequency, void* callerData, bool *endBuffer) = 0;
  65.                         
  66.     private:
  67.     
  68.         byte*         fStartOfNext;        // start of next parse of activity
  69.         byte*        fStartOfSent;        // begining of the extent
  70.         uint32        fSentLength;        // extent length
  71.         
  72.         
  73.         byte*        fBuffer;            // text buffer
  74.         uint32         fBufferLength;        // length of text buffer    
  75.         uint32        fCurrentLength;        // bytes left to parse
  76.         
  77.         uint32        fParagraphNumber;    // section number
  78.         uint32        fOrderOfSent;        // order within a section
  79.         
  80.         bool        fDidCancel;            // operation was cancelled
  81.         bool        fRemoveReturns;        // remove returns;
  82.         bool        fRanOut;            // no need to call again
  83.         
  84. };    
  85.  
  86.  
  87.  
  88. class IADocumentAbstractor : public IAObject
  89. {
  90.     public:
  91.                         IADocumentAbstractor();
  92.                         IADocumentAbstractor(IAExtentParser* parser, IAStorage* storage, IAAnalysis* analysis);
  93.  
  94.         virtual         ~IADocumentAbstractor();
  95.         
  96.         virtual void Summarize    (RankedProgressFn* progfn, clock_t progFrequency, void* callerData, 
  97.                             uint32 maxLevel = 0,                    // how many sentencs will you ask for?
  98.                             TermIndex* contextIndex = NULL);        // may be NULL for no context index
  99.  
  100.         void            SetAnalysis (IAAnalysis* analysis);
  101.         void            SetStorage (IAStorage* storage);
  102.         void            SetParser(IAExtentParser* parser);
  103.         
  104.         uint32          GetNumberOfExtents () const;
  105.         IAExtentDoc**     GetExtents() const;
  106.     
  107.     private:
  108.  
  109.     void FindAbstracts (VectorIndex* index,
  110.                             RankedProgressFn* progfn, clock_t progFrequency, void *callerData,
  111.                             int maxLevel, TermIndex* contextIndex);
  112.  
  113.         uint32  fNumberSentences;
  114.         IAStorage*    fStorage;
  115.         IAAnalysis*    fAnalysis;
  116.         IAExtentParser* fParser;
  117.         IAExtentDoc** fSentences;
  118.         RankedHit** fHits;
  119.         
  120. };
  121.  
  122.  
  123. class IAANSISentenceParser : public IAExtentParser
  124. {
  125.     public:
  126.                      IAANSISentenceParser(byte* buffer, uint32 bufferLength, const char* abbrevFile = NULL, bool removezReturns = true);
  127.                                     
  128.         virtual     ~IAANSISentenceParser();
  129.  
  130. // assume sentences to start with upper case letters.
  131. // false allows sentences to start with lower case
  132. // default is true            
  133.         void        SetRequiredUpper(bool value);
  134.         bool        IsRequiredUpper() const;
  135.         
  136.     protected:
  137.         virtual     IAExtentDoc* GettingNextExtent (RankedProgressFn* progfn, clock_t progFrequency, void* callerData, bool *endBuffer);
  138.                         
  139.     private:
  140.         IAANSISentenceParser();
  141.         bool LookUpAbbrev (char* startOfWord, char* endOfWord) const;
  142.         
  143.         LetterTree*     fAbbrevDB;
  144.         bool         fRequireUpper;        // assume sentences to start with upper case letters.
  145.                                         // false allows sentences to start with lower case
  146.                                         // default is true    
  147. };    
  148.  
  149.  
  150. IAExceptionCode                    OutOfRangeSentenceNumber = 'ABSE';
  151.  
  152. #pragma IA_END_EXPORTS
  153.  
  154. #if PRAGMA_STRUCT_ALIGN
  155.     #pragma options align=reset
  156. #endif
  157.  
  158. #pragma import reset
  159. #endif
  160.