Skip to content
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

Python deva_iast_comp step0 #3

Open
funderburkjim opened this issue Jan 3, 2022 · 42 comments
Open

Python deva_iast_comp step0 #3

funderburkjim opened this issue Jan 3, 2022 · 42 comments
Labels
documentation Improvements or additions to documentation

Comments

@funderburkjim
Copy link
Contributor

@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 added a commit that referenced this issue Jan 3, 2022
@funderburkjim
Copy link
Contributor Author

Of course, questions and comments here welcome.

@gasyoun
Copy link
Member

gasyoun commented Jan 5, 2022

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
Copy link
Contributor Author

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

@gasyoun
Copy link
Member

gasyoun commented Jan 6, 2022

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor Author

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:

  • Right-click on 'readwrite.py'
  • Choose 'open with'
  • Then choose your editor. In my case, I select EMACS

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
Copy link
Contributor Author

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
Copy link
Contributor

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

@funderburkjim
Copy link
Contributor Author

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:

  • git bash terminal
  • text editor
  • python (the program that 'runs' a .py file.

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
Copy link
Contributor

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

Dear Jim,
This step has done

изображение

@AnnaRybakovaT
Copy link
Contributor

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
Copy link
Member

gasyoun commented Jan 9, 2022

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

The default one for students.

@funderburkjim
Copy link
Contributor Author

@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
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor

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

@funderburkjim
Copy link
Contributor Author

@AnnaRybakovaT Try now

@AnnaRybakovaT
Copy link
Contributor

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
Copy link
Contributor

Try now

Thanks! It works now!

@funderburkjim
Copy link
Contributor Author

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.

  • in step0/readme.txt add a section at the bottom indicating how to run the program and what the program does. Add any additional comments that might be useful to you in future.
  • in readwriteA1.py, change the comments in the adjustlines function so they are consistent with
    'lower'.

@AnnaRybakovaT
Copy link
Contributor

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
Copy link
Contributor

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

@funderburkjim
Copy link
Contributor Author

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
Copy link
Contributor Author

the untracked file '../readwrite.txt'

I presume that

  • your current directory at the time of this screen shot is
    md/deva_iast_comp/step0
  • you have just done a git add . command in git bash terminal

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

@gasyoun gasyoun added the documentation Improvements or additions to documentation label Jan 11, 2022
@AnnaRybakovaT
Copy link
Contributor

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

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

@AnnaRybakovaT
Copy link
Contributor

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
Copy link
Contributor

both readme.txt and readwriteA1.py.

Has done.

@AnnaRybakovaT
Copy link
Contributor

AnnaRybakovaT commented Jan 16, 2022

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@AnnaRybakovaT
Copy link
Contributor

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
Copy link
Contributor Author

Yes, exactly.

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

  • deleted md/deva_iast_comp/readwrite.txt but
  • did not change the documentation

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
Copy link
Member

gasyoun commented Jan 17, 2022

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
Copy link
Contributor Author

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

@AnnaRybakovaT
Copy link
Contributor

Yes, exactly.

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

@gasyoun
Copy link
Member

gasyoun commented Jan 18, 2022

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
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants