Coder Social home page Coder Social logo

simple_typing_application's Introduction

Simple Typing Application: To Measure Your Typing Performance

GitHub top language GitHub tag (latest SemVer) GitHub GitHub last commit

Scheduled Tests

application image

Requires

  • Python >= 3.8

    • click
    • langchain
    • langchain_openai
    • openai
    • pydantic
    • pynput
    • python-dotenv
    • requests
    • sshkeyboard
    • types-pynput
    • types-requests
  • OpenAI API Key

See pyproject.toml for detail information.

Installation

You can install simple_typing_application with pip.

pip install git+https://github.com/hmasdev/simple_typing_application.git

If you want to install the full-version, i.e. simple_typing_application with data analysis packages like pandas, matplotlib and jupyterlab, specify [extra].

git clone https://github.com/hmasdev/simple_typing_application.git
cd simple_typing_application
pip install .[extra]

You can specify the following optional dependencies:

  • [huggingface]
  • [extra]
  • [dev]

For more details, see ./pyproject.toml.

Usage

Configuration

You can specify some parameters with '.json'.

For example, the following .json files are valid:

The content of ./sample_config.json is as follows:

{
    "sentence_generator_type": "OPENAI",
    "sentence_generator_config": {
        "model": "gpt-3.5-turbo-16k",
        "temperature": 0.7,
        "openai_api_key": "HERE_IS_YOUR_API_KEY",
        "memory_size": 0,
        "max_retry": 5
    },
    "user_interface_type": "CONSOLE",
    "user_interface_config": {},
    "key_monitor_type": "PYNPUT",
    "key_monitor_config": {},
    "record_direc": "./record"
}

As default, the contents of 'sample_config.json' are used except openai_api_key. In this case, you should add an environment variable OPENAI_API_KEY which contains your API key or create .env file like

OPENAI_API_KEY={HERE_IS_YOUR_API_KEY}

Sentence Generator

You can specify the followings as sentence_generator_type:

  • OPENAI: Use OpenAI API to generate typing targets;
  • HUGGINGFACE: Use the model available in HuggingFace to generate typing targets;
  • STATIC: Use typing targets which you have specified.

For each sentence_generator_type, you can specify the detailed parameters as sentence_generator_config:

To see the default values, see ./simple_typing_application/models/config_models/sentence_generator_config_model.py.

User Interface

You can specify the followings as user_interface_type:

  • CONSOLE: CUI

For each user_interface_type, you can specify the detailed parameters as user_interface_config:

  • CONSOLE
    • No parameters

To see the default values, see ./simple_typing_application/models/config_models/user_interface_config_model.py.

Key Monitor

You can specity the followings as key_monitor_type:

  • PYNPUT: pynput-based local key monitor
  • SSHKEYBOARD: sshkeyboard-based key monitor

For each key_monitor_type, you can specify the detailed parameters as key_monitor_config:

  • PYNPUT
    • No parameters
  • SSHKEYBOARD
    • No parameters

To see the default values, see ./simple_typing_application/models/config_models/key_monitor_config_model.py.

Launch the application

You can launch this application with the following command:

python -m simple_typing_application -c HERE_IS_YOUR_CONFIG_FILE

If you want to launch this application with debug mode, run the following command:

python -m simple_typing_application -c HERE_IS_YOUR_CONFIG_FILE --debug

For more details, run python -m simple_typing_application --help.

Do typing

simple_typing_application shows typing targets through the interface which you has specified. Type correct keys. Note that Typing Target (Romaji) displayed in your interface is one of correct typing patterns. For example, when Typing Target (Hiragana) is 'ใก', both 'ti' and 'chi' are correct although only one of them is displayed.

In addition to normal typing, the following keys can be accepted:

  • Esc: to quit the application;
  • Ctrl+c: to quit the application;
  • Tab: to skip the current typing target.

Analyze Your Typing Performance

The application records your typing in the following format in the directory specified in you config file for each typing target.

{
    "timestamp": "HERE IS TIMESTAMP THE TYPING START WITH FORMAT %Y-%m-%dT%H:%M:%S.%f",
    "typing_target": {
        "text": "HERE IS TYPING TARGET",
        "text_hiragana_alphabet_symbol": "HERE IS TRANSFORMED STRING WHICH CONTAINS ONLY HIRAGANA, ALPHABET AND SYMBOLS",
        "typing_target": [["CORRECT PATTERN. TYPICALLY ROMANIZED STRING", ...], ...]
    },
    "records": [
        {
            "timestamp": "HERE IS TIMESTAMP WHEN YOU TYPE %Y-%m-%dT%H:%M:%S.%f",
            "pressed_key": "WHICH KEY YOU HAVE PRESSED",
            "correct_keys": ["", ...],
            "is_correct": true or false
        },
        ...
    ]
}

Refer to ./sample_record.json for example.

Development

  1. Fork this repository:

  2. Clone your forked repository:

    git clone https://github.com/hmasdev/simple_typing_application
    cd simple_typing_application
  3. Create your feature branch:

    git checkout -b feature/your-feature
  4. Setup your development environment:

    pip install .[dev]

    if you want to develop the application with huggingface, pandas and etc., run the following command:

    $ pip install .[huggingface,extra,dev]

    To know which option is available, see ./pyproject.toml.

  5. Develop your feature and add tests.

  6. Test your feature:

    pytest  # Unit test
    pytest -m integrate  # integration test
  7. Check the code style and static type:

    flake8 simple_typing_application
    flake8 tests
    mypy simple_typing_application
    mypy tests
  8. Commit your changes:

    git add .
    git commit -m "Add your feature"
  9. Push to the branch:

    git push -u origin feature/your-feature
  10. Create a new Pull Request:

Thank you for your contribution!

LICENSE

simple_typing_application is licensed under the MIT License. See the LICENSE file for more details.

References

Authors

simple_typing_application's People

Contributors

hmasdev avatar github-actions[bot] avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.