Git Product home page Git Product logo

presque's Introduction

presque

normalisation de mots français pour spacy.

x y
chuuuuut!!!!! chut!
bateâu bateau
HO ho
PEùùùT-èTRE peut-être
auteur-rice-x-s auteur·ricexs
peut—être peut-être
autre[ment] autrement
désœuvrement désoeuvrement
  • les caractères répétés plus de 3x (2 pour la ponctuation) sont réduits à un seul (sauf "...").
  • les mots hors-lexiques sont remplacés par une version accentuée différemment, si une telle version existe.
  • les mots sont mis en minuscules.
  • les mots composés sont normalisés par l'agrégation de leurs composants, normalisés individuellement.
  • les variantes d'écritures inclusives sont uniformisées (caractère de séparation, nombre de caractères, ordre des suffixes).
  • les parenthèses et crochets sont enlevés.
  • les variantes de tirets (et d'apostrophes) remplacées par des tirets (ou apostrophes) simples (droites).

usage

pour l'utiliser comme composant d'une pipeline spacy:

import spacy

nlp = spacy.load("fr_core_news_lg")
nlp.add_pipe('presque_normalizer', first=True)

[i.norm_ for i in nlp("QUOOOIIIIII PEUUUUUT---ÉÉÉtréééééé")]
[quoi, peut-être]

it has to_disk() and from_disk() methods:

nlp.to_disk("./model_output")

configuration

import spacy

def aggregate_suffixes(word: str, suffixes: list, char: str) -> str:
    return word + char + char.join(map(str.upper, suffixes))

config = dict(
    name="normalizer",
    exc={"clef": "clé", "ptetre": "peut-être"},
    words_files=["./exemple/liste/de/mots/specifique.txt"],
    use_default_word_list=False,
    suff_sep_char="-",
    fn_agg_suff=aggregate_suffixes,
)

nlp = spacy.load("fr_core_news_lg")
nlp.add_pipe("presque_normalizer", first=True, config=config)

installation

git clone https://github.com/thjbdvlt/presque presque
cd presque
pip install .

dépendances

presque's People

Contributors

thjbdvlt avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.