Χρήστης:Sarri.greek/PAWS

Από Βικιλεξικό
Μετάβαση στην πλοήγηση Πήδηση στην αναζήτηση
>> done
Sarri.greekσυζήτηση - help:βοήθεια - mygoogle - PAWS - ref@en.wikt - fonts@en - audio@en - ετυμολογία - μοντέλα - λεξικογραφία -  
εργασίες - lab - εκφρ - tAr - t4.t5 - mS.tS - menu - ΣΥΖ&ΒΚΔΜ

Simple, very simple tasks. E.g. replace a word...
2023.07.01. LINK Go to:

https://hub-paws.wmcloud.org/hub/login?next=%2Fhub%2F
(older: https://paws.wmflabs.org/paws/hub/home)
Welcome to a PAWS redirect page!

Notice: PAWS has changed domain names
If you're arriving here, you probably arrived from an old link. As announced in https://lists.wikimedia.org/hyperkitty/list/cloud-announce@lists.wikimedia.org/thread/5RSH7DAGGIYHCSFBCV62COONUYN73E7K/ and discussed in https://phabricator.wikimedia.org/T328842 This domain was discontinued on 2023-03-13

Please update your links and use hub-paws.wmcloud.org and public-paws.wmcloud.org

dumps: write:

-xml:/public/dumps/public/elwiktionary/latest/elwiktionary-latest-pages-articles-multistream.xml.bz2
Notes: For a long time, a weird 'error' message appeared at PAWS. Legoktm helped solving it: Συζήτηση_βικιλεξικού:Bots#Please,_could_you_help_us

2023: OK now, this works https://dumps.wikimedia.org/elwiktionary/latest/

-xml:/public/dumps/public/elwiktionary/latest/elwiktionary-latest-pages-articles-multistream.xml.bz2

1) Go to https://hub-paws.wmcloud.org/hub/login?next=%2Fhub%2F

2) Log on: no problem, my username is already there

3) a card pops up. It looks like this: Click 'Allow'

Since 2022 there is A NEW SCREEN. Go to HELP and click Launch Classic Notebook

Choose New > Terminal to do replacements.

help:

The code for simple replacement of a letter or words in a specific phrase.

Replace phrase in all wiktionary

[επεξεργασία]
pwb.py replace -lang:el -family:wiktionary -xml:/public/dumps/public/elwiktionary/latest/elwiktionary-latest-pages-articles-multistream.xml.bz2 "κλίσ-'πρόβατο" "κλίση-'βούτυρο" -summary:"pwb.py replace κλίση πρόβατο = βούτυρο"


Add -ns:0 to search only in main namespace of wiktionary. Then, find all the other pages (Talks, etc with Search insource:xxxx)


Replace phrase in a category

[επεξεργασία]
pwb.py replace -lang:el -family:wiktionary -cat:"Ανδρικά ονόματα (αρχαία ελληνικά)" "{{λείπει η ετυμολογία|grc}}" "{{λείπει η ετυμολογία|τύπος=όνομα|grc}}" -summary:"pwb.py +τύπος=όνομα"


Replace in one category starting from character B

[επεξεργασία]

I need to start from specific letter, because the category is too big. e.g. for letter Γ γ (capital or lowercase) I add -titleregex:'^γ.'

pwb.py replace -lang:el -family:wiktionary -cat:"Κατηγορία:Λήμματα με προφορά (νέα ελληνικά)" "ɛ" "e" "ɔ" "o" ".ˈ" "ˈ" ".'" "ˈ" -titleregex:'^γ.'   -summary:"pwb.py ενημέρωση [[ΔΦΑ]]"


Replace 2 empty lines with 1 empty line + excepttext

[επεξεργασία]

Use -excepttext:"BLAHBLAH" Example: replace. except if the page has a specific expression. Use -excepttext:"BLAHBLAH"

pwb.py replace -regex -lang:el -family:wiktionary -ns:0 -xml:/public/dumps/public/elwiktionary/latest/elwiktionary-latest-pages-articles-multistream.xml.bz2 -excepttext:"{{clear}}\n===={{μεταφράσεις}}"  "{{clear}}\n\n===={{μεταφράσεις}}"  "{{clear}}\n===={{μεταφράσεις}}" '\s\n===={{μεταφράσεις}}====' '\n{{clear}}\n===={{μεταφράσεις}}===='  -summary:"{{clear}} πριν τις μεταφράσεις"

