Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_max():
max_five_six_seven = modifiers.max(5, 6, 7)
assert solve(max_five_six_seven) == 7
assert solve(pickle.loads(pickle.dumps(max_five_six_seven))) == 7
assert repr(max_five_six_seven) == ""
r"harvtxt",
r"Harvcoltxt",
r"Harvcol",
r"Harvcolnb",
r"Harvard citations", r"harvs",
r"Harvp"
]
cite_templates = wikitext.revision.template_names_matching(
"|".join(CITE_TEMPLATES), name="ptwiki.revision.cite_templates")
shortened_footnote_templates = wikitext.revision.template_names_matching(
r"sfn", name="ptwiki.revision.shortened_footnote_templates")
all_ref_tags = shortened_footnote_templates + wikitext.revision.ref_tags
all_cite_templates = cite_templates + shortened_footnote_templates
proportion_of_templated_references = \
all_cite_templates / max(all_ref_tags, 1)
non_templated_references = max(all_ref_tags - all_cite_templates, 0)
non_cite_templates = sub(
wikitext.revision.templates, all_cite_templates,
name="ptwiki.revision.non_cite_templates"
)
# Links
category_links = wikitext.revision.wikilink_titles_matching(
r"(Category|Categoria)\s*\:", name="ptwiki.revision.category_links")
image_links = wikitext.revision.wikilink_titles_matching(
r"(File|Ficheiro|Arquivo|Imagem?)\s*\:",
name="ptwiki.revision.image_links")
image_templates = wikitext.revision.template_names_matching(
r"(Scalable[ _]image|Panorama|Imagem[ _]vertical|Panorama|Panorama 2)",
name='ptwiki.revision.image_template')
is_blp = has_birthday.and_(not_(dead))
local_wiki = [
is_human,
is_blp,
aggregators.len(complete_translations),
aggregators.len(important_label_translations),
aggregators.len(important_description_translations),
aggregators.len(important_complete_translations),
references_count,
wikimedia_references_count,
wikimedia_references_count / modifiers.max(references_count, 1),
external_references_count,
external_references_count / modifiers.max(references_count, 1),
unique_references_count,
unique_references_count / modifiers.max(references_count, 1)
]
item_quality = wikibase.item + local_wiki
"""
Turkish Wikipedia
+++++++++++++++++
"""
from revscoring.features import wikitext
from revscoring.features.modifiers import max, sub
from . import wikipedia
cite_templates = wikitext.revision.template_names_matching(
r"Kaynak|.*[ _]kaynağı",
name="trwiki.revision.cite_templates")
proportion_of_templated_references = \
cite_templates / max(wikitext.revision.ref_tags, 1)
non_templated_references = max(wikitext.revision.ref_tags - cite_templates, 0)
non_cite_templates = sub(
wikitext.revision.templates, cite_templates,
name="trwiki.revision.non_cite_templates"
)
infobox_templates = wikitext.revision.template_names_matching(
r".*[ _]bilgi[ _]kutusu",
name="trwiki.revision.infobox_templates")
# Copied (2015-10-29) from:
# https://fr.wikipedia.org/wiki/Wikip%C3%A9dia:Citez_vos_sources#R.C3.A9clamation_et_contestation_de_sources
cn_templates = wikitext.revision.template_names_matching(
r"Kaynak[ _]belirt|Olgu|Fact|Delil",
name="trwiki.revision.lvl1_cn_templates")
main_article_templates = wikitext.revision.template_names_matching(
r"Ana|Anamadde",
added in this edit.
:Returns:
float
:Example:
..code-block:: python
>>> from revscoring.features import diff
>>> list(extractor.extract(
655097130, [diff.proportion_of_symbolic_chars_added]))
[0.06734006734006734]
"""
added_symbolic_chars_ratio = \
proportion_of_symbolic_chars_added / \
modifiers.max(parent_revision.proportion_of_symbolic_chars, 0.001)
"""
Represents ratio of added symbolic characters in this edit compared to added
symbolic characters in the last edit.
:Returns:
float
:Example:
..code-block:: python
>>> from revscoring.features import parent_revision
>>> list(extractor.extract(655097130,
[diff.added_symbolic_chars_ratio]))
[0.6290819445604794]
"""
from revscoring.features import wikitext, modifiers
article = [
wikitext.revision.chars,
wikitext.revision.content_chars,
wikitext.revision.ref_tags,
(wikitext.revision.ref_tags /
modifiers.max(wikitext.revision.content_chars, 1)),
wikitext.revision.wikilinks,
(wikitext.revision.wikilinks /
modifiers.max(wikitext.revision.content_chars, 1)),
wikitext.revision.external_links,
(wikitext.revision.external_links /
modifiers.max(wikitext.revision.content_chars, 1)),
wikitext.revision.headings_by_level(2),
(wikitext.revision.headings_by_level(2) /
modifiers.max(wikitext.revision.content_chars, 1)),
wikitext.revision.headings_by_level(3),
(wikitext.revision.headings_by_level(3) /
modifiers.max(wikitext.revision.content_chars, 1))
]
r"Harvard[_ ]citation", r"harv",
r"harvtxt",
r"Harvcoltxt",
r"Harvcol",
r"Harvcolnb",
r"Harvard citations", r"harvs",
r"Harvp"
]
cite_templates = wikitext.revision.template_names_matching(
"|".join(CITE_TEMPLATES), name="ptwiki.revision.cite_templates")
shortened_footnote_templates = wikitext.revision.template_names_matching(
r"sfn", name="ptwiki.revision.shortened_footnote_templates")
all_ref_tags = shortened_footnote_templates + wikitext.revision.ref_tags
all_cite_templates = cite_templates + shortened_footnote_templates
proportion_of_templated_references = \
all_cite_templates / max(all_ref_tags, 1)
non_templated_references = max(all_ref_tags - all_cite_templates, 0)
non_cite_templates = sub(
wikitext.revision.templates, all_cite_templates,
name="ptwiki.revision.non_cite_templates"
)
# Links
category_links = wikitext.revision.wikilink_titles_matching(
r"(Category|Categoria)\s*\:", name="ptwiki.revision.category_links")
image_links = wikitext.revision.wikilink_titles_matching(
r"(File|Ficheiro|Arquivo|Imagem?)\s*\:",
name="ptwiki.revision.image_links")
image_templates = wikitext.revision.template_names_matching(
r"(Scalable[ _]image|Panorama|Imagem[ _]vertical|Panorama|Panorama 2)",
French Wikisource
+++++++++++++++++
"""
from revscoring.features import wikitext
from revscoring.features.modifiers import max
from revscoring.languages import french
from . import wikisource
local_wiki = [
wikitext.revision.chars,
french.stemmed.revision.stem_chars,
(french.stemmed.revision.stem_chars /
max(wikitext.revision.chars, 1)),
french.dictionary.revision.dict_words / max(wikitext.revision.words, 1),
french.dictionary.revision.dict_words /
max(french.dictionary.revision.non_dict_words, 1)
]
pagelevel = local_wiki + wikisource.page
infobox_templates,
cn_templates + 1,
cn_templates / max(wikitext.revision.content_chars, 1),
who_templates + 1,
who_templates / max(wikitext.revision.content_chars, 1),
main_article_templates,
main_article_templates / max(wikitext.revision.content_chars, 1),
(english.stemmed.revision.stem_chars /
max(wikitext.revision.content_chars, 1)),
log(paragraphs_without_refs_total_length + 1),
words_to_watch_count,
words_to_watch_count / max(wikitext.revision.words, 1),
idioms_count,
idioms_count / max(wikitext.revision.words, 1),
words_to_watch_count + idioms_count,
(words_to_watch_count + idioms_count) / max(wikitext.revision.words, 1)
]
wp10 = wikipedia.article + local_wiki
"""
Based largely on work by Morten Warncke-Wang et al.[1] and with a few
# Copied (2015-10-29) from:
# https://fr.wikipedia.org/wiki/Cat%C3%A9gorie:Mod%C3%A8le_pour_bibliographie
CITE_TEMPLATES = [
r"Article",
r"Chapitre",
r"Jugement",
r"Lien[ _]web",
r"Loi",
r"Ouvrage"
]
cite_templates = wikitext.revision.template_names_matching(
"|".join(CITE_TEMPLATES),
name="frwiki.revision.cite_templates")
proportion_of_templated_references = \
cite_templates / max(wikitext.revision.ref_tags, 1)
non_templated_references = max(wikitext.revision.ref_tags - cite_templates, 0)
non_cite_templates = sub(
wikitext.revision.templates, cite_templates,
name="frwiki.revision.non_cite_templates"
)
infobox_templates = wikitext.revision.template_names_matching(
r"^infobox",
name="frwiki.revision.infobox_templates")
# Copied (2015-10-29) from:
# https://fr.wikipedia.org/wiki/Wikip%C3%A9dia:Citez_vos_sources#R.C3.A9clamation_et_contestation_de_sources
LVL1_CN_TEMPLATES = [r"Référence[ _]souhaitée", r"Citation[ _]nécessaire",
r"Référence[ _]à[ _]confirmer",
r"Référence[ _]nécessaire", r"Inédit"]
lvl1_cn_templates = wikitext.revision.template_names_matching(
"|".join(LVL1_CN_TEMPLATES),