Package: wordwright
WordwrightA package for text processingIn today's world, text is omnipresent and serves as more than just a form of communication. From the briefest tweets to in-depth blog posts, from academic papers to business emails, our digital world is full of textual content. The ability to read, analyze, and derive meaning from the written content is crucial. This is where our text analysis packagewordwrightenters the picture.Package SummaryThis Python packagewordwrightfocuses on text analysis and processing. It offers a range of functions, from basic text cleaning to more complex analyses such as language detection, word and sentence counting, word frequency summarizing, and keyword searching. This functionality is particularly useful in fields like data analysis, natural language processing, and anywhere textual data needs to be understood or transformed. Functions are designed to be self-explanatory, which is especially beneficial for those new to programming or text processing. Quickstart guide could be foundhere.ContributorsYi Han (@yhan178), Yingzi Jin (@jinyz8888), Yi Yan (@carrieyanyi), Hongyang Zhang (@alexzhang0825)InstallationInstall from PyPIRun this command to install the package$pipinstallwordwrightInstall from GitHubIf the installation is unsuccessful, please consider the following process. Before proceeding with the installation, ensure you have Miniconda/Anaconda installed on your system. These tools provide support for creating and managing Conda environments.Step 1: Clone the RepositoryStart by cloning the repository to your local machine. Open your terminal and run the following command:$gitclonegit@github.com:UBC-MDS/wordwright.gitNavigate to the directory of the cloned repository.Step 2: Create and Activate the Conda EnvironmentCreate a new Conda environment using theenvironment.yamlfile provided in this repository. This file contains all the necessary dependencies, including both Python and Poetry versions.To create the environment, open your terminal and navigate to the directory where theenvironment.yamlfile is located. Then, run the following command:$condaenvcreate-fenvironment.yaml

$condaactivatewordwrightStep 3: Install the Package Using PoetryWith the Conda environment activated, you can now use Poetry to install the package. Run the following command to install the package using Poetry:$poetryinstallThis command reads the pyproject.toml file in your project (if present) and installs the dependencies listed there.Running the testsNavigate to the project root directory and use the following command in terminal to test the functions defined in the projects. Tests are stored inhere.$pytesttests/*TroubleshootingEnvironment Creation Issues: If you encounter problems while creating the Conda environment, ensure that the environment.yaml file is in the correct directory and that you have the correct version of Conda installed.Example UsageTo use thewordwrightpackage, you can import and call its functions in your Python environment. Here is an example:>>>fromwordwright.preprocessingimportclean_text
>>>fromwordwright.word_frequencyimportfrequent_words
>>>fromwordwright.count_keywordsimportcount_keywords

>>>clean_text("It's a sunny day. ,Let's GO!")"it's a sunny day let's go">>>text="The quick brown fox jumps over the lazy dog. The fox was very quick.">>>stopwords=["the","over","was","very"]>>>frequent_words(text,stopwords)Counter({'quick':2,'fox':2,'brown':1,'jumps':1,'lazy':1,'dog':1})>>>count_keywords("I like cheese.",["cheese"]){'cheese':1}Functionsload_text(file_path): Loads and returns the content of a text file. Required input isfile_path, which specifies the path to the file.clean_text(text): Cleans a text string by removing punctuation, converting to lowercase, and removing common stopwords. Required input istext, which is the string to be cleaned.count_keywords(text, keywords): Counts the occurrences of specified keywords in the text. Required inputs aretextandkeywords. After giving a list of keywords, this function return the occurrence of each selected word.count_sentences(text, punctuation): Count the number of sentences in the text. The number of sentences is counted based on specified delimiters. Required inputs aretextandpunctuation.language_detection(text): Detects if the text is in English or not. Required input istext, which is the text to be checked for language.frequent_words(text, number, stopwards): Analyzes a given text to find and return the most frequent words, excluding specified stopwords. Required inputs aretext,number, andstopwards, which are the cleaned text to be analyzed, the number of most frequent words to return, and a list of words to be excluded from the analysis.wordwrightUse in Python EcosystemWhile there are other packages that offer similar functions, such asNatural Language Toolkit(Loper & Bird, 2002) andTextBlob(Loria, 2018).wordwrightdistinguishes itself by its simplicity and focus on the most essential text processing features. It is designed for ease of use, making it an excellent choice for those who have basic programming knowledge.ContributingInterested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.Licensewordwrightwas created by Yi Han, Yingzi Jin, Yi Yan, Hongyang Zhang. It is licensed under the terms of the MIT license.Creditswordwrightwas created withcookiecutterand thepy-pkgs-cookiecuttertemplate.ReferenceLoper, E., & Bird, S. (2002). Nltk: The natural language toolkit. arXiv preprint cs/0205028.Loria, S. (2018). textblob Documentation. Release 0.15, 2(8), 269.