pax_global_header00006660000000000000000000000064145201655430014517gustar00rootroot0000000000000052 comment=8229b48ed099e630ad0ca37ee6b98f900502a34a LanguageMachines-timblserver-8229b48/000077500000000000000000000000001452016554300175325ustar00rootroot00000000000000LanguageMachines-timblserver-8229b48/.github/000077500000000000000000000000001452016554300210725ustar00rootroot00000000000000LanguageMachines-timblserver-8229b48/.github/workflows/000077500000000000000000000000001452016554300231275ustar00rootroot00000000000000LanguageMachines-timblserver-8229b48/.github/workflows/badge.svg000066400000000000000000000061641452016554300247210ustar00rootroot00000000000000 LanguageMachines-timblserver-8229b48/.github/workflows/timblserver.yml000066400000000000000000000076141452016554300262200ustar00rootroot00000000000000name: C/C++ CI on: push: branches: [master] paths: - 'src/**' - 'include/**' - '.github/**' pull_request: branches: [master] workflow_dispatch: jobs: notification: runs-on: ubuntu-latest name: Notify start to IRC-gitlama outputs: branch: ${{ steps.extract_branch.outputs.branch }} steps: - name: Extract Branch name shell: bash run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT id: extract_branch - name: IRC notification uses: Gottox/irc-message-action@v2 with: server: irc.uvt.nl channel: '#gitlama' nickname: GitHub message: > ${{ github.actor }} started a build of ${{ github.event.repository.name }} [${{ steps.extract_branch.outputs.branch }}] build: runs-on: ${{ matrix.os }} needs: notification strategy: matrix: os: [ubuntu-latest, macos-latest] compiler: [g++, clang++] steps: - name: Cancel Previous Runs uses: styfle/cancel-workflow-action@0.11.0 with: access_token: ${{ github.token }} - uses: actions/checkout@v3 - name: Install Build Environment run: | if [ "$RUNNER_OS" == "Linux" ]; then sudo apt-get install pkg-config autoconf-archive else brew upgrade; brew install pkg-config; brew install autoconf-archive; brew install autoconf; brew install automake; fi - name: Install Dependencies run: | if [ "$RUNNER_OS" == "Linux" ]; then sudo apt-get install libicu-dev libxml2-dev libbz2-dev sudo apt-get install zlib1g-dev cppcheck else brew install libxml2; brew install bzip2; brew install zlib; brew install cppcheck fi - name: install TiccUtils env: CXX: ${{ matrix.compiler }} run: | git clone https://github.com/LanguageMachines/ticcutils; cd ticcutils; bash bootstrap.sh; ./configure; make; sudo make install; cd ..; - name: install TiMBL env: CXX: ${{ matrix.compiler }} run: | git clone https://github.com/LanguageMachines/timbl; cd timbl; bash bootstrap.sh; ./configure; make; sudo make install; cd ..; - name: bootstrap run: sh bootstrap.sh - name: compiler-id id: compiler run: | id=$(echo ${{matrix.compiler}} | cut -d\+ -f1) echo "id=$id" >> $GITHUB_OUTPUT - name: configure env: CXX: ${{ matrix.compiler }} run: ./configure - name: Static Code-check run: cppcheck --enable=all --quiet --error-exitcode=0 . - name: make run: make - name: install run: sudo make install - name: Notify IRC of failure if: ${{ failure() }} uses: Gottox/irc-message-action@v2 with: server: irc.uvt.nl channel: '#gitlama' nickname: GH-${{ runner.os }}-${{ steps.compiler.outputs.id }} message: "timblserver [${{ needs.notification.outputs.branch }}] build with ${{ matrix.compiler }} by ${{ github.actor }} on ${{ matrix.os }}: \u00034FAIL\u0003" - name: Notify IRC of succes if: ${{ success() }} uses: Gottox/irc-message-action@v2 with: server: irc.uvt.nl channel: '#gitlama' nickname: GH-${{ runner.os }}-${{ steps.compiler.outputs.id }} message: "timblserver [${{ needs.notification.outputs.branch }}] build with ${{ matrix.compiler }} by ${{ github.actor }} on ${{ matrix.os }}: \u00033SUCCESS\u0003" LanguageMachines-timblserver-8229b48/.gitignore000066400000000000000000000010771452016554300215270ustar00rootroot00000000000000Makefile Makefile.in aclocal.m4 autom4te.cache/ compile config.guess config.h config.h.in config.log config.status config.sub configure demos/.deps/ demos/.libs/ demos/Makefile demos/Makefile.in demos/sockettestClient demos/*.o demos/sockettestServer depcomp docs/Makefile docs/Makefile.in include/Makefile include/Makefile.in include/timblserver/Makefile include/timblserver/Makefile.in install-sh libtool ltmain.sh m4/ missing src/.deps/ src/.libs/ src/*.lo src/*.o src/Makefile src/Makefile.in src/libtimblserver.la src/timblclient src/timblserver stamp-h1 timblserver.pc LanguageMachines-timblserver-8229b48/AUTHORS000066400000000000000000000015251452016554300206050ustar00rootroot00000000000000TiMBL authors Lead programmer: Ko van der Sloot Code, algorithm, and design contributions by: Peter Berck Antal van den Bosch Walter Daelemans Ton Weijters Jakub Zavrel Contributors: People who contributed to Timbl by suggesting improvements, filing bug reports, asking the right questions etc.: Robert Andersson Vincent Van Asch Joris Bleys Johan Bos Joan Bresnan Stefan Breuer Sabine Buchholz Bertjan Busser Sander Canisius Win Carus Felix Filoz Alan Frankel Sven Hartrumpf Iris Hendrickx Lyndon Hiew Steve Hunt Valentin Jijkoun Gunn Inger Lyse Svetoslav Marinov Erwin Marsi Liam McGrath Jens Nilsson Ties Kemper Tom DePlonty Albert Russel Frank Scheelen Armin Schmidt Olaf Seibert Gabriel Skantze Carline Sporleder Herman Stehouwer Erik Tjong Kim Sang Joseph Turian Frederik Vaassen Corne Versloot Colin Wilson Linda Yung Bram Vandekerckhove LanguageMachines-timblserver-8229b48/COPYING000066400000000000000000001045131452016554300205710ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . LanguageMachines-timblserver-8229b48/INSTALL000066400000000000000000000363321452016554300205720ustar00rootroot00000000000000Installation Instructions ************************* Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without warranty of any kind. Basic Installation ================== Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. Some packages provide this `INSTALL' file but do not implement all of the features documented below. The lack of an optional feature in a given package is not necessarily a bug. More recommendations for GNU packages can be found in *note Makefile Conventions: (standards)Makefile Conventions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package, generally using the just-built uninstalled binaries. 4. Type `make install' to install the programs and any data files and documentation. When installing into a prefix owned by root, it is recommended that the package be configured and built as a regular user, and only the `make install' phase executed with root privileges. 5. Optionally, type `make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. This target does not install anything. Running this target as a regular user, particularly if the prior `make install' required root privileges, verifies that the installation completed correctly. 6. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 7. Often, you can also type `make uninstall' to remove the installed files again. In practice, not all packages have tested that uninstallation works correctly, even though it is required by the GNU Coding Standards. 8. Some packages, particularly those that use Automake, provide `make distcheck', which can by used by developers to test that all other targets like `make install' and `make uninstall' work correctly. This target is generally not run by end users. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. This is known as a "VPATH" build. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or "universal" binaries--by specifying multiple `-arch' options to the compiler but only a single `-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CPP="gcc -E" CXXCPP="g++ -E" This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results using the `lipo' tool if you have problems. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX', where PREFIX must be an absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. In general, the default for these options is expressed in terms of `${prefix}', so that specifying just `--prefix' will affect all of the other directory specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the correct locations to `configure'; however, many packages provide one or both of the following shortcuts of passing variable assignments to the `make install' command line to change installation locations without having to reconfigure or recompile. The first method involves providing an override variable for each affected directory. For example, `make install prefix=/alternate/directory' will choose an alternate location for all directory configuration variables that were expressed in terms of `${prefix}'. Any directories that were specified during `configure', but not in terms of `${prefix}', must each be overridden at install time for the entire installation to be relocated. The approach of makefile variable overrides for each directory variable is required by the GNU Coding Standards, and ideally causes no recompilation. However, some platforms have known limitations with the semantics of shared libraries that end up requiring recompilation when using this method, particularly noticeable in packages that use GNU Libtool. The second method involves providing the `DESTDIR' variable. For example, `make install DESTDIR=/alternate/directory' will prepend `/alternate/directory' before all installation names. The approach of `DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even when some directory options were not specified in terms of `${prefix}' at `configure' time. Optional Features ================= If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Some packages offer the ability to configure how verbose the execution of `make' will be. For these packages, running `./configure --enable-silent-rules' sets the default to minimal output, which can be overridden with `make V=1'; while running `./configure --disable-silent-rules' sets the default to verbose, which can be overridden with `make V=0'. Particular systems ================== On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its `' header file. The option `-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended to try ./configure CC="cc" and if that doesn't work, try ./configure CC="cc -nodtk" On Solaris, don't put `/usr/ucb' early in your `PATH'. This directory contains several dysfunctional programs; working variants of these programs are available in `/usr/bin'. So, if you need `/usr/ucb' in your `PATH', put it _after_ `/usr/bin'. On Haiku, software installed for all users goes in `/boot/common', not `/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to an Autoconf bug. Until the bug is fixed you can use this workaround: CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of all of the options to `configure', and exit. `--help=short' `--help=recursive' Print a summary of the options unique to this package's `configure', and exit. The `short' variant lists options used only in the top level, while the `recursive' variant lists options also present in any nested packages. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--prefix=DIR' Use DIR as the installation prefix. *note Installation Names:: for more details, including other options available for fine-tuning the installation locations. `--no-create' `-n' Run the configure checks, but stop before creating any output files. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. LanguageMachines-timblserver-8229b48/Makefile.am000066400000000000000000000004021452016554300215620ustar00rootroot00000000000000ACLOCAL_AMFLAGS =-I m4 --install SUBDIRS = src include demos docs m4 EXTRA_DIST = bootstrap.sh AUTHORS TODO NEWS README.md timblserver.pc.in pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = timblserver.pc ChangeLog: NEWS git pull; git2cl > ChangeLog LanguageMachines-timblserver-8229b48/NEWS000066400000000000000000000054631452016554300202410ustar00rootroot000000000000001.18 - 2023-10-31 [Ko van der Sloot] * minor fix to satisfy compilation against musl 1.17 - 2023-10-21 [Ko van der Sloot] * dependency on libtar is removed * code modernization/cleanup * some code modernization, avoiding CppCheck warnings 1.16 - 2023-01-02 [Ko van der Sloot] * some code modernization, avoiding CppCheck warnings 1.15 - 2020-12-15 [Ko van der Sloot] * adapted to the newest ticcutils * depends on ICU too, now * small code refactorings * bumped library version 1.14 - 2020-04-15 [Ko van der Sloot] * adapted to the newest ticcutils - changed namespace TimblServer to TiCCServer - modifications in Socket stuff * fix for https://github.com/LanguageMachines/timblserver/issues/2 1.13 - 2019-10-21 [Ko van der Sloot] * Added JSON support. The JSON syntax might change in the future, so handle with care. * lots of refactoring. Depends on recent ticcutils and timbl 1.12 - 2018-05-16 [Ko van der Sloot] Maintenance release: - updated and improved configure/build - typo's corrected - some code cleanup - better error messages. 1.11 - 2016-07-11 [Ko van der Sloot] Maintenance release: - accept long options --version and --help - improved a warning 1.10 - 2016-01-14 [Ko van der Sloot] * moved repository to GitHub * added Travis support * now depends on ticcutils: CommandLine * basic Server stuff is moved to ticcutils * numereous small fixes and refactoring 1.9 - 2014-09-23 [Ko van der Sloot] * release 1.8 - 2014-09-16 * major rework: basic server stuff no longer depends on Timbl. in the long run that can be moved to ticcutils * +vmd option added * uses TiCC::CommandLine now * fixed a leak * 1.7 - 2013-04-03 * use more ticcutils stuff * fixed problem with pid and logfile paths when --deamonize=no 1.6 - 2012-10-11 [Ko van der Sloot] * This version is build on ticcutils too 1.5 - 2012-06-19 [Ko van der Sloot] * Some typos edited * Small bug fixes * configue.ac modernized 1.4 - 2011-12-20 [ Ko van de Sloot] * small code change to satisfy '-pedantic' * small code change to remove warning on 32 bits systems. (makes -pedantic complain again, though ) * made timblserver.pc use Requires.private: 1.3 - 2011-10-20 [ Ko van de Sloot] * created a simple man page for timblclient. * addded Version() and VersionName() functions to be consistent withe the whole Timbl family. * moved the class in a new namespace TimblServer, and renamed the TimblServer class to ServerClass * removed unneeded limitation on TCP_BUFFER_SIZE 1.2 - 2011-03-21 [ Ko van der Sloot ] * decapped TimblServer ==> timblserver and libTimblServer ==> libtimblserver * src/ServerBase.cxx, src/SocketBasics.cxx: -pedantic proof 1.1 - 2010-11-17 [ Ko van der Sloot ] * moved LogStream stuff back to Timbl 1.0.0 - 2010-02-22 [ Ko van der Sloot ] * Started a separate TimblServer package LanguageMachines-timblserver-8229b48/README000066400000000000000000000000521452016554300204070ustar00rootroot00000000000000Please see README.md for for information. LanguageMachines-timblserver-8229b48/README.md000066400000000000000000000066401452016554300210170ustar00rootroot00000000000000[![GitHub build](https://github.com/LanguageMachines/timblserver/actions/workflows/timblserver.yml/badge.svg?branch=master)](https://github.com/LanguageMachines/timblserver/actions/) [![Language Machines Badge](http://applejack.science.ru.nl/lamabadge.php/timblserver)](http://applejack.science.ru.nl/languagemachines/ ) [![DOI](https://zenodo.org/badge/20526237.svg)](https://zenodo.org/badge/latestdoi/20526237) =========================================== TimblServer 1.18 (c) CLS/ILK/CLiPS 1998 - 2023 =========================================== Tilburg Memory Based Learner -- Server Centre for Language Studies, Radboud University Nijmegen Induction of Linguistic Knowledge Research Group, Tilburg University and Centre for Dutch Language and Speech, University of Antwerp **Website:** https://languagemachines.github.io/timbl/ This is the Server extension for Timbl. TiMBL is an open source software package implementing several memory-based learning algorithms, among which IB1-IG, an implementation of k-nearest neighbor classification with feature weighting suitable for symbolic feature spaces, and IGTree, a decision-tree approximation of IB1-IG. All implemented algorithms have in common that they store some representation of the training set explicitly in memory. During testing, new cases are classified by extrapolation from the most similar stored cases. For over fifteen years TiMBL has been mostly used in natural language processing as a machine learning classifier component, but its use extends to virtually any supervised machine learning domain. Due to its particular decision-tree-based implementation, TiMBL is in many cases far more efficient in classification than a standard k-nearest neighbor algorithm would be. ----------------------------------------------------------------------- Comments and bug-reports are welcome at our issue tracker at https://github.com/LanguageMachines/timblserver/issues or by mailing lamasoftware (at) science.ru.nl. Updates and more info may be found on https://languagemachines.github.io/timbl . TimblServer is distributed under the GNU Public Licence v3 (see the file COPYING). ----------------------------------------------------------------------- This software has been tested on: - Intel platforms running several versions of Linux, including Ubuntu, Debian, Arch Linux, Fedora (both 32 and 64 bits) - MAC platform running OS X 10.10 Compilers: - GCC (use 7.0 or later) - Clang Contents of this distribution: - Sources - Licensing information ( COPYING ) - Installation instructions ( INSTALL ) - Build system based on GNU Autotools - Example data files ( in the demos directory ) - Documentation ( in the docs directory ) Dependencies: To be able to succesfully build TiMBL from the tarball, you need the following pakages: - ticcutils (https://github.com/LanguageMachines/ticcutils) - timbl (https://github.com/LanguageMachines/timbl) - pkg-config - libxml2-dev To install TimblServer, first consult whether your distribution's package manager has an up-to-date package for TimblServer. If not, for easy installation of everything concerning TiMBL and all dependencies, it is included as part of our software distribution LaMachine: https://proycon.github.io/LaMachine . To compile and install manually from source instead, provided you have all the dependencies installed: $ bash bootstrap.sh $ ./configure $ make $ make install (See the INSTALL file for more details) LanguageMachines-timblserver-8229b48/TODO000066400000000000000000000000611452016554300202170ustar00rootroot00000000000000* rework timblclient * a lot of testing and suchLanguageMachines-timblserver-8229b48/bootstrap.sh000077500000000000000000000033231452016554300221070ustar00rootroot00000000000000# bootstrap - script to bootstrap the distribution rolling engine # usage: # $ sh ./bootstrap && ./configure && make dist[check] # # this yields a tarball which one can install doing # # $ tar zxf PACKAGENAME-*.tar.gz # $ cd PACKAGENAME-* # $ ./configure # $ make # # make install # requirements: # GNU autoconf, from e.g. ftp.gnu.org:/pub/gnu/autoconf/ # GNU automake, from e.g. http://ftp.gnu.org/gnu/automake/ automake=automake aclocal=aclocal # if you want to autogenerate a ChangeLog form svn: # # svn2cl, a python script, as used in the GNU Enterprise project. # By jcater (Jason Cater), contributions by reinhard (Reinhard Müller). # Get it from # http://www.gnuenterprise.org/cgi-bin/viewcvs.cgi/*checkout*/gnue/trunk/gnue-common/utils/svn2cl . # svn2cl is used in Makefile.am too. # # (Another svn2cl implementation, in perl, is at # http://www.contactor.se/~dast/svn/archive-2002-04/0910.shtml) # # see also toplevel Makefile.am # test -f ChangeLog || { # svn log --verbose > ChangeLog #} if $automake --version|head -1 |grep ' 1\.[4-9]'; then echo "automake 1.4-1.9 is active. You should use automake 1.10 or later" if test -f /etc/debian_version; then echo " sudo apt-get install automake" echo " sudo update-alternatives --config automake" fi exit 1 fi # Debian automake package installs as automake-version. Use this # to make sure the right automake is being used. # if not installed, use: apt-get install automake1.9 AUTOMAKE=automake ACLOCAL=aclocal autoreconf --install \ --symlink # add --make if you want to run "make" too. # autoreconf should run something like: # # aclocal-1.9 \ # && automake-1.9 --add-missing --verbose --gnu \ # && autoconf LanguageMachines-timblserver-8229b48/configure.ac000066400000000000000000000042471452016554300220270ustar00rootroot00000000000000# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ([2.69]) AC_INIT([timblserver],[1.18],[lamasoftware@science.ru.nl]) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([.]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADERS([config.h]) if test x"${CXXFLAGS+set}" = xset; then # the user set CXXFLAGS; don't override it. cxx_flags_were_set=true else cxx_flags_were_set=false fi if $cxx_flags_were_set; then CXXFLAGS=$CXXFLAGS fi # Checks for programs. AC_PROG_CXX( [g++ c++] ) # libtool stuff LT_INIT # when running tests, use CXX AC_LANG([C++]) AX_PTHREAD([],[AC_MSG_ERROR([We need pthread support!])]) if test x"$ax_pthread_ok" = xyes; then LIBS="$PTHREAD_LIBS $LIBS" \ CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" fi AC_OPENMP AM_CONDITIONAL( WANT_OMP, [test "x$ac_cv_prog_cxx_openmp" != "xunsupported"] ) # Checks for header files. AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h sys/socket.h unistd.h ]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL AC_C_INLINE AC_TYPE_SSIZE_T AC_TYPE_SIZE_T AC_TYPE_PID_T # Checks for library functions. AC_FUNC_FORK AC_CHECK_FUNCS([getaddrinfo gethostbyaddr gethostbyname inet_ntoa memset socket strerror dup2 memmove]) AX_LIB_SOCKET_NSL AX_TYPE_SOCKLEN_T PKG_PROG_PKG_CONFIG if test "x$prefix" = "xNONE"; then prefix="/usr/local" fi if test "x$PKG_CONFIG_PATH" = x; then export PKG_CONFIG_PATH="$prefix/lib/pkgconfig" else export PKG_CONFIG_PATH="$prefix/lib/pkgconfig:$PKG_CONFIG_PATH" fi AC_OSX_PKG( [icu4c] ) PKG_CHECK_MODULES([ticcutils], [ticcutils >= 0.28] ) CXXFLAGS="$CXXFLAGS $ticcutils_CFLAGS" LIBS="$LIBS $ticcutils_LIBS" PKG_CHECK_MODULES([XML2], [libxml-2.0 >= 2.6.16] ) CXXFLAGS="$CXXFLAGS $XML2_CFLAGS" LIBS="$XML2_LIBS $LIBS" PKG_CHECK_MODULES([timbl], [timbl >= 6.8] ) CXXFLAGS="$CXXFLAGS $timbl_CFLAGS" LIBS="$LIBS $timbl_LIBS" PKG_CHECK_MODULES([ICU], [icu-uc >= 50 icu-io] ) CXXFLAGS="$CXXFLAGS $ICU_CFLAGS" LIBS="$ICU_LIBS $LIBS" AC_CONFIG_FILES([ Makefile timblserver.pc m4/Makefile src/Makefile docs/Makefile include/Makefile include/timblserver/Makefile demos/Makefile ]) AC_OUTPUT LanguageMachines-timblserver-8229b48/demos/000077500000000000000000000000001452016554300206415ustar00rootroot00000000000000LanguageMachines-timblserver-8229b48/demos/Makefile.am000066400000000000000000000006341452016554300227000ustar00rootroot00000000000000# $Id: Makefile.am 2927 2009-09-08 15:26:45Z sloot $ # $URL: $ AM_CPPFLAGS = -I@top_srcdir@/include AM_CXXFLAGS = -std=c++0x if WANT_OMP noinst_PROGRAMS = sockettestServer sockettestClient else noinst_PROGRAMS = endif LDADD = ../src/libtimblserver.la if WANT_OMP sockettestClient_SOURCES = sockettestClient.cxx sockettestServer_SOURCES = sockettestServer.cxx endif exdir = $(datadir)/doc/@PACKAGE@/examples LanguageMachines-timblserver-8229b48/demos/sockettestClient.cxx000066400000000000000000000112441452016554300247160ustar00rootroot00000000000000/* Copyright (c) 1998 - 2018 ILK - Tilburg University CNTS - University of Antwerp This file is part of timblserver timblserver is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. timblserver is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see . For questions and suggestions, see: http://ilk.uvt.nl/software.html or send mail to: timbl@uvt.nl */ #include #include #include #include #include #include "ticcutils/StringOps.h" #include "ticcutils/SocketBasics.h" using namespace std; int globalTimeOut; // // a simple program to demonstrate and test the Timbl Socket interface // const string lines[] = { "eerste regel", "tweede regel", "derde regel", "laatste regel", "" }; bool runClient( const string& sock, int id ){ cerr << "Starting Client " << id << " on localhost, port:" << sock << endl; Sockets::ClientSocket client; if ( client.connect( "localhost", sock) ){ string resultLine; if ( client.read( resultLine ) ){ cerr << "Client " << id << " read():\t\t\t\t" << resultLine << endl; int i = 0; string testLine = lines[i]; while ( !testLine.empty() ){ if ( client.write( testLine + "\n" ) ){ cerr << "Client " << id << " wrote():\t\t\t\t" << testLine << endl; if ( client.read( resultLine ) ){ if ( resultLine == "" ) continue; cerr << "Client " << id << " read() \t\t\t\t" << resultLine << endl; } else { cerr << "read failed: " + client.getMessage() << endl; return false; } } else { cerr << "write failed: " + client.getMessage() << endl; return false; } testLine = lines[++i]; } cerr << "all lines processed" << endl; } else { cerr << "connection failed: " + client.getMessage() << endl; return false; } } return true; } int randomSecs(){ long int r = random(); ldiv_t dif = ldiv( r, 5 ); return abs(dif.rem); } bool runToClient( const string& sock, int id ){ cerr << "Starting Client " << id << " on localhost, port:" << sock << endl; Sockets::ClientSocket client; if ( client.connect( "localhost", sock) ){ client.setNonBlocking(); string resultLine; int timeOut = globalTimeOut; int snorr = randomSecs(); cerr << "client " << id << " sleeps " << snorr << " seconds" << endl; sleep( snorr); if ( client.read( resultLine, timeOut ) ){ cerr << "Client " << id << " read():\t\t\t\t" << resultLine << endl; int i = 0; string testLine = lines[i]; while ( !testLine.empty() ){ snorr = randomSecs(); cerr << "client " << id << " sleeps " << snorr << " seconds" << endl; sleep( snorr); if ( client.write( testLine + "\n", timeOut ) ){ cerr << "Client " << id << " wrote():\t\t\t\t" << testLine << endl; snorr = randomSecs(); cerr << "client " << id << " sleeps " << snorr << " seconds" << endl; sleep( snorr); if ( client.read( resultLine, timeOut ) ){ if ( resultLine == "" ) continue; cerr << "Client " << id << " read() \t\t\t\t" << resultLine << endl; } else { cerr << "read failed: " + client.getMessage() << endl; return false; } } else { cerr << "write failed: " + client.getMessage() << endl; return false; } testLine = lines[++i]; } cerr << "all lines processed" << endl; } else { cerr << "connection failed: " + client.getMessage() << endl; return false; } } return true; } int main( int argc, const char *argv[] ){ string port = "1234"; string tos = "0"; if ( argc > 1 ) port = argv[1]; if ( argc > 2 ) tos = argv[2]; int timeOut; if ( !TiCC::stringTo( tos, timeOut ) ){ cerr << "invalid timeout" << endl; cerr << "usage: " << argv[0] << " " << endl; return 1; } else globalTimeOut = timeOut; int i; #pragma omp parallel for for ( i=0; i < 6; ++i ){ cerr << "creating client: " << i+1 << endl; if ( globalTimeOut > 0 ){ if ( !runToClient( port, i+1 ) ) cerr << "runClient failed" << endl; } else if ( !runClient( port, i+1 ) ) cerr << "runClient failed" << endl; cerr << "Client "<< i+1 << " Done" << endl; } cerr << "clientTest done" << endl; return 0; } LanguageMachines-timblserver-8229b48/demos/sockettestServer.cxx000066400000000000000000000124471452016554300247540ustar00rootroot00000000000000/* Copyright (c) 1998 - 2018 ILK - Tilburg University CNTS - University of Antwerp This file is part of timblserver timblserver is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. timblserver is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see . For questions and suggestions, see: http://ilk.uvt.nl/software.html or send mail to: timbl@uvt.nl */ #include #include #include #include #include #include #include #include "ticcutils/StringOps.h" #include "ticcutils/SocketBasics.h" using namespace std; // // a simple program to demonstrate and test the Timbl Socket interface // int globalTimeOut = 0; // evil void *do_child( void *arg ){ Sockets::Socket *mysock = static_cast(arg); // Greeting message for the client // // mysock->write( "Welcome to the Timbl socket tester.\n" ); // process the test material // char line[256]; sprintf( line, "Server: Thread %lu, on Socket %d", (uintptr_t)pthread_self(), mysock->getSockId() ); cerr << line << ", started" << endl; string buf; while( mysock->read( buf ) ){ cerr << "Server: read()" << buf << endl; string answer = string( "echo: " ) + buf + "\n"; mysock->write( answer ); cerr << "Server: wrote()" << answer << endl; } if ( !mysock->getMessage().empty() ) cerr << "Server result: " << mysock->getMessage() << endl; delete mysock; return NULL; } int randomSecs(){ long int r = random(); ldiv_t dif = ldiv( r, 5 ); return abs(dif.rem); } void *do_to_child( void *arg ){ Sockets::Socket *mysock = (Sockets::Socket*)arg; // Greeting message for the client // // int timeOut = globalTimeOut; int snorr = randomSecs(); cerr << "Server sleeps " << snorr << " seconds" << endl; sleep( snorr); mysock->write( "Welcome to the Timbl socket tester.\n", timeOut ); // process the test material // char line[256]; sprintf( line, "ToServer: Thread %lu, on Socket %d", (uintptr_t)pthread_self(), mysock->getSockId() ); cerr << line << ", started" << endl; string buf; while( mysock->read( buf, timeOut ) ){ cerr << "ToServer: read()" << buf << endl; string answer = string( "echo: " ) + buf + "\n"; snorr = randomSecs(); cerr << "Server sleeps " << snorr << " seconds" << endl; sleep( snorr); mysock->write( answer, timeOut ); cerr << "ToServer: wrote()" << answer << endl; } if ( !mysock->getMessage().empty() ) cerr << "Toserver result: " << mysock->getMessage() << endl; delete mysock; return NULL; } bool startServer( const string& portString ){ Sockets::ServerSocket server; pthread_attr_t attr; if ( pthread_attr_init(&attr) || pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED ) ){ cerr << "Threads: couldn't set attributes" << endl; return false; } if ( !server.connect( portString ) ){ cerr << "failed to start Server: " << server.getMessage() << endl; return false; } if ( !server.listen( 5 ) ) { // maximum of 5 pending requests cerr << server.getMessage() << endl; return false; } cerr << "Started Server on port:" << portString << endl; int failcount = 0; while( true ){ // waiting for connections loop signal( SIGPIPE, SIG_IGN ); Sockets::ClientSocket *newSocket = new Sockets::ClientSocket(); if ( !server.accept( *newSocket ) ){ cerr << server.getMessage() << endl; if ( ++failcount > 20 ){ cerr << "accept failcount >20 " << endl; cerr << "server stopped." << endl; return false; } else { continue; } } else { failcount = 0; cerr << "Server: Accepting Connection #" << newSocket->getSockId() << " from remote host: " << newSocket->getClientName() << endl; // create a new thread to process the incoming request // (The thread will terminate itself when done processing // and release its socket handle) // pthread_t chld_thr; if ( globalTimeOut > 0 ){ newSocket->setNonBlocking(); pthread_create( &chld_thr, &attr, do_to_child, static_cast(newSocket) ); } else { pthread_create( &chld_thr, &attr, do_child, static_cast(newSocket) ); } } // the server is now free to accept another socket request } pthread_attr_destroy(&attr); return true; } int main( int argc, const char *argv[] ){ string port = "1234"; string tos = "0"; if ( argc > 1 ) port = argv[1]; if ( argc > 2 ) tos = argv[2]; int timeOut; if ( !TiCC::stringTo( tos, timeOut ) ){ cerr << "invalid timeout" << endl; cerr << "usage: " << argv[0] << " " << endl; return 1; } else globalTimeOut = timeOut; if ( !startServer( port ) ){ cerr << "creating server failed" << endl; } cerr << "Server DONE" << endl; return 0; } LanguageMachines-timblserver-8229b48/docs/000077500000000000000000000000001452016554300204625ustar00rootroot00000000000000LanguageMachines-timblserver-8229b48/docs/Makefile.am000066400000000000000000000003201452016554300225110ustar00rootroot00000000000000# $Id: Makefile.am 3099 2009-10-21 13:54:31Z joostvb $ # $URL: https://ilk.uvt.nl/svn/trunk/sources/Timbl6/docs/Makefile.am $ man1_MANS= timblserver.1 timblclient.1 EXTRA_DIST = timblserver.1 timblclient.1 LanguageMachines-timblserver-8229b48/docs/timblclient.1000066400000000000000000000023511452016554300230530ustar00rootroot00000000000000.TH timblclient 1 "2014 december 2" .SH NAME timblclient \- a simple client to access the Tilburg Memory Based Learner Server . .SH SYNOPSIS . timblclient \-h host \-p port [\-i inputfile] [\-i outputfile] [\-\-batch] [\-b basename] .SH DESCRIPTION timblclient connects to a TimblServer on 'host':'port' and sends it the normal instructions. (see .B timblserver ) .SH OPTIONS The .B timblclient options are .TP .BR \-i " inputfile" .RS a series of timblserver commands. When BATCH is specified, inputfile is supposed to be a 'normal' .B Timbl testfile. Every line is send to the timblserver as a 'classify' command. Default is stdin. .RE .BR \-o " outputfile" .RS Where to put the results. Default is stdout. .RE .BR \-\-batch .RS When .B \-\-batch is specified, the input from 'inputfile' is not interpreted as timblserver commands, but as instances that will be send 'as is' prepended by a classify instruction. .RE .BR \-h " host" .RS connect to the server on 'host' .RE .BR \-p " port" .RS connect to 'port' on 'host' .RE .BR \-b " basename" .RS set the base in TimblServer to 'base' .RE .SH BUGS This is just a simple testprogram, and rather clumsy. .SH AUTHORS Ko van der Sloot timbl@uvt.nl .SH SEE ALSO .BR timbl (1) .BR timblserver (1) LanguageMachines-timblserver-8229b48/docs/timblserver.1000066400000000000000000000024021452016554300231000ustar00rootroot00000000000000.TH timblserver 1 "2014 december 2" .SH NAME timblserver \- Tilburg Memory Based Learner Server .SH SYNOPSIS timblserver [TiMBL options] [Server options] timblserver \-\-config=configfile [\-\-pidfile=pfile] [\-\-logfile=lfile] [\-\-daemonize=val] .SH DESCRIPTION timblserver extends .B timbl with a server layer. It provides the possibility to access one timbl instance from multiple sessions. It also allows running and accessing different timbl instances in parallel. .SH OPTIONS The .B server options are .TP .BR \-\-config =file .RS read server settings from file .RE .BR \-\-pidfile =file .RS store the pid of the main server process in 'file'. A full path must me given for 'file' otherwise the file will end up in '/'. .RE .BR \-\-logfile =file .RS log server actions to 'file'. A full path must me given for 'file' otherwise the file will end up in '/'. .RE .BR \-\-daemonize =[yes|no] .RS run the server as a daemon. Default is yes. .RE .B \-S .RS run the server on 'port' (deprecated) .RE .B \-C .RS set maximum number of parallel connections to 'num' (deprecated) .RE all .B timbl options are documented in .BR timbl (1) .SH BUGS possibly .SH AUTHORS Ko van der Sloot Timbl@uvt.nl Antal van den Bosch Timbl@uvt.nl .SH SEE ALSO .BR timbl (1) LanguageMachines-timblserver-8229b48/include/000077500000000000000000000000001452016554300211555ustar00rootroot00000000000000LanguageMachines-timblserver-8229b48/include/Makefile.am000066400000000000000000000001051452016554300232050ustar00rootroot00000000000000# $Id$ # $URL$ AUTOMAKE_OPTIONS = foreign SUBDIRS = timblserver LanguageMachines-timblserver-8229b48/include/timblserver/000077500000000000000000000000001452016554300235135ustar00rootroot00000000000000LanguageMachines-timblserver-8229b48/include/timblserver/ClientBase.h000066400000000000000000000043011452016554300256730ustar00rootroot00000000000000/* Copyright (c) 1998 - 2023 CLST - Radboud University ILK - Tilburg University CLiPS - University of Antwerp This file is part of timblserver timblserver is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. timblserver is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see . For questions and suggestions, see: https://github.com/LanguageMachines/timblserver/issues or send mail to: lamasoftware (at ) science.ru.nl */ #ifndef CLIENTBASE_H #define CLIENTBASE_H #include "timbl/TimblAPI.h" #include "ticcutils/LogStream.h" #include "ticcutils/SocketBasics.h" namespace TimblServer { class ClientClass : public Timbl::MsgClass { public: virtual ~ClientClass(); ClientClass(); bool connect( const std::string&, const std::string& ); const std::string& getBase( ) const { return _base; }; bool setBase( const std::string& ); const std::set baseNames() const { return bases;}; bool classify( const std::string& ); bool classifyFile( std::istream&, std::ostream& ); bool runScript( std::istream&, std::ostream& ); std::string getClass() const { return Class; }; std::string getDistance() const { return distance; }; std::string getDistribution() const { return distribution; }; const std::vector& getNeighbors() const { return neighbors; }; private: bool extractBases( const std::string& ); bool extractResult( const std::string& ); int serverPort; std::string serverName; Sockets::ClientSocket client; std::string _base; std::set bases; std::string Class; std::string distance; std::string distribution; std::vector neighbors; }; } #endif // CLIENTBASE_H LanguageMachines-timblserver-8229b48/include/timblserver/Makefile.am000066400000000000000000000001021452016554300255400ustar00rootroot00000000000000# $Id$ # $URL$ pkginclude_HEADERS = ClientBase.h TimblServer.h LanguageMachines-timblserver-8229b48/include/timblserver/TimblServer.h000066400000000000000000000051401452016554300261220ustar00rootroot00000000000000/* Copyright (c) 1998 - 2023 CLST - Radboud University ILK - Tilburg University CLiPS - University of Antwerp This file is part of timblserver timblserver is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. timblserver is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see . For questions and suggestions, see: https://github.com/LanguageMachines/timblserver/issues or send mail to: lamasoftware (at ) science.ru.nl */ #ifndef TIMBLSERVER_H #define TIMBLSERVER_H #include "timbl/TimblAPI.h" #include "ticcutils/LogStream.h" #include "ticcutils/SocketBasics.h" #include "ticcutils/json.hpp" namespace TimblServer { class TimblThread { public: TimblThread( Timbl::TimblExperiment *, TiCCServer::childArgs *, bool = false ); ~TimblThread(){ delete _exp; }; bool setOptions( const std::string& param ); Timbl::TimblExperiment *_exp; TiCC::LogStream& myLog; bool doDebug; std::ostream& os; std::istream& is; }; class TcpServer : public TiCCServer::TcpServerBase { public: void callback( TiCCServer::childArgs* ); explicit TcpServer( const TiCC::Configuration *c ): TcpServerBase( c, &experiments ){}; bool classifyLine( TimblThread *, const std::string& ) const; private: std::map experiments; }; class HttpServer : public TiCCServer::HttpServerBase { public: void callback( TiCCServer::childArgs* ); explicit HttpServer( const TiCC::Configuration *c ): HttpServerBase( c, &experiments ){}; private: std::map experiments; }; class JsonServer : public TiCCServer::TcpServerBase { public: void callback( TiCCServer::childArgs* ); explicit JsonServer( const TiCC::Configuration *c ): TcpServerBase( c, &experiments ){}; bool read_json( std::istream&, nlohmann::json& ); nlohmann::json classify_to_json( TimblThread *, const std::vector& ) const; private: std::map experiments; }; std::string Version(); std::string VersionName(); } #endif // TIMBLSERVER_H LanguageMachines-timblserver-8229b48/m4/000077500000000000000000000000001452016554300200525ustar00rootroot00000000000000LanguageMachines-timblserver-8229b48/m4/Makefile.am000066400000000000000000000000641452016554300221060ustar00rootroot00000000000000# $Id: $ # $URL: $ extra_DIST = ax_openmp.m4 pkg.m4LanguageMachines-timblserver-8229b48/m4/ac_define_dir.m4000066400000000000000000000030701452016554300230470ustar00rootroot00000000000000# =========================================================================== # http://autoconf-archive.cryp.to/ac_define_dir.html # =========================================================================== # # SYNOPSIS # # AC_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION]) # # DESCRIPTION # # This macro sets VARNAME to the expansion of the DIR variable, taking # care of fixing up ${prefix} and such. # # VARNAME is then offered as both an output variable and a C preprocessor # symbol. # # Example: # # AC_DEFINE_DIR([DATADIR], [datadir], [Where data are placed to.]) # # LICENSE # # Copyright (c) 2008 Stepan Kasal # Copyright (c) 2008 Andreas Schwab # Copyright (c) 2008 Guido U. Draheim # Copyright (c) 2008 Alexandre Oliva # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. AC_DEFUN([AC_DEFINE_DIR], [ prefix_NONE= exec_prefix_NONE= test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn dnl refers to ${prefix}. Thus we have to use `eval' twice. eval ac_define_dir="\"[$]$2\"" eval ac_define_dir="\"$ac_define_dir\"" AC_SUBST($1, "$ac_define_dir") AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3]) test "$prefix_NONE" && prefix=NONE test "$exec_prefix_NONE" && exec_prefix=NONE ]) LanguageMachines-timblserver-8229b48/m4/ac_osx_pkg.m4000066400000000000000000000040401452016554300224270ustar00rootroot00000000000000# osx_pkg.m4 - Macros to add OSX brew locations to pkg-config. -*- Autoconf -*- # serial 1 # # Copyright © 2018 Ko van der Sloot # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # AC_OSX_PKG_ALL() # add all /opt/{package} directories to the PKG_CONFIG search path # ---------------------------------- AC_DEFUN([AC_OSX_PKG_ALL], [ case ${host_os} in linux*) # linux is wellbehaved ;; darwin*) # darwin isn't for i in `ls /usr/local/opt/` do if test -d "/usr/local/opt/$i/lib/pkgconfig" then export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/$i/lib/pkgconfig" fi done ;; esac ]) # AC_OSX_PKG_ALL([LIST_OF_PACKAGES]) # fore every packake in LIST_OF_PACKAGES, add the /opt/{package} directory # to the PKG_CONFIG search path # ---------------------------------- AC_DEFUN([AC_OSX_PKG], [ case ${host_os} in linux*) # linux is wellbehaved ;; darwin*) # darwin isn't for i in $* do if test -d "/usr/local/opt/$i/lib/pkgconfig" then export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/$i/lib/pkgconfig" fi done ;; esac ]) LanguageMachines-timblserver-8229b48/m4/ltsugar.m4000066400000000000000000000104241452016554300217760ustar00rootroot00000000000000# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 6 ltsugar.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) # lt_join(SEP, ARG1, [ARG2...]) # ----------------------------- # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their # associated separator. # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier # versions in m4sugar had bugs. m4_define([lt_join], [m4_if([$#], [1], [], [$#], [2], [[$2]], [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) m4_define([_lt_join], [m4_if([$#$2], [2], [], [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) # lt_car(LIST) # lt_cdr(LIST) # ------------ # Manipulate m4 lists. # These macros are necessary as long as will still need to support # Autoconf-2.59 which quotes differently. m4_define([lt_car], [[$1]]) m4_define([lt_cdr], [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], [$#], 1, [], [m4_dquote(m4_shift($@))])]) m4_define([lt_unquote], $1) # lt_append(MACRO-NAME, STRING, [SEPARATOR]) # ------------------------------------------ # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. # Note that neither SEPARATOR nor STRING are expanded; they are appended # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). # No SEPARATOR is output if MACRO-NAME was previously undefined (different # than defined and empty). # # This macro is needed until we can rely on Autoconf 2.62, since earlier # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. m4_define([lt_append], [m4_define([$1], m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) # ---------------------------------------------------------- # Produce a SEP delimited list of all paired combinations of elements of # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list # has the form PREFIXmINFIXSUFFIXn. # Needed until we can rely on m4_combine added in Autoconf 2.62. m4_define([lt_combine], [m4_if(m4_eval([$# > 3]), [1], [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl [[m4_foreach([_Lt_prefix], [$2], [m4_foreach([_Lt_suffix], ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) # ----------------------------------------------------------------------- # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. m4_define([lt_if_append_uniq], [m4_ifdef([$1], [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], [lt_append([$1], [$2], [$3])$4], [$5])], [lt_append([$1], [$2], [$3])$4])]) # lt_dict_add(DICT, KEY, VALUE) # ----------------------------- m4_define([lt_dict_add], [m4_define([$1($2)], [$3])]) # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) # -------------------------------------------- m4_define([lt_dict_add_subkey], [m4_define([$1($2:$3)], [$4])]) # lt_dict_fetch(DICT, KEY, [SUBKEY]) # ---------------------------------- m4_define([lt_dict_fetch], [m4_ifval([$3], m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) # ----------------------------------------------------------------- m4_define([lt_if_dict_fetch], [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], [$5], [$6])]) # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) # -------------------------------------------------------------- m4_define([lt_dict_filter], [m4_if([$5], [], [], [lt_join(m4_quote(m4_default([$4], [[, ]])), lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl ]) LanguageMachines-timblserver-8229b48/m4/pkg.m4000066400000000000000000000240071452016554300211000ustar00rootroot00000000000000# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- # serial 12 (pkg-config-0.29.2) dnl Copyright © 2004 Scott James Remnant . dnl Copyright © 2012-2015 Dan Nicholson dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU dnl General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA dnl 02111-1307, USA. dnl dnl As a special exception to the GNU General Public License, if you dnl distribute this file as part of a program that contains a dnl configuration script generated by Autoconf, you may include it under dnl the same distribution terms that you use for the rest of that dnl program. dnl PKG_PREREQ(MIN-VERSION) dnl ----------------------- dnl Since: 0.29 dnl dnl Verify that the version of the pkg-config macros are at least dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's dnl installed version of pkg-config, this checks the developer's version dnl of pkg.m4 when generating configure. dnl dnl To ensure that this macro is defined, also add: dnl m4_ifndef([PKG_PREREQ], dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])]) dnl dnl See the "Since" comment for each macro you use to see what version dnl of the macros you require. m4_defun([PKG_PREREQ], [m4_define([PKG_MACROS_VERSION], [0.29.2]) m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) ])dnl PKG_PREREQ dnl PKG_PROG_PKG_CONFIG([MIN-VERSION]) dnl ---------------------------------- dnl Since: 0.16 dnl dnl Search for the pkg-config tool and set the PKG_CONFIG variable to dnl first found in the path. Checks that the version of pkg-config found dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is dnl used since that's the first version where most current features of dnl pkg-config existed. AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then _pkg_min_version=m4_default([$1], [0.9.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) PKG_CONFIG="" fi fi[]dnl ])dnl PKG_PROG_PKG_CONFIG dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) dnl ------------------------------------------------------------------- dnl Since: 0.18 dnl dnl Check to see whether a particular set of modules exists. Similar to dnl PKG_CHECK_MODULES(), but does not set variables or print errors. dnl dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) dnl only at the first occurence in configure.ac, so if the first place dnl it's called might be skipped (such as if it is within an "if", you dnl have to call PKG_CHECK_EXISTS manually AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) dnl --------------------------------------------- dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting dnl pkg_failed based on the result. m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes ], [pkg_failed=yes]) else pkg_failed=untried fi[]dnl ])dnl _PKG_CONFIG dnl _PKG_SHORT_ERRORS_SUPPORTED dnl --------------------------- dnl Internal check to see if pkg-config supports short errors. AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi[]dnl ])dnl _PKG_SHORT_ERRORS_SUPPORTED dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], dnl [ACTION-IF-NOT-FOUND]) dnl -------------------------------------------------------------- dnl Since: 0.4.0 dnl dnl Note that if there is a possibility the first call to dnl PKG_CHECK_MODULES might not happen, you should be sure to include an dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no AC_MSG_CHECKING([for $2]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD m4_default([$4], [AC_MSG_ERROR( [Package requirements ($2) were not met: $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. _PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT To get pkg-config, see .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) $3 fi[]dnl ])dnl PKG_CHECK_MODULES dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], dnl [ACTION-IF-NOT-FOUND]) dnl --------------------------------------------------------------------- dnl Since: 0.29 dnl dnl Checks for existence of MODULES and gathers its build flags with dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags dnl and VARIABLE-PREFIX_LIBS from --libs. dnl dnl Note that if there is a possibility the first call to dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to dnl include an explicit call to PKG_PROG_PKG_CONFIG in your dnl configure.ac. AC_DEFUN([PKG_CHECK_MODULES_STATIC], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl _save_PKG_CONFIG=$PKG_CONFIG PKG_CONFIG="$PKG_CONFIG --static" PKG_CHECK_MODULES($@) PKG_CONFIG=$_save_PKG_CONFIG[]dnl ])dnl PKG_CHECK_MODULES_STATIC dnl PKG_INSTALLDIR([DIRECTORY]) dnl ------------------------- dnl Since: 0.27 dnl dnl Substitutes the variable pkgconfigdir as the location where a module dnl should install pkg-config .pc files. By default the directory is dnl $libdir/pkgconfig, but the default can be changed by passing dnl DIRECTORY. The user can override through the --with-pkgconfigdir dnl parameter. AC_DEFUN([PKG_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([pkgconfigdir], [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, [with_pkgconfigdir=]pkg_default) AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ])dnl PKG_INSTALLDIR dnl PKG_NOARCH_INSTALLDIR([DIRECTORY]) dnl -------------------------------- dnl Since: 0.27 dnl dnl Substitutes the variable noarch_pkgconfigdir as the location where a dnl module should install arch-independent pkg-config .pc files. By dnl default the directory is $datadir/pkgconfig, but the default can be dnl changed by passing DIRECTORY. The user can override through the dnl --with-noarch-pkgconfigdir parameter. AC_DEFUN([PKG_NOARCH_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([noarch-pkgconfigdir], [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, [with_noarch_pkgconfigdir=]pkg_default) AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ])dnl PKG_NOARCH_INSTALLDIR dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) dnl ------------------------------------------- dnl Since: 0.28 dnl dnl Retrieves the value of the pkg-config variable for the given module. AC_DEFUN([PKG_CHECK_VAR], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl _PKG_CONFIG([$1], [variable="][$3]["], [$2]) AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl ])dnl PKG_CHECK_VAR LanguageMachines-timblserver-8229b48/src/000077500000000000000000000000001452016554300203215ustar00rootroot00000000000000LanguageMachines-timblserver-8229b48/src/ClientBase.cxx000066400000000000000000000213631452016554300230630ustar00rootroot00000000000000/* Copyright (c) 1998 - 2023 CLST - Radboud University ILK - Tilburg University CLiPS - University of Antwerp This file is part of timblserver timblserver is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. timblserver is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see . For questions and suggestions, see: https://github.com/LanguageMachines/timblserver/issues or send mail to: lamasoftware (at ) science.ru.nl */ #include #include #include #include #include "ticcutils/StringOps.h" #include "timblserver/ClientBase.h" using namespace std; namespace TimblServer { const string TimblEntree = "Welcome to the Timbl server."; enum code_t { UnknownCode, Result, Err, OK, Echo, Skip, Neighbors, EndNeighbors, Status, EndStatus }; ClientClass::ClientClass() { serverPort = -1; } ClientClass::~ClientClass(){ } bool ClientClass::extractBases( const string& line ){ static const string WHAT = "available bases:"; string::size_type pos = line.find( WHAT ); if ( pos == 0 ){ string value = line.substr( WHAT.size() ); // cerr << "step 1 '" << value << "'" << endl; vector names = TiCC::split( value ); for ( const auto& base : names ){ // cerr << "step 2 i= " << i << " '" << base << "'" << endl; bases.insert( base ); } return true; } cerr << "unable to extract basenames from: '" << line << "'" << endl; return false; } bool ClientClass::connect( const string& node, const string& port ){ cout << "Starting Client on node:" << node << ", port:" << port << endl; if ( client.connect( node, port) ){ serverPort = TiCC::stringTo( port ); serverName = node; string line; if ( client.read( line ) ){ // cout << "read line " << line << endl; if ( line == TimblEntree ){ client.setNonBlocking(); if ( client.read( line, 1 ) ){ // see if the server spits out information about available bases // assume that these will come within a second // cout << "next line = " << line << endl; client.setBlocking(); if ( extractBases( line ) ) return true; } else { client.setBlocking(); return true; } } } else { cerr << client.getMessage() << endl; } } else { cerr << client.getMessage() << endl; } return false; } bool ClientClass::setBase( const string& base ){ // cout << "Setting base to :" << base << endl; if ( bases.find( base ) == bases.end() ){ cerr << "'" << base << "' is not a valid base." << endl; return false; } if ( client.isValid() ) { if ( client.write( "base " + base + "\n" ) ){ string line; if ( client.read( line ) ){ if ( line.find("selected base") != string::npos && line.find( base ) != string::npos ){ _base = base; return true; } else { cerr << "unexpected line = " << line << endl; } } } } return false; } code_t toCode( const string& command ){ string com = TiCC::uppercase( command ); code_t result = UnknownCode; if ( com == "CATEGORY" ) result = Result; else if ( com == "ERROR" ) result = Err; else if ( com == "OK" ) result = OK; else if ( com == "AVAILABLE" ) result = Echo; else if ( com == "SELECTED" ) result = Echo; else if ( com == "SKIP" ) result = Skip; else if ( com == "NEIGHBORS" ) result = Neighbors; else if ( com == "ENDNEIGHBORS" ) result = EndNeighbors; else if ( com == "STATUS" ) result = Status; else if ( com == "ENDSTATUS" ) result = EndStatus; return result; } code_t extract_code( const string& line, string& rest ){ string code; rest.clear(); vector parts = TiCC::split( line, 2 ); if ( !parts.empty() ){ code = parts[0]; if ( parts.size() == 2 ){ rest = parts[1]; } } return toCode( code ); } bool ClientClass::extractResult( const string& line ){ string cls; string dist; string db; string::size_type pos1 = line.find( "{" ); if ( pos1 != string::npos ) { string::size_type pos2 = line.find( "}", pos1 ); if ( pos2 != string::npos ){ cls = line.substr( pos1+1, pos2 - pos1 -1 ); pos1 = line.find( "DISTRIBUTION" ); if ( pos1 != string::npos ) { pos1 = line.find( "{", pos1 + 13 ); if ( pos1 != string::npos ) { pos2 = line.find( "}", pos1 ); if ( pos2 != string::npos ){ db = line.substr( pos1, pos2 - pos1 + 1 ); } else return false; } else return false; } pos1 = line.find( "DISTANCE" ); if ( pos1 != string::npos ) { pos1 = line.find( "{", pos1 + 9 ); if ( pos1 != string::npos ) { pos2 = line.find( "}", pos1 ); if ( pos2 != string::npos ){ dist = line.substr( pos1+1, pos2 - pos1-1 ); } else return false; } else return false; } pos1 = line.find( "NEIGHBORS" ); if ( pos1 != string::npos ) { string answer; while ( client.read( answer ) ){ string rest; code_t code = extract_code( answer, rest ); if ( code != EndNeighbors ){ neighbors.push_back( answer ); } else break; } } Class = cls; distribution = db; distance = dist; return true; } } return false; } bool ClientClass::classify( const string& line ){ Class.clear(); distribution.clear(); distance.clear(); neighbors.clear(); if ( client.isValid() ) { string request; request = "classify " + line + "\n"; if ( client.write( request ) ){ string response; while ( client.read( response ) ){ // cerr << "result line " << response << endl; if ( response.empty() ) continue; string rest; code_t code = extract_code( response, rest ); switch( code ){ case Result: return extractResult( rest ); break; default: cerr << "unexpected response '" << response << "'" << endl; return false; } } } } return false; } bool ClientClass::classifyFile( istream& is, ostream& os ){ if ( client.isValid() ) { string line; while( getline( is, line) ){ // cerr << "Test line " << line << endl; if ( classify( line ) ){ os << line << " --> CATEGORY {" << Class << "}"; if ( !distribution.empty() ) os << " DISTRIBUTION " << distribution; if ( !distance.empty() ) os << " DISTANCE {" << distance << "}"; if ( neighbors.size() > 0 ){ os << " NEIGHBORS " << endl; for ( const auto& n : neighbors ){ os << n << endl; } os << "ENDNEIGHBORS "; } os << endl; } else { os << line << " ==> ERROR" << endl; } } return true; } else { return false; } } bool ClientClass::runScript( istream& is, ostream& os ){ if ( client.isValid() ) { string request; while( getline( is, request ) ){ // cerr << "script line " << request << endl; if ( client.write( request + "\n" ) ){ string response; bool more = true; while ( more && client.read( response ) ){ // cerr << "response line " << response << endl; if ( response.empty() ){ continue; } more = false; string rest; code_t code = extract_code( response, rest ); switch ( code ) { case OK: os << "OK" << endl; break; case Echo: os << response << endl; break; case Skip: os << "Skipped " << rest << endl; break; case Err: os << response << endl; break; case Result: { bool also_neighbors = (response.find( "NEIGHBORS" ) != string::npos ); os << response << endl; if ( also_neighbors ) while ( client.read( response ) ){ code = extract_code( response, rest ); os << response << endl; if ( code == EndNeighbors ) break; } break; } case Status: os << response << endl; while ( client.read( response ) ){ code = extract_code( response, rest ); os << response << endl; if ( code == EndStatus ) break; } break; default: os << "Client is confused?? " << response << endl; os << "Code was '" << code << "'" << endl; break; } } } else return false; } return true; } else return false; } } LanguageMachines-timblserver-8229b48/src/HttpServer.cxx000066400000000000000000000172151452016554300231610ustar00rootroot00000000000000/* Copyright (c) 1998 - 2023 CLST - Radboud University ILK - Tilburg University CLiPS - University of Antwerp This file is part of timblserver timblserver is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. timblserver is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see . For questions and suggestions, see: https://github.com/LanguageMachines/timblserver/issues or send mail to: lamasoftware (at ) science.ru.nl */ #include #include #include #include #include "ticcutils/CommandLine.h" #include "ticcutils/PrettyPrint.h" #include "ticcutils/ServerBase.h" #include "timbl/TimblAPI.h" #include "timblserver/TimblServer.h" using namespace std; using namespace Timbl; using namespace TimblServer; using namespace TiCCServer; using TiCC::operator<<; #define LOG *TiCC::Log(logstream()) #define DBG *TiCC::Dbg(logstream()) #define IS_DIGIT(x) (((x) >= '0') && ((x) <= '9')) #define IS_HEX(x) ((IS_DIGIT(x)) || (((x) >= 'a') && ((x) <= 'f')) || \ (((x) >= 'A') && ((x) <= 'F'))) string urlDecode( const string& s ) { string result; size_t len=s.size(); for ( size_t i=0; i> std::showbase >> std::hex; ss >> tmp; result = result + (char)tmp; i += 2; } else { result += cc; } } return result; } void HttpServer::callback( childArgs *args ){ // process the test material // report connection to the server terminal // args->socket()->setNonBlocking(); map experiments = *(static_cast *>(callback_data())); string logLine = "Thread " + to_string( (uintptr_t)pthread_self() ) + " on Socket " + to_string( args->id() ); LOG << logLine << " started." << endl; string Line; int timeout = 1; if ( nb_getline( args->is(), Line, timeout ) ){ DBG << "HttpServer::FirstLine='" << Line << "'" << endl; if ( Line.find( "HTTP" ) != string::npos ){ // skip HTTP header string tmp; timeout = 1; while ( ( nb_getline( args->is(), tmp, timeout ), !tmp.empty()) ){ // cerr << "skip: read:'" << tmp << "'" << endl;; } string::size_type spos = Line.find( "GET" ); if ( spos != string::npos ){ string::size_type epos = Line.find( " HTTP" ); string line = Line.substr( spos+3, epos - spos - 3 ); DBG << "HttpServer::Line='" << line << "'" << endl; epos = line.find( "?" ); string basename; if ( epos != string::npos ){ basename = line.substr( 0, epos ); string qstring = line.substr( epos+1 ); epos = basename.find( "/" ); if ( epos != string::npos ){ basename = basename.substr( epos+1 ); auto exp_it = experiments.find(basename); if ( exp_it != experiments.end() ){ TimblThread *client = new TimblThread( exp_it->second, args ); if ( client ){ TiCC::LogStream LS( &logstream() ); TiCC::LogStream DS( &logstream() ); DS.message(logLine); LS.message(logLine); DS.setstamp( StampBoth ); LS.setstamp( StampBoth ); TiCC::XmlDoc doc( "TiMblResult" ); xmlNode *root = doc.getRoot(); TiCC::XmlSetAttribute( root, "algorithm", TiCC::toString(client->_exp->Algorithm()) ); vector avs = TiCC::split_at( qstring, "&" ); if ( !avs.empty() ){ multimap acts; for ( const auto& av : avs ){ vector parts = TiCC::split_at( av, "=", 2 ); if ( parts.size() == 2 ){ acts.insert( make_pair(parts[0], parts[1]) ); } else { LS << "unknown word in query " << av << endl; } } typedef multimap::const_iterator mmit; pair range = acts.equal_range( "set" ); mmit it = range.first; while ( it != range.second ){ string opt = it->second; if ( !opt.empty() && opt[0] != '-' && opt[0] != '+' ){ opt = string("-") + opt; } if ( doDebug() ){ DS << "set :" << opt << endl; } if ( !client->setOptions( opt ) ){ LS << ": Don't understand set='" << opt << "'" << endl; args->os() << ": Don't understand set='" << it->second << "'" << endl; } ++it; } range = acts.equal_range( "show" ); it = range.first; while ( it != range.second ){ if ( it->second == "settings" ){ xmlNode *node = client->_exp->settingsToXML(); xmlAddChild( root, node ); } else if ( it->second == "weights" ){ xmlNode *node = client->_exp->weightsToXML(); xmlAddChild( root, node ); } else LS << "don't know how to SHOW: " << it->second << endl; ++it; } range = acts.equal_range( "classify" ); it = range.first; while ( it != range.second ){ string params = it->second; params = urlDecode(params); int len = params.length(); if ( len > 2 ){ DS << "params=" << params << endl << "params[0]='" << params[0] << "'" << endl << "params[len-1]='" << params[len-1] << "'" << endl; if ( ( params[0] == '"' && params[len-1] == '"' ) || ( params[0] == '\'' && params[len-1] == '\'' ) ){ params = params.substr( 1, len-2 ); } } DS << "base='" << basename << "'" << endl << "command='classify'" << endl; string distrib, answer; double distance; if ( doDebug() ){ LS << "Classify(" << params << ")" << endl; } if ( client->_exp->Classify( params, answer, distrib, distance ) ){ if ( doDebug() ){ LS << "resultaat: " << answer << ", distrib: " << distrib << ", distance " << distance << endl; } xmlNode *cl = TiCC::XmlNewChild( root, "classification" ); TiCC::XmlNewTextChild( cl, "input", params ); TiCC::XmlNewTextChild( cl, "category", answer ); if ( client->_exp->Verbosity(DISTRIB) ){ TiCC::XmlNewTextChild( cl, "distribution", distrib ); } if ( client->_exp->Verbosity(DISTANCE) ){ TiCC::XmlNewTextChild( cl, "distance", TiCC::toString(distance) ); } if ( client->_exp->Verbosity(CONFIDENCE) ){ TiCC::XmlNewTextChild( cl, "confidence", TiCC::toString( client->_exp->confidence() ) ); } if ( client->_exp->Verbosity(MATCH_DEPTH) ){ TiCC::XmlNewTextChild( cl, "match_depth", TiCC::toString( client->_exp->matchDepth()) ); } if ( client->_exp->Verbosity(NEAR_N) ){ xmlNode *nb = client->_exp->bestNeighborsToXML(); xmlAddChild( cl, nb ); } } else { DS << "classification failed" << endl; } ++it; } } string out_line = doc.toString(); timeout=10; nb_putline( args->os(), out_line , timeout ); delete client; } } else { DBG << "HttpServer::invalid BASE! '" << basename << "'" << endl; args->os() << "invalid basename: '" << basename << "'" << endl; } args->os() << endl; } } } } } } LanguageMachines-timblserver-8229b48/src/JsonServer.cxx000066400000000000000000000201501452016554300231430ustar00rootroot00000000000000/* Copyright (c) 1998 - 2023 CLST - Radboud University ILK - Tilburg University CLiPS - University of Antwerp This file is part of timblserver timblserver is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. timblserver is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see . For questions and suggestions, see: https://github.com/LanguageMachines/timblserver/issues or send mail to: lamasoftware (at ) science.ru.nl */ #include #include #include #include #include "ticcutils/CommandLine.h" #include "ticcutils/PrettyPrint.h" #include "timbl/TimblAPI.h" #include "ticcutils/json.hpp" #include "ticcutils/ServerBase.h" #include "timblserver/TimblServer.h" using namespace std; using namespace Timbl; using namespace TimblServer; using namespace TiCCServer; using namespace nlohmann; using TiCC::operator<<; #define LOG *TiCC::Log(logstream()) #define DBG *TiCC::Dbg(logstream()) #define SDBG *TiCC::Dbg(client->myLog) json json_error( const string& message ){ json result; result["status"] = "error"; result["message"] = message; return result; } json JsonServer::classify_to_json( TimblThread *client, const vector& params ) const { SDBG << "classify_to_json(" << params << ")" << endl; TimblExperiment *_exp = client->_exp; json result; if ( params.size() > 1 ){ result = _exp->classify_to_JSON( params ); } else { result = _exp->classify_to_JSON( params[0] ); } SDBG << "created json: " << result.dump(2) << endl; return result; } bool JsonServer::read_json( istream& is, json& the_json ){ the_json.clear(); string json_line; if ( getline( is, json_line ) ){ try { the_json = json::parse( json_line ); } catch ( const exception& e ){ cerr << "json parsing failed on '" << json_line + "':" << e.what() << endl; } DBG << "Read JSON: " << the_json << endl; return true; } return false; } void JsonServer::callback( childArgs *args ){ JsonServer *theServer = dynamic_cast( args->mother() ); int sockId = args->id(); TimblThread *client = 0; map experiments = *(static_cast *>(callback_data())); int result = 0; json out_json; out_json["status"] = "ok"; if ( experiments.size() == 1 && experiments.find("default") != experiments.end() ){ DBG << "Before Create Default Client " << endl; TimblExperiment *exp = experiments["default"]; client = new TimblThread( exp, args, true ); DBG << "After Create Client " << endl; // report connection to the server terminal // } else { json arr = json::array(); for ( const auto& it : experiments ){ arr.push_back( it.first ); } out_json["available_bases"] = arr; } DBG << "send JSON: " << out_json.dump(2) << endl; args->os() << out_json << endl; json in_json; bool go_on = true; while ( go_on && theServer->read_json( args->is(), in_json ) ){ if ( in_json.empty() ){ continue; } DBG << "handling JSON: " << in_json.dump(2) << endl; DBG << "running FromSocket: " << sockId << endl; string command; string param; if ( in_json.find("command") != in_json.end() ){ command = in_json["command"]; } if ( command.empty() ){ DBG << sockId << " Don't understand '" << in_json << "'" << endl; json err_json = json_error( "Illegal instruction:'" + in_json.dump() + "'" ); args->os() << err_json << endl; } else { vector params; if ( in_json.find("param") != in_json.end() ){ param = in_json["param"]; } else if ( in_json.find("params") != in_json.end() ){ json pars = in_json["params"]; if ( pars.is_array() ){ for ( auto const& par : pars ){ params.push_back( par.get() ); } } } DBG << sockId << " Command='" << command << "'" << endl; if ( param.empty() ){ DBG << sockId << " Params='" << params << "'" << endl; } else { DBG << sockId << " Param='" << param << "'" << endl; } if ( command == "base" ){ if ( param.empty() ){ json err_json = json_error( "missing 'param' for base command " ); args->os() << err_json << endl; } else { auto it = experiments.find(param); if ( it != experiments.end() ){ // args->os() << "selected base: '" << Params << "'" << endl; if ( client ){ delete client; } DBG << sockId << " before Create Default Client " << endl; client = new TimblThread( it->second, args, true ); DBG << sockId << " after Create Client " << endl; // report connection to the server terminal // DBG << sockId << " Thread " << (uintptr_t)pthread_self() << " on Socket " << sockId << " started." << endl; out_json.clear(); out_json["base"] = param; args->os() << out_json << endl; } else { json err_json = json_error( "Unknown basename: '" + param + "'" ); args->os() << err_json << endl; } } } else if ( command == "set" ){ if ( !client ){ json err_json = json_error( "'set' failed: you haven't selected a base yet!" ); args->os() << err_json << endl; } else { if ( param.empty() ){ json err_json = json_error( "missing 'param' for set command " ); args->os() << err_json << endl; } else { out_json.clear(); if ( client->setOptions( param ) ){ DBG << sockId << " setOptions: " << param << endl; out_json["status"] = "ok"; args->os() << out_json << endl; } else { DBG << sockId<< " Don't understand set(" << param << ")" << endl; json err_json = json_error("set( " + param + ") failed" ); args->os() << err_json << endl; } } } } else if ( command == "query" || command == "show" ){ if ( !client ){ json err_json = json_error( "'show' failed: no base selected" ); args->os() << err_json << endl; } else if ( param.empty() ){ json err_json = json_error( "missing 'param' for " + command + " command " ); args->os() << err_json << endl; } else { out_json.clear(); if ( param == "settings" ){ out_json = client->_exp->settings_to_JSON(); } else if ( param == "weights" ){ out_json = client->_exp->weights_to_JSON(); } else { out_json = json_error( "'show' failed, unknown parameter: " + param ); } args->os() << out_json << endl; } } else if ( command == "exit" ){ out_json.clear(); out_json["status"] = "closed"; args->os() << out_json << endl; go_on = false; } else if ( command == "classify" ){ if ( !client ){ json err_json = json_error( "'classify' failed: you haven't selected a base yet!" ); args->os() << err_json << endl; } else { if ( params.empty() ){ if ( param.empty() ){ json err_json = json_error( "missing 'param' or 'params' for 'classify'" ); args->os() << err_json << endl; } else { params.push_back( param ); } } else if ( !param.empty() ){ json err_json = json_error( "both 'param' and 'params' found" ); args->os() << err_json << endl; } if ( !params.empty() ){ out_json = classify_to_json( client, params ); DBG << "JsonServer::sending JSON:" << endl << out_json << endl; args->os() << out_json << endl; if ( out_json.find("error") == out_json.end() ){ result += out_json.size(); } } } } else { json err_json = json_error( "Unknown command: '" + command + "'" ); args->os() << err_json << endl; } } } delete client; LOG << sockId << " Thread " << (uintptr_t)pthread_self() << " terminated, " << result << " instances processed " << endl; } LanguageMachines-timblserver-8229b48/src/Makefile.am000066400000000000000000000006351452016554300223610ustar00rootroot00000000000000AM_CPPFLAGS = -I@top_srcdir@/include AM_CXXFLAGS = -std=c++14 -W -Wall -O3 -g LDADD = libtimblserver.la bin_PROGRAMS = timblclient timblserver timblclient_SOURCES = TimblClient.cxx timblserver_SOURCES = TimblServer.cxx lib_LTLIBRARIES = libtimblserver.la libtimblserver_la_LDFLAGS= -version-info 5:0:0 libtimblserver_la_SOURCES = ClientBase.cxx TimblThread.cxx TcpServer.cxx \ HttpServer.cxx JsonServer.cxx LanguageMachines-timblserver-8229b48/src/TcpServer.cxx000066400000000000000000000152611452016554300227670ustar00rootroot00000000000000/* Copyright (c) 1998 - 2023 CLST - Radboud University ILK - Tilburg University CLiPS - University of Antwerp This file is part of timblserver timblserver is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. timblserver is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see . For questions and suggestions, see: https://github.com/LanguageMachines/timblserver/issues or send mail to: lamasoftware (at ) science.ru.nl */ #include #include #include #include #include "ticcutils/CommandLine.h" #include "ticcutils/PrettyPrint.h" #include "timbl/TimblAPI.h" #include "ticcutils/ServerBase.h" #include "timblserver/TimblServer.h" using namespace std; using namespace Timbl; using namespace TiCCServer; using namespace TimblServer; using TiCC::operator<<; #define LOG *TiCC::Log(logstream()) #define DBG *TiCC::Dbg(logstream()) #define SDBG *TiCC::Dbg(client->myLog) enum CommandType { UnknownCommand, Classify, Base, Query, Set, Exit, Comment }; CommandType check_command( const string& com ){ CommandType result = UnknownCommand; if ( compare_nocase_n( com, "CLASSIFY" ) ) result = Classify; else if ( compare_nocase_n( com, "QUERY" ) ) result = Query; else if ( compare_nocase_n( com, "BASE") ) result = Base; else if ( compare_nocase_n( com, "SET") ) result = Set; else if ( compare_nocase_n( com, "EXIT" ) ) result = Exit; else if ( com[0] == '#' ) result = Comment; return result; } inline void Split( const string& line, string& com, string& rest ){ vector parts = TiCC::split( line, 2 ); if ( parts.size() == 2 ){ com = parts[0]; rest = parts[1]; } else { com = parts[0]; rest = ""; } } bool TcpServer::classifyLine( TimblThread *client, const string& params ) const { double Distance; string Distrib; string Answer; TimblExperiment *_exp = client->_exp; ostream *os = &client->os; if ( _exp->Classify( params, Answer, Distrib, Distance ) ){ SDBG << _exp->ExpName() << ":" << params << " --> " << Answer << " " << Distrib << " " << Distance << endl; *os << "CATEGORY {" << Answer << "}"; if ( os->good() ){ if ( _exp->Verbosity(DISTRIB) ){ *os << " DISTRIBUTION " <good() ){ if ( _exp->Verbosity(DISTANCE) ){ *os << " DISTANCE {" << Distance << "}"; } } if ( os->good() ){ if ( _exp->Verbosity(MATCH_DEPTH) ){ *os << " MATCH_DEPTH {" << _exp->matchDepth() << "}"; } } if ( os->good() ){ if ( _exp->Verbosity(CONFIDENCE) ){ *os << " CONFIDENCE {" <<_exp->confidence() << "}"; } } if ( os->good() ){ if ( _exp->Verbosity(NEAR_N) ){ *os << " NEIGHBORS" << endl; _exp->showBestNeighbors( *os ); *os << "ENDNEIGHBORS"; } } if ( os->good() ) *os << endl; return os->good(); } else { SDBG << _exp->ExpName() << ": Classify Failed on '" << params << "'" << endl; return false; } } void TcpServer::callback( childArgs *args ){ string Line; int sockId = args->id(); TimblThread *client = 0; map experiments = *(static_cast *>(callback_data())); int result = 0; args->os() << "Welcome to the Timbl server." << endl; if ( experiments.size() == 1 && experiments.find("default") != experiments.end() ){ DBG << " Voor Create Default Client " << endl; TimblExperiment *exp = experiments["default"]; client = new TimblThread( exp, args ); DBG << " Na Create Client " << endl; // report connection to the server terminal // } else { args->os() << "available bases: "; for ( const auto& exp_it : experiments ){ args->os() << exp_it.first << " "; } args->os() << endl; } if ( getline( args->is(), Line ) ){ DBG << "TcpServer::FirstLine='" << Line << "'" << endl; string Command, Param; bool go_on = true; DBG << "TcpServer::running FromSocket: " << sockId << endl; do { Line = TiCC::trim( Line ); DBG << "TcpServer::Line='" << Line << "'" << endl; Split( Line, Command, Param ); DBG << "TcpServer::Command='" << Command << "'" << endl; DBG << "TcpServer::Param='" << Param << "'" << endl; switch ( check_command(Command) ){ case Base:{ auto exp_it = experiments.find(Param); if ( exp_it != experiments.end() ){ args->os() << "selected base: '" << Param << "'" << endl; if ( client ){ delete client; } DBG << "TcpServer::before Create Default Client " << endl; client = new TimblThread( exp_it->second, args ); DBG << " TcpServer::After Create Client " << endl; // report connection to the server terminal // LOG << sockId << " Thread " << (uintptr_t)pthread_self() << " on Socket " << sockId << " started." << endl; } else { args->os() << "ERROR { Unknown basename: " << Param << "}" << endl; } } break; case Set: if ( !client ){ args->os() << "you haven't selected a base yet!" << endl; } else if ( client->setOptions( Param ) ){ DBG << "TcpServer::setOptions: " << Param << endl; args->os() << "OK" << endl; } else { args->os() << "ERROR { set options failed: " << Param << "}" << endl; } break; case Query: if ( !client ) args->os() << "you haven't selected a base yet!" << endl; else { args->os() << "STATUS" << endl; client->_exp->ShowSettings( args->os() ); args->os() << "ENDSTATUS" << endl; } break; case Exit: args->os() << "OK Closing" << endl; go_on = false; break; case Classify: if ( !client ){ args->os() << "you haven't selected a base yet!" << endl; } else { if ( classifyLine( client, Param ) ){ result++; } go_on = true; // HACK? } break; case Comment: args->os() << "SKIP '" << Line << "'" << endl; break; default: DBG << sockId << "TcpServer::Don't understand '" << Line << "'" << endl; args->os() << "ERROR { Illegal instruction:'" << Command << "' in line:" << Line << "}" << endl; break; } } while ( go_on && getline( args->is(), Line ) ); } delete client; LOG << "Thread " << (uintptr_t)pthread_self() << " terminated, " << result << " instances processed " << endl; } LanguageMachines-timblserver-8229b48/src/TimblClient.cxx000066400000000000000000000070761452016554300232650ustar00rootroot00000000000000/* Copyright (c) 1998 - 2023 CLST - Radboud University ILK - Tilburg University CLiPS - University of Antwerp This file is part of timblserver timblserver is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. timblserver is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see . For questions and suggestions, see: https://github.com/LanguageMachines/timblserver/issues or send mail to: lamasoftware (at ) science.ru.nl */ #include #include #include #include #include #include #include #include #include using namespace std; #include "timbl/TimblAPI.h" #include "ticcutils/CommandLine.h" #include "ticcutils/SocketBasics.h" #include "timblserver/ClientBase.h" using namespace std; using namespace Timbl; using namespace Sockets; inline void usage(){ cerr << "timblclient V0.10" << endl << "For demonstration purposes only!" << endl << "Usage:" << endl << "timblclient -n NodeName -p PortNumber [-i InputFile ][-o OutputFile] [--batch] [-b basename]" << endl; } int main(int argc, char *argv[] ){ // the following trick makes it possible to parse lines from cin // as well from a user supplied file. istream *Input = &cin; ostream *Output = &cout; ifstream input_file; ofstream output_file; bool c_mode = false; string base; string node; string port; TiCC::CL_Options opts( "i:o:p:n:b:", "batch" ); try { opts.init( argc, argv ); } catch( TiCC::OptionError& e ){ cerr << e.what() << endl; usage(); exit(EXIT_FAILURE); } string value; if ( opts.extract( "i", value ) ){ if ( (input_file.open( value, ios::in ), !input_file.good() ) ){ cerr << argv[0] << " - couldn't open inputfile " << value << endl; exit(EXIT_FAILURE); } cout << "reading input from: " << value << endl; Input = &input_file; } if ( opts.extract( "o", value ) ){ if ( (output_file.open( value, ios::out ), !output_file.good() ) ){ cerr << argv[0] << " - couldn't open outputfile " << value << endl; exit(EXIT_FAILURE); } cout << "writing output to: " << value << endl; Output = &output_file; } if ( opts.extract( "batch" ) ){ c_mode = true; } if ( opts.extract( "p", value ) ){ port = value; } if ( opts.extract( "n", value ) ){ node = value; } if ( opts.extract( "b", value ) ){ base = value; } if ( !node.empty() && !port.empty() ){ TimblServer::ClientClass client; if ( !client.connect( node, port ) ){ cerr << "connection failed " << endl; exit(EXIT_FAILURE); } if ( !base.empty() ){ if ( !client.setBase( base ) ){ cerr << "setbase failed"; exit(EXIT_FAILURE); } } if ( c_mode ){ if ( !client.classifyFile( *Input, *Output ) ){ cerr << "classification failed." << endl; exit(EXIT_FAILURE); } } else { if ( !client.runScript( *Input, *Output ) ){ cerr << "running script failed." << endl; exit(EXIT_FAILURE); } } exit(EXIT_SUCCESS); } else { usage(); exit(EXIT_FAILURE); } } LanguageMachines-timblserver-8229b48/src/TimblServer.cxx000066400000000000000000000211131452016554300233010ustar00rootroot00000000000000/* Copyright (c) 1998 - 2023 CLST - Radboud University ILK - Tilburg University CLiPS - University of Antwerp This file is part of timblserver timblserver is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. timblserver is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see . For questions and suggestions, see: https://github.com/LanguageMachines/timblserver/issues or send mail to: lamasoftware (at ) science.ru.nl */ #include #include #include #include #include "ticcutils/CommandLine.h" #include "ticcutils/PrettyPrint.h" #include "ticcutils/Timer.h" #include "timbl/TimblAPI.h" #include "ticcutils/ServerBase.h" #include "timblserver/TimblServer.h" #include "config.h" using namespace std; using namespace Timbl; using namespace TiCCServer; using namespace TimblServer; using TiCC::operator<<; namespace TimblServer { string Version() { return VERSION; } string VersionName() { return PACKAGE_STRING; } } inline void usage_full(void){ cerr << "usage: timblserver [TiMBLoptions] [ServerOptions]" << endl << endl; cerr << "for an overwiew of all TiMBLoptions, use 'timbl -h'" << endl; cerr << endl; ServerBase::server_usage(); } inline void usage(void){ cerr << "usage: timblserver --config=config-file" << endl; cerr << " timblserver -f data-file {-S socket} {-C num}" << endl; cerr << "or see: timblserver -h" << endl; cerr << " for more options" << endl; cerr << endl; } void startExperiments( ServerBase *server ){ map *experiments = static_cast *>(server->callback_data()); TiCC::LogStream &s_log = server->logstream(); map allvals; if ( server->config()->hasSection("experiments") ) allvals = server->config()->lookUpAll("experiments"); else { allvals = server->config()->lookUpAll("global"); // old style, everything is global // remove all already processed stuff auto it = allvals.begin(); while ( it != allvals.end() ){ if ( it->first == "port" || it->first == "protocol" || it->first == "logfile" || it->first == "debug" || it->first == "pidfile" || it->first == "daemonize" || it->first == "configDir" || it->first == "maxconn" ){ allvals.erase(it++); } else { ++it; } } } if ( allvals.empty() ){ string mess = "TimblServer: Unable to initalize at least one experiment\n"; mess += "please check your commandline or configuration file"; throw runtime_error( mess ); } for ( const auto& it : allvals ){ string exp_name = it.first; TiCC::CL_Options opts; opts.set_short_options( timbl_short_opts + serv_short_opts ); opts.set_long_options( timbl_long_opts + serv_long_opts ); opts.init( it.second ); string treeName; string trainName; string MatrixInFile = ""; string WgtInFile = ""; Weighting WgtType = GR; Algorithm algorithm = IB1; string ProbInFile = ""; string value; if ( opts.is_present( 'a', value ) ){ // the user gave an algorithm if ( !string_to( value, algorithm ) ){ string mess = exp_name + ":start(): illegal -a value: " + value; throw runtime_error( mess ); } } if ( !opts.extract( 'f', trainName ) ) opts.extract( 'i', treeName ); if ( opts.extract( 'u', ProbInFile ) ){ if ( algorithm == IGTREE ){ string mess = exp_name + ":start(): -u option is useless for IGtree"; throw runtime_error( mess ); } } if ( opts.extract( 'w', value ) ){ Weighting W; if ( !string_to( value, W ) ){ // No valid weighting, so assume it also has a filename vector parts = TiCC::split_at( value, ":" ); size_t num = parts.size(); if ( num == 2 ){ if ( !string_to( parts[1], W ) ){ string mess = exp_name + ":start(): invalid weighting option:" + value; throw runtime_error( mess ); } WgtInFile = parts[0]; WgtType = W; } else if ( num == 1 ){ WgtInFile = value; } else { string mess = exp_name + ":start(): invalid weighting option:" + value; throw runtime_error( mess ); } } } opts.extract( "matrixin", MatrixInFile ); if ( treeName.empty() && trainName.empty() ) { // we need to learn from trainName // OR read a tree from treeName s_log << "missing '-i' or '-f' option in serverconfig entry: '" << exp_name << "=" << it.second << "'" << endl; } else { // let's start TimblAPI *run = new TimblAPI( opts, exp_name ); bool result = false; if ( run && run->Valid() ){ if ( treeName.empty() ){ s_log << "trainName = " << trainName << endl; result = run->Learn( trainName ); } else { s_log << "treeName = " << treeName << endl; result = run->GetInstanceBase( treeName ); } if ( result && WgtInFile != "" ) { result = run->GetWeights( WgtInFile, WgtType ); } if ( result && ProbInFile != "" ){ result = run->GetArrays( ProbInFile ); } if ( result && MatrixInFile != "" ) { result = run->GetMatrices( MatrixInFile ); } } if ( result ){ run->initExperiment(); TimblExperiment *exp = run->grabAndDisconnectExp(); (*experiments)[exp_name] = exp; delete run; s_log << "started experiment " << exp_name << " with parameters: " << it.second << endl; } else { s_log << "FAILED to start experiment " << exp_name << " with parameters: " << it.second << endl; } } } if ( experiments->size() == 0 ){ s_log << "Unable to start a server. " << "No valid Timbls could be instantiated" << endl; exit(EXIT_FAILURE); } } int main(int argc, char *argv[]){ try { // Start. // cerr << "TiMBL Server " << TimblServer::Version() << " (c) CLTS/ILK/CLIPS 1998 - 2023.\n" << "Tilburg Memory Based Learner\n" << "Centre for Language and Speech Technology, Radboud University\n" << "Induction of Linguistic Knowledge Research Group, Tilburg University\n" << "CLiPS Computational Linguistics Group, University of Antwerp\n" << "based on " << Timbl::VersionName() << endl; cerr << TiCC::Timer::now() << endl; if ( argc <= 1 ){ usage(); return 1; } TiCC::CL_Options opts; opts.set_short_options( timbl_short_opts + serv_short_opts ); opts.set_long_options( timbl_long_opts + serv_long_opts ); opts.init( argc, argv ); if ( opts.is_present( 'h' ) || opts.is_present( "help" ) ){ usage_full(); exit(EXIT_SUCCESS); } if ( opts.is_present( 'V' ) || opts.is_present( "version" ) ){ cerr << "TiMBL server " << ServerBase::VersionInfo( true ) << endl; cerr << "Based on TiMBL " << TimblAPI::VersionInfo( true ) << endl; exit(EXIT_SUCCESS); } opts.insert( 'v', "F", true ); opts.insert( 'v', "S", false ); TiCC::Configuration *config = initServerConfig( opts ); if ( !config ){ exit(EXIT_FAILURE); } ServerBase *server = 0; string protocol = config->lookUp( "protocol" ); if ( protocol.empty() ){ protocol = "tcp"; } if ( protocol == "tcp" ){ server = new TcpServer( config ); server->logstream().message("tcp_server"); } else if ( protocol == "http" ){ server = new HttpServer( config ); server->logstream().message("http_server"); } else if ( protocol == "json" ){ server = new JsonServer( config ); server->logstream().message("json_server"); } else { cerr << "unknown protocol " << protocol << endl; exit(EXIT_FAILURE); } startExperiments( server ); return server->Run(); // returns EXIT_SUCCESS or EXIT_FAIL } catch( const std::bad_alloc& ){ cerr << "ran out of memory somewhere" << endl; cerr << "timblserver terminated, Sorry for that" << endl; } catch( const TiCC::OptionError& e ){ cerr << " " << e.what() << endl; } catch( const std::exception& e ){ cerr << "a standard exception was raised: '" << e.what() << "'" << endl; cerr << "timblserver terminated, Sorry for that" << endl; } catch(...){ cerr << "some unhandled exception was raised" << endl; cerr << "timblserver terminated, Sorry for that" << endl; } return 0; } LanguageMachines-timblserver-8229b48/src/TimblThread.cxx000066400000000000000000000040751452016554300232520ustar00rootroot00000000000000/* Copyright (c) 1998 - 2023 CLST - Radboud University ILK - Tilburg University CLiPS - University of Antwerp This file is part of timblserver timblserver is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. timblserver is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see . For questions and suggestions, see: https://github.com/LanguageMachines/timblserver/issues or send mail to: lamasoftware (at ) science.ru.nl */ #include #include #include #include #include "ticcutils/PrettyPrint.h" #include "ticcutils/ServerBase.h" #include "timbl/TimblAPI.h" #include "timbl/GetOptClass.h" #include "timblserver/TimblServer.h" using namespace std; using namespace Timbl; using namespace TimblServer; using namespace TiCCServer; using TiCC::operator<<; #define DBG *TiCC::Dbg(myLog) #define LOG *TiCC::Log(myLog) TimblThread::TimblThread( TimblExperiment *exp, childArgs* args, bool json ): myLog(args->logstream()), doDebug(args->debug()), os(args->os()), is(args->is()) { if ( doDebug ){ myLog.setlevel(LogHeavy); } _exp = exp->clone(); *_exp = *exp; if ( !_exp->connectToSocket( &(args->os() ) , json ) ){ throw logic_error( "unable to create working client" ); } if ( exp->getOptParams() ){ _exp->setOptParams( exp->getOptParams()->Clone( &(args->os() ) ) ); } _exp->setExpName(string("exp-")+TiCC::toString( args->id() ) ); } bool TimblThread::setOptions( const string& param ){ if ( _exp->SetOptions( param ) && _exp->ConfirmOptions() ){ return true; } return false; } LanguageMachines-timblserver-8229b48/timblserver.pc.in000066400000000000000000000004241452016554300230210ustar00rootroot00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: timblserver Version: @VERSION@ Description: Timbl Server library. Requires.private: timbl >= 6.4.0 libxml-2.0 Libs: -L${libdir} -ltimblserver Libs.private: @LIBS@ Cflags: -I${includedir}