Skip to main content

A text based decision tree builder

Project description

Python Implementation of Neil Larson's PERM Decision Tree Builder

This project is a Python implementation of Neil Larson's DOS-based PERM Decision Tree Builder, a tool designed to convert three hierarchical input files into a decision tree or search tree. Originally developed for DOS, PERM used text-based input files created with Larson's MaxThink outliner. This implementation preserves that functionality while allowing the use of any ASCII text editor.

Table of Contents

Overview

PERM processes three input files—Attribute File, Category File, and Priority File—to generate a decision tree. These files use a hierarchical structure, with indentation (spaces or tabs) to denote levels. The output is a minimal-path decision tree, useful for decision-making processes like selecting a beverage based on attributes such as cost, color, and taste.

Input Files

Attribute File (A)

The Attribute File defines the items and their properties. Below is an example for selecting a beverage:

TITLE
    DRINK COKE
        COLOR: BROWN
        COST: $0.75
        TASTE: TART
    DRINK PEPSI
        TASTE: TART
        COLOR: BROWN
        COST: $0.80
    DRINK ROOT BEER
        COLOR: TAN
        COST: $0.75
        TASTE: SWEET
  • Notes:
    • Attribute tags (e.g., COLOR, COST, TASTE) are optional but must be consistent across files.
    • Indentation indicates hierarchy (use spaces or tabs).

Category File (B)

The Category File organizes attributes into decision-making categories. It is derived from the Attribute File:

TITLE
    How much does it cost?
        COST: $0.75
        COST: $0.80
    What is the color?
        COLOR: BROWN
        COLOR: TAN
    What is the taste?
        TASTE: SWEET
        TASTE: TART
  • Notes:
    • Questions group related attributes.
    • Must align with attributes defined in the Attribute File.

Priority File (C)

The Priority File defines the order of decision-making criteria for different user types. It is derived from the Category File:

Beverage Decision Tree
    PRICE BUYER
        How much does it cost?
        What is the color?
        What is the taste?
    COLOR BUYER
        What is the color?
        What is the taste?
        How much does it cost?
    TASTE BUYER
        What is the taste?
        What is the color?
        How much does it cost?
  • Notes:
    • Each buyer type prioritizes categories differently.
    • Order of questions determines the decision path.

File Conversion

If using a text editor other than MaxThink, ensure compatibility with indentation:

  • Convert tabs to spaces (MaxThink format):
    cat a.otl | expand --tabs=1 > a.mt
    
  • Convert spaces to tabs:
    cat a.mt | unexpand --tabs=1 > a.otl
    

Output Example

Running perm A B C > D generates an output file (D) with minimal decision paths:

Beverage Decision Tree
    PRICE BUYER
        COST: $0.75
            COLOR: BROWN
                DRINK COKE
            COLOR: TAN
                DRINK ROOT BEER
        COST: $0.80
            DRINK PEPSI
    COLOR BUYER
        COLOR: BROWN
            COST: $0.75
                DRINK COKE
            COST: $0.80
                DRINK PEPSI
        COLOR: TAN
            DRINK ROOT BEER
    TASTE BUYER
        TASTE: SWEET
            DRINK ROOT BEER
        TASTE: TART
            COST: $0.75
                DRINK COKE
            COST: $0.80
                DRINK PEPSI
  • Result: A structured tree showing optimal decisions based on buyer priorities.

Usage

  1. Prepare the three input files (A, B, C) as described above.
  2. Run the program from the command line:
    perm A B C > D
    
  3. Check the output file (D) for the generated decision tree.

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyperm_decisiontree-0.1.2.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

pyperm_decisiontree-0.1.2-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file pyperm_decisiontree-0.1.2.tar.gz.

File metadata

  • Download URL: pyperm_decisiontree-0.1.2.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for pyperm_decisiontree-0.1.2.tar.gz
Algorithm Hash digest
SHA256 412c0c8fd69dc16b7d6f1a9aeaa4dfb2946e6ecd3bdfb4bce4b02602a6f82cd0
MD5 e7e6051b0a3b5d78ad9d4ac4fbc3ee3f
BLAKE2b-256 9df951229972288bb1d0b7eb2784eb005550dedbdb61b5a264d9388817f45be0

See more details on using hashes here.

File details

Details for the file pyperm_decisiontree-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pyperm_decisiontree-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b4d03639e8b80a522f5bed5d0e2c693ff7dcef9cd954cea5234777c1c255c633
MD5 90e1044b8634945cb359bc516d8acdbf
BLAKE2b-256 bc3e7f48786e67b1eed0b1fa7b5243d3d87fc6267b656dab4dd9d80bce023052

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page