This archive contains the source code corresponding to the implementation of Royal Skousen's Analogical Modeling algorithm as explained in chapter 16 of _Analogical Modeling: An Exemplar-Based Approach to Language_, with slight modifications as noted below. This implementation is numbered AM 2.1. This source code does not represent the most efficient implementation to date. It should be used primarily in conjunction with the chapter mentioned above as a study aid for understanding the theory behind the code, especially since all other implementations in the AM 2 series derive from it. Please refer to the Analogical Modeling web site for the latest developments. Nevertheless, this source code should compile and run on any Unix-like platform which has the GCC C compiler and Perl 5.6 or later installed. A makefile is provided; the user need only type "make" at the prompt to successfully build. The executable customarily remains in the build directory; there is no "make install" target. The makefile can be edited for use with a different compiler or to add debugging flags; however, the user is warned against making any other changes to the makefile unless thoroughly versed in the intricacies of embedding Perl within C programs. The Perl API changed significantly with version 5.6. Thus, this particular implementation's source code will not compile in environments whose Perl versions predate 5.6 (usually the 5.005 series). More recent implementations have workarounds for this; please see the web site for details. These are the slight modifications made to the AM 2.1 source code since publication of the book: -- The statement #include has been replaced by #define and && #define or || amc.c will now compile on systems without standard header file iso646.h (which unfortunately is quite a few systems). -- Instead of allocating and freeing memory for the supracontextual lattice at the beginning and end of each test item run, this memory is allocated just once, right after the Perl subroutine setup() has been called from amc.c. To be able to do this, setup() looks at the first test item to see what the maximum possible number of active variables is and stores this in $maxvar, whose value is retrieved by amc.c in the standard way (see section 4.4 in chapter 16). This results in a significant reduction in run time as the number of active variables increases. Also, if enough memory cannot be allocated, the program terminates cleanly. -- With the probability set less than 1, users often want to run the same test item more than once. This functionality has been added. amc.c finds out how many times to run each test item by inspecting the value of $repeat in amc.pl. Also, if the probability is quite low, there may be no data items selected for a particular test item to compare against. In this case, amc.c skips directly to calling endTestItem() in amc.pl, which prints the message "No data items considered. No prediction possible." -- The flag to mark heterogeneity within add() has been changed (see the end of section 6). The statement c->data = calloc(1, sizeof(AM_CONTEXT)) is replaced by c->data == NULL and the test if (p->next->data[0]) is replaced by if (p->next->data != NULL) thus obviating more calls for memory allocation. *************************************************************** The primary maintainer of the AM source code is Theron Stanford (theron@byu.edu). ***************************************************************