sanskrit-lexicon / MD

Research re Macdonell Sanskrit-English Dictionary
0 stars 0 forks source link

Python deva_iast_comp step0 #3

Open funderburkjim opened 2 years ago

funderburkjim commented 2 years ago

@AnnaRybakovaT - Please git pull (or clone) this https://github.com/sanskrit-lexicon/MD/ repository and Check out the 'deva_iast_comp' directory, starting with the readme files.

Then try the suggestions for study in step0/readme.txt.

When you're ready, push the directory again.

funderburkjim commented 2 years ago

Of course, questions and comments here welcome.

gasyoun commented 2 years ago

questions and comments here welcome.

Guess it will take her a few more days to recover. I myself was dead for three days, but now it's ower. She will soon follow.

funderburkjim commented 2 years ago

Were you and Anna taken by Covid? Glad you are better, and hope also Anna recovers soon.

gasyoun commented 2 years ago

It was not covid for me, hope not for Anna as well. Anna said she'll be back in a couple of days. And I would want to introduce Kate, @KateRusse from the same city Anna initially came from, from the same Saint Petersburg State University.

AnnaRybakovaT commented 2 years ago

Were you and Anna taken by Covid

Dear all, Finally I came back! I suppose I had a virus, I did two rapid test for Covid, both of them were negative, but we know many cases of incorrect work of such simple tests. In any case I am almost fine and from today I again have more or less normal life.

AnnaRybakovaT commented 2 years ago

Of course, questions and comments here welcome.

Dear Jim, Of course, I have some questions)))

I have managed to open the file readwrite.py only by IDLE (there was option "Edit with IDLE". Is it ok? It looks like this: изображение

In general I understood the structure and the described functions.

Could you provide more details how to run the program, I mean: Usage: python readwrite.py ../data.txt readwrite.txt

AnnaRybakovaT commented 2 years ago

the same city Anna initially came from, from the same Saint Petersburg State University

Marcis, you aren't quite right, before Greece I was living and studying in Moscow. In Saint Petersburg and in Saint Petersburg State University I just have a lot of friends.

funderburkjim commented 2 years ago

open the file readwrite.py only by IDLE

I suggest NOT to do this. Although IDLE is part of the Python download, I never use it.

I suggest opening readwrite.py with your favorite text editor. The way I do this on Windows 10 is:

image

The first time you do this, your editor may not show up in the list. In this case select 'Choose another app'. image

If your editor doesn't show in the 'choose another app' list, then click on 'more apps' You'll get a bigger list, where your editor should appear. Then select it. You could experiment with selecting the 'Always use this to open .py' Personally I don't use it, even though I do always open .py files with Emacs.

Note: It's possible your editor won't appear in the longer 'choose another app' list. Then you would need to click 'Look for another app on this PC', which will open a standard File Explorer dialog which you would use to navigate to the 'exe' file that opens your editor.

funderburkjim commented 2 years ago

python readwrite.py ../data.txt readwrite.txt

This is the 'command' to use in a terminal, such as the git bash terminal. So type (or copy-paste) this command into the terminal, then press 'enter' so the terminal program will execute the command.

AnnaRybakovaT commented 2 years ago

Dear Jim, many thanks!!! I suppose i understood now what to do. I will try to manage it tomorrow.

funderburkjim commented 2 years ago

You may see the term 'development environment' which refers to the programs (tools) used to aid in the development of programs written in some programming language. In the way I am describing to you, the development environment involves three components:

This is a minimalist python development environment. Professional programmers would likely use something else, such as

What we are doing might be classified as a type of natural language processing, which is considered a branch of 'data science',

Effective use of these more robust development environments requires gaining knowledge of the tools and, sometimes, a complex installation procedure. For me, the learning curve has never been worth it. But I do occasionally like to experiment with Jupyter notebooks. When beginning Python programming several years ago, I also made use of some simpler web-based programming environments such as

And probably others.

Depending on how your interest in Python develops, you may sometime want to try some of these other approaches. But for now, I'll stick with helping you learn via the 'minimalist' environment.

AnnaRybakovaT commented 2 years ago

I suggest opening readwrite.py with your favorite text editor.

Dear Jim, This step has done

изображение

AnnaRybakovaT commented 2 years ago

This is the 'command' to use in a terminal, such as the git bash terminal.

but I have some difficulties with this: изображение

Maybe do you see what I do wrong?

gasyoun commented 2 years ago

https://colab.research.google.com/

The default one for students.

funderburkjim commented 2 years ago

@AnnaRybakovaT The command to execute the program must be consistent with where things are in the file system. Notice that you are in the directory 'MD'. But that is not where 'readwrite.py' is found. (do you see how the error message gives this clue?)

Thus, you need to find the directory containing this 'readwrite.py' program, then 'cd' there in Gitbash. So, what directory is readwrite.py in ? Do an 'ls' to list all the files in that directory. Then redo the command. Finally, do an 'ls' again to see if there are any new files in the directory. If there is a new file, edit it in EMeditor and see how the new file and original file (what is the 'original' file in this case?) Then review readwrite.py to understand how the original file was changed into the new file.

AnnaRybakovaT commented 2 years ago

Notice that you are in the directory 'MD'. But that is not where 'readwrite.py' is found

Dear Jim, Thanks a lot! I was close))) Now I did it! изображение

