Package: text4gcn
Text for GCNGCN applied in a text classification context.Table of ContentsAbstractInstallationFunctionalitiesExamplesGet Sample DataText PipelineBuilder AdjacencyContributingLicenseReferencesAbstractText4GCNis an open-source python framework that simplifies the generation of text-based graph data to be applied as input to graph neural network architectures. Text4GCN's core is the ability to build memory-optimized text graphs, using different text representations to create their relationships and define the weights used for edges.This project aims to exam the text classification problem with novel approaches Graph Convolutional Networks and Graph Attention Networks using Deep Learning algorithms and Natural Language Processing Techniques.The main contribution of this work is to provide a flexible framework, capable of performingsyntacticandsemanticfilters that make text graphs smaller and more representative. This framework offers an alternative and powerful tool for the study ofConvolutional Graph Networksapplied in the text classification task.Text graphInstallationText4GCNis available atPyPI:pipinstalltext4gcnAlso,Text4GCNcan be cloned directly from GitHub (https://github.com/vitormeriat/text4gcn) and run as a Python script.FunctionalitiesDatasets: Module responsible for downloading model datasets, used in benchmark tasks for text classification.Preprocess: It performs dataset processing, applies natural language processing to process the information and generates the files necessary for the construction of text graphs.Build Adjacency: Creates the adjacency matrix based on a specific representation.Models: Provides a two-tier GCN built with PyTorch for document classification task.ExamplesGet datafromtext4gcn.datasetsimportdata# List of all available datasetsdata.list()# Download sample data for a specific folderdata.R8(path=path)data.R52(path=path)data.AG_NEWS(path=path)Available Datasets:R8(Reuters News Dataset with 8 labels)R52(Reuters News Dataset with 52 labels)20ng(Newsgroup Dataset)coming soonOhsumed(Cardiovascular Diseases Abstracts Dataset)coming soonMR(Movie Reviews Dataset)coming soonCora(Citation Dataset)coming soonCiteseer(Citation Dataset)coming soonPubmed(Citation Dataset)Datasets Description:DatasetDocsTrainingTestWordsNodesClassesAverage Length20NG18,84611,3147,53242,75761,60320221.26R87,6745,4852,1897,68815,362865.72R529,1006,5322,5688,89217,9925269.82MR10,6627,1083,55418,76429,426220.39Ohsumed7,4003,3574,04314,15721,55723135.82Text Pipelinefromtext4gcn.preprocessimportTextPipeline# Create a text pipeline for processing a datasetpipe=TextPipeline(dataset_name="R8",rare_count=5,dataset_path="my_folder",language="english")# Run the created pipelinepipe.execute()Frequency Adjacencyfromtext4gcn.builderimportFrequencyAdjacency# Create the adjacency matrix based on a specific builderfreq=FrequencyAdjacency(dataset_name="R8",dataset_path="my_folder")# Run the created pipelinefreq.build()Available Builders:LiwcLinguistic Inquiry and Word Count to extract a dependency relationshipFrequencyEmbeddingBased on Word2vec, applied due to its ability to capture semantic information for word representationsCosineSimilarityDependencyParsingBased on the Syntactic Dependency Tree extracted with Stanford CoreNLPcoming soonConstituencyParsingGCNfromtext4gcn.modelsimportBuilderasbdfromtext4gcn.modelsimportLayeraslayerfromtext4gcn.modelsimportGNNgnn=GNN(dataset="R8",# Dataset to trainpath="my_folder",# Dataset pathlog_dir="examples/log",# Log pathlayer=layer.GCN,# Layer Typeepoches=200,# Number of traing epochesdropout=0.5,# Dropout rateval_ratio=0.1,# Train data used to validationearly_stopping=10,# Stop early techniquelr=00.2,# Initial learing ratenhid=200,# Dimensions of hidden layersbuilder=bd.Embedding# Type of Filtered Text Graph)gnn.fit()ContributingContributions aregreatly appreciated. If you want to help us improve this software, please fork the repo and create a new pull request. Don't forget to give the project a star! Thanks!Fork the ProjectCreate your Feature Branch (git checkout -b feature/AmazingFeature)Commit your Changes (git commit -m 'Add some AmazingFeature')Push to the Branch (git push origin feature/AmazingFeature)Open a Pull RequestAlternatively, you can make suggestions or report bugs by opening a new issue with the appropriate tag ("feature" or "bug") and following our Contributing template.LicenseDistributed under the MIT License. SeeLICENSE.txtfor more information.References[Kipf and Welling, 2017]  Semi-supervised Classification with Graph Convolutional Networks[Liang Yao, Chengsheng Mao, Yuan Luo, 2018] Graph Convolutional Networks for Text Classification(back to top)