Created
February 27, 2020 01:44
-
-
Save galtay/0c637f56af05239aa2619c0f172fc8cd to your computer and use it in GitHub Desktop.
Parsing albedo wikitext markup with mwtext
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mwtext | |
albedo_wikitext = """ | |
{{Other uses}} | |
{{Use dmy dates|date=April 2019}} | |
[[File:Albedo-e hg.svg|thumb|upright=1.3|The percentage of [[diffuse reflection|diffusely reflected]] [[sunlight]] re\ | |
lative to various surface conditions]] | |
'''Albedo''' ({{IPAc-en|æ|l|ˈ|b|iː|d|oʊ}}) ({{lang-la|albedo}}, meaning 'whiteness') is the measure of the [[diffuse \ | |
reflection]] of [[sunlight|solar radiation]] out of the total [[solar radiation]] received by an [[astronomical body]\ | |
] (e.g. a [[planet]] like [[Earth]]). It is [[dimensionless number|dimensionless]] and measured on a scale from 0 (co\ | |
rresponding to a [[black body]] that absorbs all incident radiation) to 1 (corresponding to a body that reflects all \ | |
incident radiation). | |
""" | |
forbidden_link_prefixes = ["File"] | |
wikitext_preprocessor = mwtext.WikitextPreprocessor(forbidden_link_prefixes) | |
for line in wikitext_preprocessor.process(albedo_wikitext): | |
print(line) | |
break | |
""" | |
Output | |
In [5]: run -i albedo_parse_example.py | |
['sunlight', 'relative', 'to', 'various', 'surface', 'conditions'] | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment