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. This archive also contains a pre-built Windows binary executable for use on systems with Perl 5.6 installed. Perl for Windows is typically obtained from . This binary will not work with any other version of Perl from ActiveState. To check your version of Perl, type "perl -v" at the command prompt. If you don't know how to do that, do the following: 1. Double-click on "My Computer" from the desktop 2. Double-click on "Local Disk (C:)" (or something with a similar name) 3. Double-click on "Perl" 4. Double-click on "bin" 5. Look for a file called "perl56.dll". If it's there, you have version 5.6 To run, just double-click on "amc.exe". This executable was compiled using the GCC 3.2 C compiler from the MinGW project (see ). Because gcc does not currently understand the .lib file format, other tools were used to create an archive "libPerl56.a" that gcc could link to. Contact the code maintainer (listed below) for more information. This code should also build with compilers from Microsoft, Borland, or other vendors, but this has not been attempted. If you plan to compile, make sure you read the perlembed documentation carefully. Help is also available from the code maintainer. Please note that 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). ***************************************************************