Replace empty line after Template + param

[επεξεργασία]

Example: at Translations section

Replace empty line

Template|param + empty line + asterisc which starts the next line as in
{{μτφ-αρχή|blahblah}}

* {{en}}: ...... etc

Use "({{μτφ-αρχή[^}]+}})\n\n(\*)" "\1\n\2"

[^}] means: any character which is NOT a curly bracket }
+ means: get a sequence with 1 character at least.
to make sure it works if a vertical pipe | does not exist, use an asterisc: [^}]*
Careful: asterisc has special meaning in regex. We need to put \ before it, if needed as simple text

This is the command: (repeat at dumps)

pwb.py replace -ns:0 -regex -lang:el -family:wiktionary -cat:"Νέα ελληνικά" "({{μτφ-αρχή[^}]+}})\n\n(\*)" "\1\n\2" -summary:"PAWS - συντήρηση: μείον κενές γραμμές στις Μεταφράσεις"

pwb.py replace -regex -lang:el -family:wiktionary -ns:0 -xml:/public/dumps/public/elwiktionary/latest/elwiktionary-latest-pages-articles-multistream.xml.bz2 "({{μτφ-αρχή[^}]+}})\n\n(\*)" "\1\n\2" -summary:"PAWS - συντήρηση: μείον κενές γραμμές στις Μεταφράσεις"


Template|param + empty line + < which starts the next line as in
{{μτφ-αρχή|blahblah}}

<!-- .....
as above.
ooops. problem

This is the command: (repeat at dumps)

pwb.py replace -regex -lang:el -family:wiktionary -ns:0 -cat:"Νέα ελληνικά" "({{μτφ-αρχή[^}]+}})\n\n(<)" "\1\n\2" -summary:"PAWS - συντήρηση: μείον κενές γραμμές στις Μεταφράσεις"


Template|param + empty line + Template:(( which starts the next line as in
{{μτφ-αρχή|blahblah}}

{{((}}
as above.
CAREFUL: symbol ( has special meaning in regex. We need to put \ before it, if needed as simple text

This is the command: (repeat at dumps)

pwb.py replace -ns:0 -regex -lang:el -family:wiktionary -cat:"Νέα ελληνικά" "({{μτφ-αρχή[^}]+}})\n({{\(\(}})" "\1\n" -summary:"PAWS - συντήρηση: μείον κενές γραμμές στις Μεταφράσεις"

Replace empty line after Template no param

[επεξεργασία]

Example: at Translations section

Replace empty lines at

===={{μεταφράσεις}}====
-- erase this line
{{μτφ-αρχή}}
-- erase this line
* {{en}}: ...... etc
-- erase this line
{{μτφ-μέση}}
-- erase this line
{{μτφ-τέλος}}

Command: do with -- > and without

1)
pwb.py replace -regex -lang:el -family:wiktionary -ns:0 -cat:"Νέα ελληνικά" "===={{μεταφράσεις}}====\n\n"   "===={{μεταφράσεις}}====\n" "{{μτφ-αρχή}}\n\n"   "{{μτφ-αρχή}}\n"  "\n\n{{μτφ-μέση}}" "\n{{μτφ-μέση}}" "\n\n{{μτφ-τέλος}}" "\n{{μτφ-τέλος}}"  -summary:"PAWS - συντήρηση: μείον κενές γραμμές στις Μεταφράσεις"

2)
pwb.py replace -regex -lang:el -family:wiktionary -ns:0 -cat:"Νέα ελληνικά" "{{μτφ-αρχή}}\n\n" "{{μτφ-αρχή}}\n"  "-->\n\n{{μτφ-μέση}}" "-->\n{{μτφ-μέση}}"  "-->\n\n{{μτφ-τέλος}}" "-->\n{{μτφ-τέλος}}"  -summary:"PAWS - συντήρηση: μείον κενές γραμμές στις Μεταφράσεις"

Replace phrase + any character

[επεξεργασία]
NOTE: -regex creates problems, skip it

replace phrase + any character + continue the phrase. e.g.

replace "{ grc-β-κλισ-σοφός|BLAHBLAHBLABLAH} " with "{ grc-κλίση-'καλός'} "

Our good friend Botaki writes:

pwb.py replace -regex -lang:el -family:wiktionary -cat:"Επίθετα (αρχαία ελληνικά)" "{{grc-β-κλισ-σοφός[^}]+}}" "{{grc-κλίση-'καλός'}}" -summary:"pwb.py {{grc-κλίση-'καλός'}}"
[^}]     means: any character which is NOT a curly bracket }
+     means: get a sequence with 1 character at least.

And to make sure it works if a vertical pipe | does not exist, use an asterisc:

pwb.py replace -lang:el -family:wiktionary -cat:"Επίθετα (αρχαία ελληνικά)" -regex "{{grc-β-κλισ-σοφός[^}]*}}" "{{grc-κλίση-'καλός'}}" -summary:"pwb.py {{grc-κλίση-'καλός'}}"

Thank you Botaki!!! 2021.07.16. Sarri.greek.

Replace within a template

[επεξεργασία]

1) σωστό σύμβολο τόνου   ˈ   και όχι απλή τυπογραφική απόστροφος   '

  • !! Προσοχή να μην σβήνονται σύμβολα για πλάγια ή έντοντα γράμματα αν υπάρχουν ΜΕΣΑ στο {{ΔΦΑ}}
pwb.py replace -regex -lang:el -family:wiktionary -ns:0 -xml:/public/dumps/public/elwiktionary/latest/elwiktionary-latest-pages-articles-multistream.xml.bz2 "({{ΔΦΑ[^}]+)'([^}]*}})" "\1ˈ\2"  -summary:"pwb.py ΔΦΑ (ipa) update correct accent"

2) Αλλαγή του τελεία + τόνος. Μόνον ο τόνος είναι απαραίτητος (σημαίνει, αλλαγή συλλαβής). Δεν γράφουμε, και τελεία, και τόνο.

pwb.py replace -regex -lang:el -family:wiktionary -ns:0 -xml:/public/dumps/public/elwiktionary/latest/elwiktionary-latest-pages-articles-multistream.xml.bz2 "({{ΔΦΑ[^}]+)\.ˈ([^}]*}})" "\1ˈ\2"  -summary:"pwb.py ΔΦΑ (ipa) update, not dot+accent"


No brackets μέσα στο ΔΦΑ [] // Χρειάζεται escape me \[ \] \/ (δυο φορές η πλαγιοκάθετη: πιάνει και το πρώτο και το δεύητερο)

pwb.py replace -regex -lang:el -family:wiktionary -ns:0 -xml:/public/dumps/public/elwiktionary/latest/elwiktionary-latest-pages-articles-multistream.xml.bz2 "({{ΔΦΑ[^}]+)\/([^}]*}})" "\1\2" "({{ΔΦΑ[^}]+)\/([^}]*}})" "\1\2" "({{ΔΦΑ[^}]+)\[([^}]*}})" "\1\2" "({{ΔΦΑ[^}]+)\]([^}]*}})" "\1\2" -summary:"pwb.py ΔΦΑ (ipa) delete internal brackets"

Αλλαγές συμβόλων: Τα σωστά σύμβολα που ισχύουν για όλες τις γλώσσες

  • t͡s παλιά ʦ ή ts
  • d͡z παλιά ʣ ή dz
  • t͡ʃ παλιά t͜ʃ ή tʃ
  • d͡ʒ παλιά ʤ
  • ɡ (σύμβολο ipa και όχι το λατινικό g)

New symbols /t͡s/ και /d͡z/ and /t͡ʃ/ και /d͡ʒ/: cf. new rules

  • with ⟨t͡s⟩ or ⟨t͜s⟩ (formerly with ⟨ʦ⟩ or ⟨ƾ⟩)
  • with ⟨d͡z⟩ or ⟨d͜z⟩ (formerly ⟨ʣ⟩)
  • with ⟨t͡ʃ⟩, ⟨t͜ʃ⟩ or ⟨tʃ⟩ (formerly the ligature ⟨ʧ⟩).
  • with ⟨d͡ʒ⟩ (formerly the ligature ⟨ʤ⟩)
pwb.py replace -regex -lang:el -family:wiktionary -ns:0 -xml:/public/dumps/public/elwiktionary/latest/elwiktionary-latest-pages-articles-multistream.xml.bz2 "({{ΔΦΑ[^}]+)ʣ([^}]*}})" "\1d͡z\2" "({{ΔΦΑ[^}]+)ʤ([^}]*}})" "\1d͡ʒ\2" "({{ΔΦΑ[^}]+)ʦ([^}]*}})" "\1t͡s\2" "({{ΔΦΑ[^}]+)ʧ([^}]*}})" "\1t͡ʃ\2"  -summary:"pwb.py ΔΦΑ (ipa) replace depracated symbols, ligatures [[Βικιλεξικό:Οδηγός_προφοράς#Αναφορές|cf. new rules]] - απαρχαιωμένα σύμβολα"

το ειδικό ɡ όχι g

pwb.py replace -regex -lang:el -family:wiktionary -ns:0 -xml:/public/dumps/public/elwiktionary/latest/elwiktionary-latest-pages-articles-multistream.xml.bz2 "({{ΔΦΑ[^}]+)g([^}]*}})" "\1ɡ\2"  -summary:"pwb.py ΔΦΑ (ipa) update σύμβολο ɡ"

μαζί και τα δύο:

pwb.py replace -regex -lang:el -family:wiktionary -ns:0 -xml:/public/dumps/public/elwiktionary/latest/elwiktionary-latest-pages-articles-multistream.xml.bz2 "({{ΔΦΑ[^}]+)g([^}]*}})" "\1ɡ\2" "({{ΔΦΑ[^}]+)ʣ([^}]*}})" "\1d͡z\2" "({{ΔΦΑ[^}]+)ʤ([^}]*}})" "\1d͡ʒ\2" "({{ΔΦΑ[^}]+)ʦ([^}]*}})" "\1t͡s\2" "({{ΔΦΑ[^}]+)ʧ([^}]*}})" "\1t͡ʃ\2"  -summary:"pwb.py ΔΦΑ (ipa) replace depracated symbols, ligatures [[Βικιλεξικό:Οδηγός_προφοράς#Αναφορές|cf. new rules]] & replace the latin g - απαρχαιωμένα σύμβολα"


Swap position within a template

[επεξεργασία]

H παράμετρος |γλ=... πάντα στην πρώτη θέση (τεχνικοί λόγοι)

pwb.py replace -regex -lang:el -family:wiktionary -ns:0 -xml:/public/dumps/public/elwiktionary/latest/elwiktionary-latest-pages-articles-multistream.xml.bz2 "({{ΔΦΑ)\|([^}]+)\|(γλ=[^}]+)}}" "\1|\3|\2}}"  -summary:"pwb.py ΔΦΑ (ipa) update move γλ="

και μόνο για ελληνικά, ώστε 'να δει' και τα πιο πρόσφατα

pwb.py replace -regex -lang:el -family:wiktionary -cat:"Λήμματα με προφορά ΔΦΑ (νέα ελληνικά)" "({{ΔΦΑ)\|([^}]+)\|(γλ=[^}]+)}}" "\1|\3|\2}}"  -summary:"pwb.py ΔΦΑ (ipa) update move γλ="

Replace and swap position

[επεξεργασία]

ρηματικός τύπος

[επεξεργασία]

Κατηγορία:Ρηματικοί τύποι (αγγλικά) όπως abandoned.
Change {{ρημ τύπος|αόριστος και παθητική μετοχή|abandon}}
to {{infl|en|abandon||en-ed}}

pwb.py replace -regex -lang:el -family:wiktionary -cat:"Ρηματικοί τύποι (αγγλικά)" "({{ρημ τύπος)\|(αόριστος και παθητική μετοχή)\|([^}]+)}}" "{{infl|en|\3||en-ed}}"  -summary:"pwb.py update English forms -ed"

Note, that regex, escape characters etc are used at the REPLACED.sequenct, NOT at the result.sequence

[^}] means: any character which is NOT a curly bracket }
[^}\]] means: any character which is NOT a curly bracket } and NOT a bracket ]
I cannot write }] because the ] is a special character: I must put \ in front of it (escape character)
+ means: get a sequence with 1 character at least.
pwb.py replace -regex -lang:el -family:wiktionary -ns:0 -xml:/public/dumps/public/elwiktionary/latest/elwiktionary-latest-pages-articles-multistream.xml.bz2 "({{μτφδ}}\s{{ετυμ fr}}\s\[\[)([^}\]]+)(\]\])" "{{μτφδ|fr|el|\2|text=1}}"  -summary:"pwb.py Συντήρηση - auto replace {ετυμ fr}"

