I need to manually tag a large number of sentences choosing between a small, fixed number of short strings as tags for each sentence. I would like to do this with a Pharo GUI that displays sentences one at a time and permit choice of tags using radio buttons. The results need to be saved as a CSV file on the hard drive for further manipulations with python. As a first step, I used Excel to create a test CSV file with two sentences that was saved on the disk drive in the Pharo working directory. I have subsequently tried to import the sentences into Pharo 6.1 32 bit stable. This was done as follows. |workingDir reader result| workingDir := FileSystem disk workingDirectory. myFileName := 'MoonCSV.csv'. stream := workingDir/myFileName readStreamDo: [ :stream | stream contents]. reader := (NeoCSVReader new) separator: Character cr. The separator was changed from a comma to a cr because the inspector showed a cr, not a comma separating the two imported sentences. result := (reader on: stream). result upToEnd. This failed with the following error: Instance of ByteString doesnât understand #atEnd. I donât see how to proceed further. Also I am not clear on the best way to export the sentence and tags to the disk drive.. Any help would be appreciated. Lou Cleveland
Hi,
Instance of ByteString doesnât understand #atEnd.
This is a very typical error when you have accidentally passed a String instead of a Stream. ... which you did here:
stream := workingDir/myFileName readStreamDo: [ :stream | stream contents].
You can either operate directly on the file stream, e.g. file := 'D:\tmp\rules.csv' asFileReference. result := file readStreamDo: [ :stream | |reader| reader := NeoCSVReader new. reader on: stream. reader upToEnd. ]. Or if you already have a string, then ask it for its readStream file := 'D:\tmp\rules.csv' asFileReference. contents := file contents. reader := NeoCSVReader new. reader on: contents readStream. reader upToEnd. On Mon, Nov 26, 2018 at 11:27 PM William L. Cleveland <wlc1@columbia.edu> wrote:
I need to manually tag a large number of sentences choosing between a small, fixed number of short strings as tags for each sentence. I would like to do this with a Pharo GUI that displays sentences one at a time and permit choice of tags using radio buttons. The results need to be saved as a CSV file on the hard drive for further manipulations with python.
As a first step, I used Excel to create a test CSV file with two sentences that was saved on the disk drive in the Pharo working directory.
I have subsequently tried to import the sentences into Pharo 6.1 32 bit stable. This was done as follows.
|workingDir reader result|
workingDir := FileSystem disk workingDirectory.
myFileName := 'MoonCSV.csv'.
stream := workingDir/myFileName readStreamDo: [ :stream | stream contents].
reader := (NeoCSVReader new) separator: Character cr. The separator was changed from a comma to a cr because the inspector showed a cr, not a comma separating the two imported sentences.
result := (reader on: stream).
result upToEnd.
This failed with the following error:
Instance of ByteString doesnât understand #atEnd.
I donât see how to proceed further. Also I am not clear on the best way to export the sentence and tags to the disk drive..
Any help would be appreciated.
Lou Cleveland
participants (2)
-
Peter Uhnak -
William L. Cleveland