Skip to main content

POSNoise

POSNoise: An Effective Countermeasure Against Topic Biases in Authorship Analysis

Description

POSNoise is a preprocessing method that systematically masks topic-related content from text documents. The motivation for this becomes clear when we take a closer look at the field of authorship analysis, particularly Authorship Attribution (AA) and Authorship Verification (AV).

AA is concerned with determining which of several possible authors wrote a particular anonymous text. AV, on the other hand, deals with the so-called fundamental problem of whether two documents were written by the same person. To accomplish both tasks, we rely on the assumption that every person has his or her own writing style, which differs to a certain extent from the writing styles of other people. This is exactly where the topic can pose a serious challenge.

Consider for example the following scenario: D1 and D2 represent two documents that deal with the same topic but were written by two different people. An AV method (which aims to answer the question of whether two documents were written by the same author) could mistakenly conclude that D1 and D2 were written by the same author, as both documents are very similar in terms of topic. However, the goal of AA and AV is not to predict whether authorship is the same or different based on the topic, but rather based on the actual writing style.

To prevent AA and AV methods from focusing on the topic and instead force them to concentrate on linguistic patterns such as function words or punctuation marks (which are closely related to writing style), topic masking approaches can be used, where POSNoise is one such approach...

POSNoise in a Nutshell

POSNoise in a nutshell...


The L_TA pattern list...


The placeholder POStag list...

Installation

The easiest way to install POSNoise is to use pip, where you can choose between (1) the PyPI repository and (2) this repository.

  • (1) pip install posnoise

  • (2) pip install git+https://github.com/Halvani/POSNoise.git

The latter will pull and install the latest commit from this repository as well as the required Python dependencies.

Quickstart

import posnoise
from posnoise import POSNoise
from posnoise.core import SpacyLanguage, SpacyModelSize

# English
posnoise_en = POSNoise()  # Note, by default POSNoise loads the "Large" spaCy model

# In case you want specify another model size, just set it accordingly e.g. 
# posnoise_en = POSNoise(spacy_model_size=posnoise.core.SpacyModelSize.Medium)

# German
posnoise_de = POSNoise(language=SpacyLanguage.German)

text_en = "The original dataset contains two partitions comprising sockpuppets and non-sockpuppets cases."
text_de = "Schöneberg ist ein Ortsteil im Berliner Bezirk Tempelhof-Schöneberg."

print(posnoise_en.pos_noise(text_en))
# The @ # Ø two # Ø # and @@@ #.

print(posnoise_de.pos_noise(text_de))
# § ist ein # im @ # §.

All part-of-speech (POS) placeholders used in POSNoise to replace topic-related words or tokens are listed below:

Category Tag Examples
Noun # { house, music, bird, tree, air, … }
Proper noun § { David, Vivien, London, USA, COVID-19, … }
Verb Ø { eat, laugh, dance, travel, hiking, … }
Adjective @ { red, shiny, fascinating, phenomenal, … }
Adverb © { financially, foolishly, angrily, … }
Numeral μ { 0, 5, 2013, 3.14159, III, IV, MMXIV, … }
Symbol $ { £, ©, §, %, #, … }
Other ¥ { xfgh, pdl, jklw, … }

Source: POSNoise: An Effective Countermeasure Against Topic Biases in Authorship Analysis ➜ Table 2.

Features

  • Effective way to mask topic-related content with custom POS placeholders
  • Multilingual support (currently available in English and German)
  • Automatic NLP pipeline creation (loads and installs the spaCy models on demand, while providing installation feedback)
  • No API dependency (after downloading the spaCy models, POSNoise can be used completely offline)
  • Documented source code

Citation

If you find this library helpful, please invest a few minutes and cite it in your paper/project:

@inproceedings{HalvaniGranerPOSNoise:2021,
  author       = {Oren Halvani and Lukas Graner},
  editor       = {Delphine Reinhardt and Tilo M{\"{u}}ller},
  title        = {{POSNoise: An Effective Countermeasure Against Topic Biases in Authorship Analysis}},
  booktitle    = {{ARES} 2021: The 16th International Conference on Availability, Reliability and Security, Vienna, Austria, August 17-20, 2021},
  pages        = {47:1--47:12},
  publisher    = {{ACM}},
  year         = {2021},
  url          = {https://doi.org/10.1145/3465481.3470050},
  doi          = {10.1145/3465481.3470050},
  timestamp    = {Sun, 04 Aug 2024 19:40:49 +0200},
  biburl       = {https://dblp.org/rec/conf/IEEEares/HalvaniG21.bib},
  bibsource    = {dblp computer science bibliography, https://dblp.org}
}

License

The POSNoise package is released under the Apache-2.0 license. See LICENSE for further details.

Last Remarks

As is usual with open source projects, we developers do not earn any money with what we do, but are primarily interested in giving something back to the community with fun, passion and joy. Nevertheless, we would be very happy if you rewarded all the time that has gone into the project with just a small star 🤗

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

posnoise-0.0.4.tar.gz (69.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

posnoise-0.0.4-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file posnoise-0.0.4.tar.gz.

File metadata

  • Download URL: posnoise-0.0.4.tar.gz
  • Upload date:
  • Size: 69.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for posnoise-0.0.4.tar.gz
Algorithm Hash digest
SHA256 fcb866a7371f441c9bfc6c3cfcdc0c3f3bacd394ffa8de303fc20af4c5732bf3
MD5 d26e9f9c88a41ad266368469d85c799f
BLAKE2b-256 bfdfaa8e4bb226cc3ce3fca520af448c16ae99718d7c665d7dd9c671b3359022

See more details on using hashes here.

Provenance

The following attestation bundles were made for posnoise-0.0.4.tar.gz:

Publisher: python-publish.yml on Halvani/POSNoise

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file posnoise-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: posnoise-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for posnoise-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a2d8767721879a8b3561d49d024bd3ea1618979c3cb16fa2d9c58c3ee36b9829
MD5 2dfa9ff7e6552cd4940081ee882d8693
BLAKE2b-256 5c7913289ce8383509b036b14a233708b63b542f918ef1371c1fb8e07d81c67f

See more details on using hashes here.

Provenance

The following attestation bundles were made for posnoise-0.0.4-py3-none-any.whl:

Publisher: python-publish.yml on Halvani/POSNoise

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page