I am at https://paws.wmflabs.org/paws/user/Sarri.greek/tree

  • 1) Choose 'New'. A list pops up. Choose 'Text file'
  • 2) now, I am at https://paws.wmflabs.org/paws/user/Sarri.greek/edit/untitled.txt
  • 3) I write codes here for specific tasks. For #Replaceing I do not need this.
  • 4) click 'File' > choose 'Rename'
    e.g. test01.txt https://paws.wmflabs.org/paws/user/Sarri.greek/edit/test01.txt
  • 5) click 'File' > choose 'Save'
    Now i can see it under 'Files' at my notebook

https://www.mediawiki.org/wiki/Talk:Phabricator/Help

Now, I am at https://paws.wmflabs.org/paws/user/Sarri.greek/tree

Since 2022 there is A NEW SCREEN. Go to HELP and click Launch Classic Notebook

Choose New > Terminal

It says

Welcome to PAWS!
Please behave responsibly
Getting Started: https://www.mediawiki.org/wiki/Manual:Pywikibot/PAWS
Questions? Need help? Find us on #wikimedia-cloud on IRC on freenode!
File bugs at https://phabricator.wikimedia.org/maniphest/task/create/?projects=PAWS
@PAWS:~$
  • 3) copy my code, and
  • 4) click Enter

IF i write nothing at the black screen, I just exit this window:

  • From central page, go to 'Running'. I see all my unused 'Terminal1', 'Terminal2' etc. Click the button 'Shutdown' to get rid of them.

Click letters

[επεξεργασία]

After clicking Enter at a code, you get each occurunce, with choices: [y]es [q]uit, etc: press the key in the bracket (e.g. y) + Enter, the key q + Enter... etc.

  • [q]uit, it quits (as though you have pressed CTRL+C, but in a more final way)
  • [N]no, it skips this occurance, and procedes to the next one
  • [e]dit, ...
  • [y]es, yes, do the changes and procede to the next one

Careful:

  • [a]ll, does them all! one after the other. We do not click it unless having tried yes, several times

Code commands

[επεξεργασία]

Start the code at the black screen after @PAWS:~$ There is a blinking little square

  • pwb.py   = I start with this
  • what to do
    replace   = (our command: replace the first of the pairts I'm going to write)
  • -lang:el   = at the el(.wiktionary)
  • -family:wiktionary   = or wikipedia or wiki...
  • -ns:0 = only in namespace: main
  • -cat:"Κατηγορία:xxxxx" = only in this Category
  • -titleregex:'^γ.' = when the first letter (^) is γ, followed by any character (.)
  • (optional) -search:"xxxx"   = search for this sequence of characters
  • first pair, if I need to replace:
    "xxxx"   = the sequence to be replaced
    "zzzz"   = the sequence with which we want to replace it
  • I may add more pairs
  • -summary:"pwb.py ...."   = describe the task
  • \n = a line break
  • These characters have special meaning in regex: . + * ? ^ $ ( ) [ ] { } | \
    if command -regex is used, and we wish to write them as text, we need escape character \ before them

Note, that regex, escape characters etc are used at the REPLACED.sequenct, NOT at the result.sequence

[^}] means: any character which is NOT a curly bracket }
[^}\]] means: any character which is NOT a curly bracket } and NOT a bracket ]
I cannot write }] because the ] is a special character: I must put \ in front of it (escape character)
+ means: get a sequence with 1 character at least.
  • Do not leave too many spaces between the commands
  • -pt:1 does everything in ONE second -must make trials first, then use with caution-. If something goes wrong, press CTRL+C (says my teacher, FocalPoint)
  • summary: If by accident "zzzz"-summary are joined together, you will get a note about your summary
  • use english keyboard to click letters
  • PROBLEM with search and replace: if weird little diacritics are in the replace, things go wrong

Good ideas:

  • add -ns:0 (namespace: main) if you do not wish to interfere with other pages. May check them later, manually.
  • only in a specific category: instead of -xml:/public/dumps/...xml.bz2 I write: -cat:"Category in greek ωωω"

