Raphaela Heil
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Introduction to Text and Image Analysis Using Python - Workshop Webpage: https://raphaelaheil.github.io/2022-03-15-dhnb/ - Code of Conduct: https://coderefinery.org/about/code-of-conduct/ - JupyterHub: https://worker02.chcaa.au.dk/jupyter/hub/login (username and password have been distributed via email) - Link to this note: https://hackmd.io/@rheil/dhnb_2022 ## Program |Time|Topic|Instructor| |---|---|---| |9:00|Introduction to Jupyter (based on [this CodeRefinery lesson](https://coderefinery.github.io/jupyter/))|Diana| |9:25|[Python basics and first computational notebook](https://github.com/coderefinery/jupyter-dhnb)|Radovan| |10:00|Analyzing Documents with TF-IDF, [material](https://github.com/RaphaelaHeil/2022-03-15-dhnb/tree/gh-pages/text-analysis) (based on [this Programming Historian lesson](https://programminghistorian.org/en/lessons/analyzing-documents-with-tfidf))|Henrik| |11:00|[Clustering-based Analysis of Handwritten Digits](https://github.com/RaphaelaHeil/clustering-dhnb)|Raphaela| ## Icebreaker question How do you use or plan to use Python in your research? - text analysis - Using Python for pre- and post-processing of data and for data visualization. - Data visualization. Scraping. - Image Analysis - Text wrangling / pattern searching. statistics - As an additional tool to supplement R - especially audio and image analysis. - Text classification, topic modeling, text mining - Plan: code-switching research in early modern Latin-Greek texts - create alternate lessons (from existing R code) for text/image/network analysis - Audio analysis - Text analysis - I don't do any research, I'm a librarian, but I would like to learn more about the possibilities for text analysis - Will start a phd soon where I'll use NLP on cuneiform economic sources // work on Sumerian dialects in cuneiform sources in my current project - Online text re-use research - Text analysis, pattern searching - Just a developer in the field of digital humanities curious to see whats happening. - Webscraping - creating text analysis workflows for HTR output - Identify handwritten text in printed maps ## Questions and Notes for Part I: "Introduction to Jupyter" - What is your experience with Jupyter notebooks? - no experience: oooooooooo - some experience: ooooooooooo - Which operating system are you using? - Windows: ooooooooo - macOS: ooooooooo - Linux: ooo - Python experience: - have never written any Python: ooooooo - have already written some Python: ooooooooooo ### Starting Jupyter-Lab locally On Windows: 1. Open "Anaconda Prompt" from the start menu 2. write (without quotes) "jupyter-lab" 3. press Enter MacOS and Linux: 1. Open a Terminal 2. write (without quotes) "jupyter-lab" 3. press Enter To Quit (any operating system): - press the Control key and "C" at the same time ## Questions and Notes for Part II: "Python basics and first computational notebook" - Can you run the whole notebook, so you don't get an error from not running a previous cell? - yes, in the menu at the top, under "Cell" (or "Run"), there is the option to "Run All" - Do you have any good practice tips for naming variables? - good variable names are descriptive for humans. the computer does not mind whether it is `n` or `num_words` but the latter is better for humans. - avoid variable names that are reserved by python, here is a list of reserved keywords: https://realpython.com/lessons/reserved-keywords/ - Maybe an overly specific question, so feel free not to prioritize. This is my first time using conda and jupyter notebooks and since activating the environment EVERY terminal window opens with the conda environment activated. As a heavy terminal user, this is pretty irritating. Is there any way to limit the scope of the environment, e.g. only to the terminal in which it was first activated? (Linux OS) - it is an excellent question. when you installed Conda you probably answered yes to a question whether your .bashrc environment should be modified to activate the base environment every time. you could take that out of your .bashrc and activate Conda environment explicitly. I also recommend to create separate environments for separate projects and then you would not like to use the base environment anyway. The reason why we did not go too deep into this is to not confuse with too many things. - yes! it's .bashrc. Thanks. - what I do (but it is a bit more advanced use): .bashrc is not modified and I activate Conda explicitly myself. I use separate environments for each project and I never install anything into the base environment but always into the project environments. Motivation: it forces me to document my dependencies and no risk of me messing up my base environment. If I mess up, I just delete the project enviroment and recreate it. - :thumbsup: I do the same, but with venv. ## Questions and Notes for Part III: "Analyzing Documents with TF-IDF" - notebook "TF_IDF_and_cosine_similarity.ipynb" if you want to follow the already written code - notebook "TF_IDF_and_cosine_similarity_blank.ipynb" if you want to write the code that Henrik presents yourself - ... - I can't load the text data. The file isn't found. I can find `2_text_analysis\lesson-files\lesson-files\txt` but 2 `input_files = os.listdir('lesson-files/txt')` doesn't work. - does this work: `input_files = os.listdir('lesson-files/lesson-files/txt')`? Yes, thank you! - (for the later discussion maybe) just a small question about word_tokenize(): the Counter output has a lot of punctuation marks as well as the default split, but does nltk tokenizer has an argument to remove punctuation? or it should be done separately before? - RB: I am looking for a good answer ... not knowing that code I would probably remove punctuation myself outside but looking whether there is not a better way - I looked more and it seems nltk can do a lot and recognize punctuation: https://www.nltk.org/api/nltk.tokenize.html - Maybe you may get some inspiration from https://stackoverflow.com/questions/15547409/how-to-get-rid-of-punctuation-using-nltk-tokenizer or https://www.codegrepper.com/code-examples/python/how+to+remove+punctuation+in+python+nltk. - Yes, thanks, my question was just about the function itself: similar R function `unnest_tokens()` would delete all punctuation marks by default (and it's a question sometimes how to keep them:)), so now I see here it's the other way round - One could use `stop_words`. - One could wrap word_tokenize in a custom function that filters out the punctuation, for instance by using a regular expression - This part of the workshop was quite difficult to follow without previous experience. Do you know of a more basic tutorial? (Since the programming historian one is also quite advanced) - and you mean basic tutorial introducing Python or introducing NLTK or this method? - For nltk: https://www.nltk.org/book/ - For introduction to python (including pandas, with emphasis on loading and plotting data): https://swcarpentry.github.io/python-novice-gapminder/ - Any good way of visualizing the results? - https://www.geeksforgeeks.org/visualize-data-from-csv-file-in-python/ - Network graphs: http://jonathanstray.com/a-full-text-visualization-of-the-iraq-war-logs - Some graph plotting libraries I (HA) have used are networkx and pyvis: https://pyvis.readthedocs.io/en/latest/ https://networkx.org/documentation/stable/index.html ## Break until 11:10 ## Questions and Notes for Part IV: "Clustering-based Analysis of Handwritten Digits" - Can you explain a little bit about how pixels_per_cell impacts on the accuracy of the overall process? Is it better to just have more pixels per cell? Why not 64x64 according to the original image? - 64x64 and 32x32 causes errors in the later parts of the doc. fyi - Under 1. Loading the data, I get an error message when running: utils.digit_grid(images[:100]) The error message is: ValueError: Supply a single scale, or one value per spatial axis. It seems I have to specify the multichannel argument as true, but I cannot figure out how to do that (and wonder why I have to do it) Any suggestions? I will try to update Python. I was just asking in case you see immediately what the problem is. ## Feedback One thing that was particularly good/useful: - A plus was that it was a good start to see some examples of what you can do with Python. Especially the handwriting recognition part was interesting.... - It was very interesting to see the part on image analysis, which is all new to me. The text analysis part was also very good. ... - Image analyses was great!! I'm hooked & now wondering about the next steps..letters, word shapes? - Good and varied examples, showing different types of applications. One thing we should change/remove/adjust for next time: - This is all new to me so a bit hard to follow. - ... - I would suggest for next time, try to estimate different levels of the participants and do a beginner & intermediate group separately. Some comments about the level going too quickly, on the other hand it's easy to become disengaged while the presenter goes over fundamentals. - I agree with parting the group in two for different levels. It was hard to follow many steps in the workshop. - It would have been useful to get some exercises to try out some step of the analysis. This was more of a demonstration than a workshop and I had no hope trying to do the steps while shown.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully