Index

Subject : [lug] Digest (1 messages)

From : lug-owner@lists.ncsu.[redacted]

Date : Mon, 09 Feb 2015 20:32:07 -0500


The Lug Digest
Volume 1 : Issue 342 : "text" Format

Messages in this Issue:
201502/3 : Re: Cleaning excess whitespace from text files.
Jeffery Mewtamer <mewtamer@gmail.[redacted]>

----------------------------------------------------------------------

Date: Mon, 2 Feb 2015 12:54:29 +0000
From: Jeffery Mewtamer <mewtamer@gmail.[redacted]>
To: lug@lists.ncsu.[redacted]
Subject: Re: Cleaning excess whitespace from text files.
Message-ID: <CAO2sX30J7wSPAdhBDzj=Tu1jO7-xW-Duw=tLUFdrMLLveAprRQ@mail.gmail.[redacted]>

Good Morning,

Sorry for the late reply, but I was having a rough weekend on account
of the usual stresses of being a blind university student when the
Chaotic system we call life decided to blindside(no pun intended) me
with a sudden death in the family(If you're wondering, I appear to be
holding up better than the rest of the family).

Anyways, to more pleasant matters, I wasn't able to get the tr based
script to work(my tests just produced a empty text file with a random
filename and left the test input file such that fdupes marked it as
matching the file it was copied from), but I've googled the tr command
in an effort to understand how to use it and I'm sure I'll find use
for it even if it doesn't solve this particular issue.

I haven't had a chance to try the python script yet, but the mention
of a potential python solution does remind me that I should probably
make an effort to at least learn the basics of python and perl
scripting, especially since most graphical tools are beyond my reach.

Also, as requested, I've attached some files to illustrate what I'm up
against. Attached are three versions each of two documents. One is a
short homework assignment originally in docx format and the other is a
set of lecture notes originally in ppt format. I've included the
original files downloaded from Blackboard along with both the raw
output of saving what Gmail's "view as html" feature produces as plain
text and manually cleaned versions of the files. Because the lecture
notes would have take too long to manually clean, I've truncated the
uncleaned .txt to the first hundred lines and the cleaned version only
contains the cleaned-up version of those hundred lines.

For what it's worth, here is how my screen readers read the white space.

Orca, my graphical screen reader, condenses whitespace when reading
line-by-line, treating single blank lines between paragraphs as if
they aren't there, reading blocks of whitespace as a single blank
line, and not vocalizing any kind of whitespace that is intermingled
with visible text. Reading character-by-character, it does vocalize
individual whitespace characters and distinguishes between them. Note
that this is Orca's behavior for non-editable text, but as Firefox is
the only reason I ever go into Graphical mode, I have no easy way to
open files in a editor so Orca can read them.

SBL, my text-mode reader, does not vocalize whitespace characters at
all, can't distinguish between a truly blank line and a line of
whitespace characters, and when reading text line-by-line, I have to
silently arrow up/down accross all the whitespace lines. Also doesn't
vocalize most punctuation when reading line-by-line and will thus read
some lines consisting only of punctuation as if they were blank(i.e.
by remaining silent), but best I can tell, that isn't relevant
here(and where it is relevant, mainly closing braces in C++/Java
source code, I've long ago solved the problem by using comments to
label the braces(also useful for keeping track of which code block is
being closed)).

Reading accross one of the whitespace blocks character-by-character
with orca, it appears the culprit preventing cat -s from removing all
the extra blank lines might be stray tab characters rather than no
break space characters.

On 2/1/15, Kevin Hunter Kesling <hunteke@earlham.[redacted]> wrote:
> At 4:02pm -0500 Sun, 01 Feb 2015, Kevin Hunter Kesling wrote:
>> $ reduce_whitespace.py
>>
>> Hope that helps,
>
> Also, note that I have tested exactly 0% of this, so take care when
> executing it.
>
> Kevin
>


--
Sincerely,

Jeffery Wright
President Emeritus, Nu Nu Chapter, Phi Theta Kappa.
Former Secretary, Student Government Association, College of the Albemarle.
COMPUTER ORGANIZATION AND DESIGN



The Hardware/Software Interface



5th





Edition



Chapter 2



Instructions: Language of the Computer



Instruction Set



* The repertoire of instructions of a computer
* Different computers have different instruction sets
o But with many aspects in common
* Early computers had very simple instruction sets
o Simplified implementation
* Many modern computers also have simple instruction sets



§2.1 Introduction



The MIPS Instruction Set



* Used as the example throughout the book
* Stanford MIPS commercialized by MIPS Technologies (www.mips.com
<http://www.mips.com/>)
* Large share of embedded core market
o Applications in consumer electronics, network/storage equipment,
cameras, printers, …
* Typical of many modern ISAs
o See MIPS Reference Data tear-out card, and Appendixes B and E



Arithmetic Operations



* Add and subtract, three operands
o Two sources and one destination

add a, b, c # a gets b + c

* All arithmetic operations have this form
* Design Principle 1:Simplicity favours regularity
o Regularity makes implementation simpler
o Simplicity enables higher performance at lower cost



§2.2 Operations of the Computer Hardware



Arithmetic Example



* C code:

f = (g + h) - (i + j);

* Compiled MIPS code:

add t0, g, h # temp t0 = g + h
add t1, i, j # temp t1 = i + j
sub f, t0, t1 # f = t0 - t1



Register Operands



* Arithmetic instructions use register
operands


[Attachment of type application/vnd.ms-powerpoint removed.]
COMPUTER ORGANIZATION AND DESIGN

The Hardware/Software Interface

5th Edition

Chapter 2

Instructions: Language of the Computer

Instruction Set

* The repertoire of instructions of a computer
* Different computers have different instruction sets
o But with many aspects in common
* Early computers had very simple instruction sets
o Simplified implementation
* Many modern computers also have simple instruction sets

2.1 Introduction

The MIPS Instruction Set

* Used as the example throughout the book
* Stanford MIPS commercialized by MIPS Technologies (www.mips.com
* Large share of embedded core market
o Applications in consumer electronics, network/storage equipment,
cameras, printers
* Typical of many modern ISAs
o See MIPS Reference Data tear-out card, and Appendixes B and E

Arithmetic Operations

* Add and subtract, three operands
o Two sources and one destination

add a, b, c # a gets b + c

* All arithmetic operations have this form
* Design Principle 1:Simplicity favours regularity
o Regularity makes implementation simpler
o Simplicity enables higher performance at lower cost

2.2 Operations of the Computer Hardware

Arithmetic Example

* C code:

f = (g + h) - (i + j);

* Compiled MIPS code:

add t0, g, h # temp t0 = g + h
add t1, i, j # temp t1 = i + j
sub f, t0, t1 # f = t0 - t1

Register Operands

* Arithmetic instructions use register operands


[Attachment of type application/vnd.openxmlformats-officedocument.wordprocessingml.document removed.]
*If there are images in this attachment, they will not be displayed.*
Download the original attachment
</attachment/u/0/?view=att&th=14b4544a0fa2dec5&attid=0.1&disp=attd&realattid=file1&saduie=AG9B_P-Kz80PvVdGR4m4zJNV8Yud&zw>

Elizabeth City State University

Department of Mathematics and Computer Science

Home work 1 (20 pts), CSC 314-01 (Computer Architecture), Spring 2015





[4 pts]



1.State the four design principles of MIPS?

[16 pts]



2. Convert the following high-level language into MIPS machine code.
Represent the machine code both in binary and hexadecimal formats.

A[5] = f – B[7];

Given that $t0 has he base of array A, $t1 has the base of array B, and
$s1 corresponds to variable f.



Elizabeth City State University

Department of Mathematics and Computer Science

Home work 1 (20 pts), CSC 314-01 (Computer Architecture), Spring 2015

[4 pts] 1.State the four design principles of MIPS?

[16 pts] 2. Convert the following high-level language into MIPS machine code.
Represent the machine code both in binary and hexadecimal formats.

A[5] = f – B[7];

Given that $t0 has the base of array A, $t1 has the base of array B, and
$s1 corresponds to variable f.

------------------------------

End of [lug] Digest (1 messages)
**********