I will continue tomorrow. And now it's bedtime.

funderburkjim commented 2 years ago

Yep! You got it!

Do you understand why the command has '../data.txt' instead of 'data.txt' ? What is that '../' ? What happens if you omit the '../' ?

What happens if you run the command python readwrite.py ../data.txt ../temp_readwrite.txt ?

And why did I write '../temp_readwrite.txt' instead of '../readwrite.txt' ?

AnnaRybakovaT commented 2 years ago

Dear Jim, Step 0 has done. Only I can't push the directory изображение

funderburkjim commented 2 years ago

@AnnaRybakovaT Try now

AnnaRybakovaT commented 2 years ago

Do you understand why the command has '../data.txt' instead of 'data.txt' ? What is that '../' ? What happens if you omit the '../' ?

To be honest I can only guess. For example - when we work with the file 'data.txt' by Python this program creates one new file '../data.txt' which includes some data of 'data.txt'. I noticed - such files aren't tracked by "git add" изображение

In any case, I suppose I need your support and explanations about this issue.

AnnaRybakovaT commented 2 years ago

Try now

Thanks! It works now!

funderburkjim commented 2 years ago

I pulled, and now see your results of running readwrite program and that you made a new version 'readwriteA1.py', ran the program and generated 'readwriteA1.txt' . I see that you discovered to use 'lower' method instead of 'upper'. That's what I expected. A good start!

documentation

Some suggestions regarding 'documentation' of your new program. The main principle: add enough documentation to help recall what you did.

Documentation is never perfect, and what is enough documentation is subjective.

Here are suggestions regarding documentation of readwriteA1.

AnnaRybakovaT commented 2 years ago

Some suggestions regarding 'documentation' of your new program. The main principle: add enough documentation to help recall what you did.

Is "documentation" should be in a file "readme"?

AnnaRybakovaT commented 2 years ago

Dear all, Just for information. Tomorrow I am going to Athens for some days, so until Saturday I will unavailable.

funderburkjim commented 2 years ago

Is "documentation" should be in a file "readme"?

First, there is already a file 'readme.txt' in step0 directory, which I started. The documentation suggestion above involved both readme.txt and readwriteA1.py.

funderburkjim commented 2 years ago

the untracked file '../readwrite.txt'

I presume that

In this case, git picks up all the modified files in the current directory or in any subdirectories of the current directory. So git shows the two readwriteA1 files in green, indicating it found them. But it didn't pick up md/deva_iast_comp/readwrite.txt -- that's why '../readwrite.txt' shows in red and is said to be untracked.

what does '../' mean?

When current directory is md/deva_iast_comp/step0, then '../' refers to the parent directory, i.e., to the directory md/deva_iast_comp.

In terminal, make step0 your current dirrectory, then issue command ls ../ --- you should see a listing of all the files in the parent directory. Use File explorer if necessary to convince yourself that the list is indeed the files in parent directory.

Next try ls ../../ --- Before doing make a guess as to what you will see.

funderburkjim commented 2 years ago

what to do with '../readwrite.txt'

I think you really don't want md/deva_iast_comp/readwrite.txt. (the readwrite.txt you want is md/deva_iast_comp/readwrite.txt, which you've already pushed). So just delete it. Then do a 'git status' to be sure git no longer sees it.

funderburkjim commented 2 years ago

Why did I use '../data.txt'

This was in running readwrite.py (and similarly your readwriteA1.py).

I put data.txt in the deva_iast_comp directory on purpose, in anticipation of using it as the input file not only in step0 but in future step1, step2, etc.

But since we are running our program from step0 (and later from step1, etc.), python readwrite.py data.txt temp.txt would not find data.txt (since data.txt is not in step0).

You can try running this command (with data.txt instead of ../data.txt) to see what happens; You will get an error condition saying the program did not find 'data.txt'.

