Skip to main content

PosLog: A CRF-based Part-of-Speech Tagger for Log Messages

Project description

PosLog

A CRF-based Part-of-Speech (POS) Tagger for Log Messages.

Usage

  • Use default model

    from poslog import PosLogTokenizer, PosLogCRF
    
    tokenizer=PosLogTokenizer()
    s="Tag this sentence."
    tokens=tokenizer.tokenize(s)
    # ['Tag', 'this', 'sentence', '.']
    
    pos_log=PosLogCRF()
    pos_log.predict(tokens)
    # ['VERB' 'DET' 'NOUN' 'PUNCT']
    
  • Train your own model
    Define model name in constructor:

    pos_log=PosLogCRF(model_name="abs_path_to_my_model")
    

    You can give abs_path_to_my_model as absolute path or relative path.
    Note: Relative paths models will stored in package directory models/ and will be overwritten if you renew the environment.

    PosLog takes training data as tokens and tags separately:

    train(X_train_tokens:list[list[str]], y_train_tags:list[list[str]])
    

    Or as token and tag pairs:

    train_from_tagged_sents(tagged_sents:list[list[tuple[str,str]]])
    

    After training, the model will be saved in the path you provided in the constructor.
    Note: Training will override existing model with the same name.

  • Use your own model
    Just call the constructor with the model name:

    pos_log=PosLogCRF(model_name="my_model")
    

Dependencies

PosLog relies on

  • nltk corpora: words, stopwords, wordnet and
  • sklearn for the CRF classifier sklearn-crfsuite.

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

poslog-0.5.tar.gz (459.2 kB view details)

Uploaded Source

Built Distribution

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

poslog-0.5-py3-none-any.whl (457.4 kB view details)

Uploaded Python 3

File details

Details for the file poslog-0.5.tar.gz.

File metadata

  • Download URL: poslog-0.5.tar.gz
  • Upload date:
  • Size: 459.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for poslog-0.5.tar.gz
Algorithm Hash digest
SHA256 8b10473262e8ec67cb285818d3954c79970dbf0439e7cf7f5a3aaca55914e21e
MD5 799bbe6adc1320aeec9f77a36748fcbd
BLAKE2b-256 ef2284e415a3fd8824ef343b75d88c21392a1cf16cb4acc71f71625ff6701b3c

See more details on using hashes here.

File details

Details for the file poslog-0.5-py3-none-any.whl.

File metadata

  • Download URL: poslog-0.5-py3-none-any.whl
  • Upload date:
  • Size: 457.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for poslog-0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 88eaef98afc5007c1cd602d475647e80f35e2c7bd8655c63acee837d2240ec67
MD5 90e7f58aa3d82479de6ac2be14343f09
BLAKE2b-256 275d14f5146835f14ca18c13a3c5009f7d2eedb757c156afd2c0cd5d9f9f8b79

See more details on using hashes here.

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