Skip to main content

POSNoise: An Effective Countermeasure Against Topic Biases in Authorship Analysis

Project description

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...

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

from posnoise import POSNoise

# By default POSNoise loads the "Large" spaCy model
posnoise_instance = POSNoise()
    
# In case you want specify another model, just set it accordingly e.g. 
# posnoise_instance = POSNoise(spacy_model_size=posnoise.core.SpacyModelSize.Medium)

document = "Fitzgerald made her first tour of Australia in July 1954 for the Australian-based American promoter Lee Gordon."
posnoised_doc = posnoise_instance.pos_noise(document)

print(document)
# Fitzgerald made her first tour of Australia in July 1954 for the Australian-based American promoter Lee Gordon.

print(posnoised_doc)
# § made her first # of § in § µ for the §-Ø @ # § §.

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-relatd content with custom POS placeholders
  • Automatic NLP pipeline creation (loads and installs the spaCy models on demand, while providing 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 🤗

Project details


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.3.tar.gz (69.1 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.3-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: posnoise-0.0.3.tar.gz
  • Upload date:
  • Size: 69.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for posnoise-0.0.3.tar.gz
Algorithm Hash digest
SHA256 fc4a715569b38224296f36c3f6db6cccbdd32865d0d5abbe3ecab3e88382ebd2
MD5 e28d5c9adffac71dfa89136e35a12d1d
BLAKE2b-256 63aece02de66dfb7f936beae2dfaa5ebc69cca175a76090e297b20120f104ce0

See more details on using hashes here.

Provenance

The following attestation bundles were made for posnoise-0.0.3.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.3-py3-none-any.whl.

File metadata

  • Download URL: posnoise-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for posnoise-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d531a99c4c4437dde85a67311a25a0ba68d4d6d4d96010fbda498e2544a2c433
MD5 6c632b2ee1ec63cbc02dea3ec93014bf
BLAKE2b-256 e7eaf66045c80cc04a7ea4d10ec5a328a588330026eb82e082ea1ef72f6a0c10

See more details on using hashes here.

Provenance

The following attestation bundles were made for posnoise-0.0.3-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.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page