{"id":24985324,"url":"https://github.com/cahya-wirawan/opentc","last_synced_at":"2025-04-11T22:35:22.234Z","repository":{"id":57449252,"uuid":"86568247","full_name":"cahya-wirawan/opentc","owner":"cahya-wirawan","description":"OpenTC is a text classification engine using several algorithms in machine learning","archived":false,"fork":false,"pushed_at":"2020-05-04T09:52:23.000Z","size":70,"stargazers_count":26,"open_issues_count":0,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-07T18:01:39.272Z","etag":null,"topics":["convolutional-neural-networks","machine-learning","svm-classifier","tensorflow","text-classification"],"latest_commit_sha":null,"homepage":"https://cahya-wirawan.github.io/opentc","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cahya-wirawan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-29T10:18:21.000Z","updated_at":"2024-02-29T04:49:33.000Z","dependencies_parsed_at":"2022-09-14T07:31:11.308Z","dependency_job_id":null,"html_url":"https://github.com/cahya-wirawan/opentc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cahya-wirawan%2Fopentc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cahya-wirawan%2Fopentc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cahya-wirawan%2Fopentc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cahya-wirawan%2Fopentc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cahya-wirawan","download_url":"https://codeload.github.com/cahya-wirawan/opentc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248491023,"owners_count":21112870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["convolutional-neural-networks","machine-learning","svm-classifier","tensorflow","text-classification"],"created_at":"2025-02-04T10:51:45.393Z","updated_at":"2025-04-11T22:35:22.210Z","avatar_url":"https://github.com/cahya-wirawan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Open Text Classification (OpenTC)\n\nOpenTC is a text classification engine using machine learning. It is designed as client-server architecture and uses \npython libraries scikit-learn and tensorflow for it's machine learning algorithms. \nCurrently following algorithms are supported:\n\n- Naive Bayes\n- Support Vector Machine\n- Convolutional Neural Network\n\nIn the future it will also support FastText from Facebookresearch. \n\nThe engine is running as a server listening on command and text to be classified. By default it listens on localhost \nport 3333, but it can be changed in the yaml configuration file. \n\nOpenTC can be used for example for text classification (a demo website for this purpose is available online \n[OpenTC demo](http://opentc.oldjava.org/demo/)), or for other purposes such as Data Leak Prevention (DLP). \nAn example of implementation for the DLP has been created as ICAP Server: \n[opentc-icap](https://github.com/cahya-wirawan/opentc-icap) \n\n\n## Requirements\n- Python 3.x\n- numpy\n- pyparsing\n- PyYAML\n- scikit-learn\n- scipy\n- tensorflow 1.x\n\n## How to use\n\n### Installation\nInstall the module using pip:\n\n    $ pip install opentc\n    \nor clone the repository\n    \n    $ git clone https://github.com/cahya-wirawan/opentc.git\n    $ cd opentc\n    $ python setup.py install\n\n\n### opentc\n\n#### synopsis\nopentc\n\n#### Description\nThe command line to train the application based on the datasets define in the configuration file. The result\nof the training (pre-trained data) can be used for the opentcd server.\n\n#### Usage\n\n    $ python opentc -h\n    usage: opentc [-h] [-c CLASSIFIER] [-C CONFIGURATION_FILE] [-d DATASET]\n                  [-l LOG_CONFIGURATION_FILE]\n    \n    optional arguments:\n      -h, --help            show this help message and exit\n      -c CLASSIFIER, --classifier CLASSIFIER\n                            set classifier to use for the training (support\n                            currently bayesian, svm or cnn)\n      -C CONFIGURATION_FILE, --configuration_file CONFIGURATION_FILE\n                            set the configuration file\n      -d DATASET, --dataset DATASET\n                            set dataset to use for the training\n      -l LOG_CONFIGURATION_FILE, --log_configuration_file LOG_CONFIGURATION_FILE\n                            set the log configuration file\n\n\n### opentcd\n\n#### synopsis\nopentcd\n\n#### Description\nThe daemon listens for incoming connections on TCP port (default is 3333) and classify files or text string on \ndemand. It reads a configuration file in the following order: ./opentc.yml, ~/.opentc/opentc.yml or \n/etc/opentc/opentc.yml.\n\n#### Usage\nOpentcd uses the configuration file opentc.yml to define allmost all possible configuration. Only few setup\ncan be overridden in command line options.\n\nList of arguments:\n\n    $ python opentcd -h\n    usage: opentcd [-h] [-a ADDRESS] [-C CONFIGURATION_FILE]\n                   [-l LOG_CONFIGURATION_FILE] [-p PORT] [-t TIMEOUT]\n    \n    optional arguments:\n      -h, --help            show this help message and exit\n      -a ADDRESS, --address ADDRESS\n                            define the address for the server\n      -C CONFIGURATION_FILE, --configuration_file CONFIGURATION_FILE\n                            set the configuration file\n      -l LOG_CONFIGURATION_FILE, --log_configuration_file LOG_CONFIGURATION_FILE\n                            set the log configuration file\n      -p PORT, --port PORT  define the port number which the server uses to listen\n      -t TIMEOUT, --timeout TIMEOUT\n                            define the time out\n\nRun it as background application:\n    \n    $ python opentcd\u0026\n    2017-05-02 13:33:22,276 - opentc.core.classifier.cnn_text - DEBUG - Load the checkpoint: \n    data/input/cnn_twenty_newsgroup_20170301_090000-all/checkpoints/model-2210\n    INFO:tensorflow:Restoring parameters from data/input/cnn_twenty_newsgroup_20170301_090000-all/checkpoints/model-2210\n    2017-05-02 13:33:23,899 - tensorflow - INFO - Restoring parameters \n    from data/input/cnn_twenty_newsgroup_20170301_090000-all/checkpoints/model-2210\n    2017-05-02 13:33:27,375 - __main__ - INFO - Server start\n    2017-05-02 13:33:28,019 - opentc.core.server - INFO - Server loop running in thread: Thread-1\n\n\n\n\n#### datasets and pre-trained data\nThe configuration file defines the path to the datasets and pre-trained data. A pre-trained data for testing\npurpose can be downloaded from [data](https://NoFile.io/f/8DkSGjqW3qO/data.tgz), it is around 1.4GB. Just uncompress it \nand change the path to the pre-trained data in opentc.yml file accordingly.\n\n#### Commands\nThe command uses a newline character as the delimiter. If opentcd doesn't recognize the command, \nor the command doesn't follow the requirements specified below, it will reply with an error message, but still wait \nfor the next commands (this behaviour can be changed in the future).\n\n##### PING\nCheck the server's state. It should reply with \"PONG\".\n\n##### VERSION\nPrint the program version\n\n##### RELOAD\nReload the engine\n\n##### LIST_CLASSIFIER\nList the supported classifiers (at the moment there are three classifiers\nsupported: Bayesian, Support Vector Machine and Convolutional Neural Network). It shows also \nthe status of classifier, either True (enabled) or False (disabled).\n\n##### SET_CLASSIFIER\nEnabled or disabled the specific classifier\n\n##### PREDICT_STREAM\nClassify text streams. It uses a new line character as delimiter for every sentences. \n\n##### PREDICT_FILE\nClassify file. It uses a new line character as delimiter for every sentences\n\n##### CLOSE\nClose the connection\n\n## Todo\n- Multilabel classification\n- Include FastText from Facebookresearch\n- Will use pyzmq and google's protobuf to improve the protocol and network communication\n- considering a multi processing server instead of multi threading due to the global interpreter lock \n  used in threads which prevent the code to run really concurrently in multi processor environment.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcahya-wirawan%2Fopentc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcahya-wirawan%2Fopentc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcahya-wirawan%2Fopentc/lists"}