rk

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2023 License: MIT Imports: 15 Imported by: 0

README

🌳 Go Bonzai File Comparison Branch

File Comparison using a slightly modified version of the Rabin Karp Algorithm to determine propabilities of plagarism accross student submissions.

Installation

You can grab the latest binary release. This rk command can be installed as a standalone program or composed into a Bonzai command tree.

Standalone

go install github.com/chriswifn/rk/cmd/rk@latest

Composed

package z

import (
    Z "github.com/rwxrob/bonzai/z"
    "github.com/chriswifn/rk"
)

var Cmd = &Z.Cmd{
    Name: `z`,
    Commands: []*Z.Cmd{help.Cmd, rk.Cmd},
}

Tab Completion

To activate bash completion just use the complete -C option from your .bashrc or command line. There is no messy sourcing required. All the completion is done by the program itself.

complete -C rk rk

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &Z.Cmd{
	Name:        `rk`,
	Aliases:     []string{},
	Copyright:   `Copyright 2023 Christian Hageloch`,
	Version:     `v0.1.2`,
	License:     `MIT`,
	Source:      `git@github.com:chriswifn/rk.git`,
	Issues:      `github.com/chriswifn/rk/issues`,
	Commands:    []*Z.Cmd{compareCmd, help.Cmd, vars.Cmd, conf.Cmd, initCmd, filterCmd},
	Summary:     help.S(_rk),
	Description: help.D(_rk),
}

Functions

func Checker

func Checker(text, pattern string) string

func Contains

func Contains(a interface{}, e interface{}) bool

func Intersect

func Intersect(a interface{}, b interface{}) []interface{}

func Mod

func Mod(a, b int) int

func WalkDir

func WalkDir(root string, filename string) ([]string, error)

Types

type PlagarismChecker

type PlagarismChecker struct {
	HashTable map[string][]int
	KGram     int
}

func NewPlagarismChecker

func NewPlagarismChecker(fileA, fileB string) *PlagarismChecker

func (PlagarismChecker) CalculateHash

func (pc PlagarismChecker) CalculateHash(content, docType string)

func (PlagarismChecker) CalculatePlagarismRate

func (pc PlagarismChecker) CalculatePlagarismRate() float64

func (PlagarismChecker) GetFileContent

func (pc PlagarismChecker) GetFileContent(filename string) string

func (PlagarismChecker) GetRate

func (pc PlagarismChecker) GetRate() float64

func (PlagarismChecker) PrepareContent

func (pc PlagarismChecker) PrepareContent(content string) string

type RabinKarp

type RabinKarp struct {
	Base        int
	Text        string
	PatternSize int
	Start       int
	End         int
	Mod         int
	Hash        int
}

func NewRabinKarp

func NewRabinKarp(text string, patternSize int) *RabinKarp

func (*RabinKarp) CurrentWindowText

func (rb *RabinKarp) CurrentWindowText() string

CurrentWindowText return the current window text

func (*RabinKarp) GetHash

func (rb *RabinKarp) GetHash()

func (*RabinKarp) NextWindow

func (rb *RabinKarp) NextWindow() bool

Directories

Path Synopsis
cmd
rk

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL