Skip to content

Latest commit

 

History

History
144 lines (104 loc) · 4.87 KB

README.md

File metadata and controls

144 lines (104 loc) · 4.87 KB

5-Letter-Words

GitHub code size in bytes GitHub top language LICENSE

A collection of five-letter English words, available in both JSON and TXT format, designed for seamless integration into your project(s). This repository offers an easily accessible list of five-letter words, ideal for word games, educational resources, and various other applications, with an extra c# script to convert txt to json thrown in 😉.

Table of Contents

Usage

You can easily integrate this word list into your projects by accessing either the TXT, JSON endpoints or downlading the files locally. Below are some examples of how to fetch/read and use the word-list endpoint in your application or download and use the file locally, For quick access to relevant links and further details, checkout the resource page.

Endpoints

You can access the list of words through the following endpoints:

Downloads

Instead of using a endpoint you can download the files locally at:

Examples

a list of examples of using the word list in your program

Python

Fetching the JSON Data from the endpoint

import requests

url = "https://cheaderthecoder.github.io/5-Letter-words/words.json"
response = requests.get(url)
words = response.json()

print(words[:10])  # Print the first 10 words as an example

c#

Reading from the TXT file locally

using System;
using System.IO;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        // Path to the local file containing the 5-letter words
        string filePath = "path/to/your/words.txt";

        // Read all lines from the file into a string array
        string[] words = File.ReadAllLines(filePath);

        // Example: Print the words
        foreach (var word in words)
        {
            Console.WriteLine(wordList[i]);
        }

      Console.ReadKey();
    }
}

JavaScript

Fetching the TXT Data from the endpoint

// URL of the TXT file
const url = 'https://cheaderthecoder.github.io/5-Letter-words/words.txt';

// Fetch the TXT file
fetch(url)
  .then(response => {
    // Check if the response is successful
    if (!response.ok) {
      throw new Error('Status Code: ' + response.statusText);
    }
    return response.text(); // Return the text content
  })
  .then(data => {
    // Split the text data by new lines into an array of words
    const words = data.split('\n').map(word => word.trim());

    // Example: Log the first 10 words
    console.log('First 10 words:', words.slice(0, 10));

    // Log all words (optional)
    // words.forEach(word => console.log(word));
  })
  .catch(error => {
    // Handle errors
    console.error('error:', error);
  });

Script

This script converts a list of words from a text file into a JSON file format. It fetches a text file containing a list of five-letter words from a specified URL, processes the content, and saves it as a JSON file.

Overview

Language: C#
Dependencies:
    Newtonsoft.Json
    .NET Core or .NET Framework

Features

Fetches data from a remote text file using HttpClient.
Converts the list of words to a JSON format using JsonConvert.SerializeObject.
Saves the JSON output to a file named words.json.

Acknowledgements

A list of Repo's/projects that helped me in someway

License

This project is licensed under the MIT License License - see the LICENSE file for details