Thus, we have to indicate the full location of data.txt, and since data.txt is in the directory which is a parent of step0 directory, we use '../data.txt' in the command to indicate the path to the input file relative to where the program is being run: python readwrite.py ../data.txt readwrite.txt.

funderburkjim commented 2 years ago

multi-level house analogy

Here's an analogy that may be helpful in thinking about '../' and other things about locations.

Think of the 'MD' directory as a multi-level house, with each level containing rooms, and possibly containing stairs connecting the levels. The top level currently contains a room with only README.md sitting on the floor, along with two stairs going down one level to rooms deva_iast_comp and verbs01.

jimfu@DESKTOP-6PTUC6R MINGW64 /c/xampp/htdocs/sanskrit-lexicon/md (master)
$ ls
README.md  deva_iast_comp/  verbs01/

We can use the stairs down to deva_iast_comp room:

jimfu@DESKTOP-6PTUC6R MINGW64 /c/xampp/htdocs/sanskrit-lexicon/md (master)
$ cd deva_iast_comp

jimfu@DESKTOP-6PTUC6R MINGW64 /c/xampp/htdocs/sanskrit-lexicon/md/deva_iast_comp (master)

What's in that room?

jimfu@DESKTOP-6PTUC6R MINGW64 /c/xampp/htdocs/sanskrit-lexicon/md/deva_iast_comp (master)
$ ls
data.txt  readme.txt  step0/

two boxes data.txt and readme.txt, and a stairway down to a room step0.

If we want to go back up to the level above this level, the stairway up is known as '../'

jimfu@DESKTOP-6PTUC6R MINGW64 /c/xampp/htdocs/sanskrit-lexicon/md/deva_iast_comp (master)
$ cd ../

jimfu@DESKTOP-6PTUC6R MINGW64 /c/xampp/htdocs/sanskrit-lexicon/md (master)

Don't know if this analogy is helpful. If not, just ignore.

AnnaRybakovaT commented 2 years ago

Don't know if this analogy is helpful. If not, just ignore.

Dear Jim, Thanks a lot! Everything is absolutely clear now!!!

AnnaRybakovaT commented 2 years ago

You will get an error condition saying the program did not find 'data.txt'.

I had this message during my 1st try to write the Usage for readwriteA1.py. And now I understood why))

AnnaRybakovaT commented 2 years ago

both readme.txt and readwriteA1.py.

Has done.

AnnaRybakovaT commented 2 years ago

md/deva_iast_comp/readwrite.txt. (the readwrite.txt you want is md/deva_iast_comp/readwrite.txt

I am confused a bit... Probably I have to delete one of those files: md/deva_iast_comp/step0/readwrite.txt or md/deva_iast_comp/readwrite.txt

funderburkjim commented 2 years ago

You could delete md/deva_iast_comp/readwrite.txt (you would also need to change your documentation deva_iast_comp/step0/readme.txt at line 44 from '../readwrite.txt' to '../data.txt'.

funderburkjim commented 2 years ago

I'll start preparing a 'step1' . Where we'll do more complex things in the 'adjustlines' function.

AnnaRybakovaT commented 2 years ago

you would also need to change your documentation deva_iast_comp/step0/readme.txt at line 44 from '../readwrite.txt' to '../data.txt'.

Dear Jim, In this case the documentation and at line 41 has to be changed: "readwriteA1.py Second python program, designed to read the lines of data.txt" (instead of "....to read the lines of readwrite.txt) Is it correct?

funderburkjim commented 2 years ago

Yes, exactly.

Incidentally, the suggested change to documentation is optional. But, in the hypothetical case where you

Then someone reading the documentation in readme and trying the suggested command would get an error, and thus might be confused. It is to avoid (to the extent possible) such confusion that I suggested the change to the readme file. It's good to get in the habit of thinking of documentation as an integral part of programming.

gasyoun commented 2 years ago

It's good to get in the habit of thinking of documentation as an integral part of programming.

It is something to be learnt from you. Actually I have quite many Russian newcommers and they are ready for different tasks. What could we test them on?

funderburkjim commented 2 years ago

@gasyoun What kinds of 'different tasks' are you thinking of for the newcomers? Programmatic analysis of data related to Sanskrit?

AnnaRybakovaT commented 2 years ago

Yes, exactly.

Thanks!!! Just wanted to be sure. Now has done.

gasyoun commented 2 years ago

What kinds of 'different tasks' are you thinking of for the newcomers?

Whatever - checking of lists of suspected words, abbreviation cleanup, literally anything.

Programmatic analysis of data related to Sanskrit?

They are no-coders, or maybe one them is a bit, but I would not push in this directin too far.

funderburkjim commented 2 years ago

@gasyoun got it. Will keep this in mind and develop some ideas.