home *** CD-ROM | disk | FTP | other *** search
- /*
- * ReaderDomain.m:
- * This file is used to generate programmatically a .domain file
- * to be used with the FrenchReader miniexample.
- * The FrenchText file must be fed into the attribute parser. It is supposed
- * to be the most representative sample of the French language. For the purpose
- * of this example, a random French text has been chosen.
- *
- * Written by Mai Nguyen, NeXT Developer Support
- * June 1993
- */
-
- #import <indexing/indexing.h>
- #import <streams/streams.h>
- #import <libc.h>
- #import "IXFrenchReader.h"
-
- void main() {
- IXFrenchReader* theReader;
- IXAttributeParser* theParser;
- IXWeightingDomain* theDomain;
- List * aList;
- int fd; /* file descriptor */
- NXStream *stream = NULL;
- BOOL saveOK;
-
- /* Set up a French Reader and a Parser */
- theReader = [[IXFrenchReader alloc] init];
- theParser = [[IXAttributeParser alloc] init];
- aList = [[List alloc] init];
- [aList addObject:theReader];
- [theParser setAttributeReaders:aList];
- /* Parse a representative French text file to generate the
- * histogram. Note that the FrenchText file in this example
- * is NOT at all representative of the French language, but
- * is only used for testing purposes.
- */
- [theParser parseFile:"FrenchText" ofType:"ASCII"];
-
-
- if (saveOK =
- (((fd = open ("French.domain", O_WRONLY|O_CREAT|O_TRUNC, 0644)) != -1) &&
- (stream = NXOpenFile (fd, NX_WRITEONLY))))
- theDomain = [[[IXWeightingDomain alloc]
- initFromAttributeParser:theParser] writeDomain:stream];
- if (stream) NXClose (stream);
- if (fd != -1) close (fd);
-
- if (saveOK)
- printf("Domain file successfully created\n");
- else
- printf("Domain file can't be created\n");
-
-
- exit(0);
- }
-