Skip to content

Add script for package description complexity extraction #743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions scripts/time-complexities/from-cabal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#! /usr/bin/env sh

set -e

export LC_COLLATE=C LC_CTYPE=C

header_fields_re="^ +\\| *$(printf '%s *\\| *' \
'Resource' \
'Operation' \
'Merge policy' \
'Merge schedule' \
'Worst-case disk I\\\/O complexity'
)\$"

printf '%s\n' 'Resource,Operation,Merge policy,Merge schedule,Worst-case disk I\\\/O complexity'

sed -E -e '
# Drop everything from the beginning to the header fields
1,/'"$header_fields_re"'/ d
# Drop everything after the table
/^ *$/,$ d
# Drop separating lines
/^ +\+([=-]+\+)* *$/ d
# Switch to delimiting by commas
s/ *\| */,/g
# Remove initial comma
s/^,//
# Remove final comma
s/,$//
# Remove escaping of slashes
s/\\\//\//g
# Remove (leading) occurrences of “N/A”
s/(^|,)N\/A/\1/g
# Remove monospace and inline math markup
s/@|\\\(|\\\)//g
# Fill empty “Resource” field with previous content
/^,/ {
G
s/(.*)\n([^,]*).*/\2\1/
}
# Fill empty “Operation” field with previous content
/^[^,]*,,/ {
G
s/([^,]*,)(.*)\n[^,]*,([^,]*).*/\1\3\2/
}
# Store the current output line
h
' "$@"