See User:Sarri.greek/PAWS/done

  • NOTE: the 'search' command MAY NOT WORK. Try (Thank you Botaki for help!)
pwb.py replace -lang:el -family:wiktionary -xml:/public/dumps/public/elwiktionary/latest/elwiktionary-latest-pages-articles-multistream.xml.bz2 "κλίσ-'πρόβατο" "κλίση-'βούτυρο" -summary:"pwb.py replace κλίση πρόβατο = βούτυρο"
  • 3b) NOT BEST WAY Now, e.g. I write next to that @PAWS:~$
    @PAWS:~$ pwb.py replace -lang:el -family:wiktionary -search:"Β:Χρηστικό" "Β:Χρηστικό" "Π:Χρηστικό" -summary:"pwb.py replace αντικατάσταση"
    pwb.py   = ...
    replace   = (our command: replace the first of the pairts I'm going to write)
    -lang:el   = at the el(.wiktionary)
    -family:wiktionary   = or wikipedia or wiki...
    -search:"xxxx"   = search for this sequence of characters
    "xxxx"   = the sequence to be replaced
    "zzzz"   = the sequence with which we want to replace it
  • I may add more pairs
  • 4) Now, I click Enter and Here is what i get:
Welcome to PAWS!
Please behave responsibly
Getting Started: https://www.mediawiki.org/wiki/Manual:Pywikibot/PAWS
Questions? Need help? Find us on #wikimedia-cloud on IRC on freenode!
File bugs at https://phabricator.wikimedia.org/maniphest/task/create/?projects=PAWS
@PAWS:~$ pwb.py replace -lang:el -family:wiktionary -search:"Β:Χρηστικό" "Β:Χρηστικό" "Π:Χρηστικό" -summary:"pwb.py replace αντικατάσταση Β: σε Π:"
Retrieving 50 pages from wiktionary:el.
No changes were necessary in [[bonaccia]]
No changes were necessary in [[Σκοτία]]
No changes were necessary in [[Σκότος]]
No changes were necessary in [[Συντροφία]]
No changes were necessary in [[αίμα]]
No changes were necessary in [[ανοίγω]]
No changes were necessary in [[αντικατασκοπία]]

>>> αρόδο <<<
@@ -4 +4 @@
- : '''{{PAGENAME}}''' < {{δαν|vec|el}} [[a]] [[roda]]<ref>{{Β:Γεωργακάς}}</ref> <ref name=Babi>{{Β:Μπαμπινιώτης 2002}}</ref> ή [[arodo]]<ref>{{Β:Χρηστικό}}</ref> <ref>{{Β:ΛΚΝ}}</ref> <ref>ή {{ετυμ|oc|el|arròda}} < {{ετυμ|la|el|rota}}</ref>
+ : '''{{PAGENAME}}''' < {{δαν|vec|el}} [[a]] [[roda]]<ref>{{Β:Γεωργακάς}}</ref> <ref name=Babi>{{Β:Μπαμπινιώτης 2002}}</ref> ή [[arodo]]<ref>{{Π:Χρηστικό}}</ref> <ref>{{Β:ΛΚΝ}}</ref> <ref>ή {{ετυμ|oc|el|arròda}} < {{ετυμ|la|el|rota}}</ref>

Do you want to accept these changes? ([y]es, [N]o, [e]dit original, edit
[l]atest, open in [b]rowser, [m]ore context, [a]ll, [q]uit):
  • 5) I agree, i click y and Enter, to procede
    or, I do not agree and press N and Enter, to procede
    Do not go fast: WAIT for the change to be viewed at the 'Recent changes' and then, go on.
  • 6) bugs
    • do not leave long spaces before -summary or between other expressions.
  • 7) When finished: I go to 'Running' and delete (shutdown)
  • 8) go back to home and start again

Replace in one Category

[επεξεργασία]

help: https://www.mediawiki.org/wiki/Manual:Pywikibot/replace.py

  • cat - work on all pages (not categories) which are in a specific category. Argument can also be given as "-cat:categoryname".
  • for beginners to limit the work to the main namespace with -ns:0
  • -titleregex:'^γ.' = when the first letter (^) is γ, followed by any character (.)


These help pages have no simple examples:

Learn more

  • Search google for: regex pcre