semvec/pypi-packages huggingface dataset:
lrcparser 0.1.2
A simple lyric file parser
Requires Python: >=3.8

# [WIP]lrcparser

A simple lyric file parser.

## Why this parser?

Pros:

- ...
- Well, to be honest, there's no strong reasons.

Cons:

- Lack of tests
- Potential bugs that may screw your files up
- ...

...But if you have tried this library and think it useful...

then just keep using it, thank you for your support :)

## Usage

```lrc
[ti:test_lyric]
[al:TEST ~AVOIDING ERRORS~]
[by:283375]
[offset:250]

[00:00.02]Line 1
[00:00.28]Line 2
[00:02.83]Line 3
[00:28.33]Line 4 with translation | 一般大家都这么打翻译
[00:28.33]可惜我更喜欢换行
[00:28.33]你说得对，但是《lrcparser》是由……
[28:33.75]Line 6
```

```py
from lrcparser import *

with open('example.lrc', 'r', encoding='utf-8') as lrc_file:
    parsed = LrcParser.parse(lrc_file.read(), parse_translations=True)
    offset, lrc_lines, attributes = parsed.values()

>>> offset
250

>>> lrc_lines
[
    LrcLine(
        start_time=LrcTime(0, 0, 20),
        text=LrcText(LrcTextSegment(LrcTime(0, 0, 20), "Line 1")),
        translations=None,
    ),
    LrcLine(
        start_time=LrcTime(0, 0, 280),
        text=LrcText(LrcTextSegment(LrcTime(0, 0, 280), "Line 2")),
        translations=None,
    ),
    LrcLine(
        start_time=LrcTime(0, 2, 830),
        text=LrcText(LrcTextSegment(LrcTime(0, 2, 830), "Line 3")),
        translations=None,
    ),
    LrcLine(
        start_time=LrcTime(0, 28, 330),
        text=LrcText(
            LrcTextSegment(LrcTime(0, 28, 330), "Line 4 with translation")
        ),
        translations=[
            LrcText(LrcTextSegment(LrcTime(0, 28, 330), "一般大家都这么打翻译")),
            LrcText(LrcTextSegment(LrcTime(0, 28, 330), "可惜我更喜欢换行")),
            LrcText(LrcTextSegment(LrcTime(0, 28, 330), "你说得对，但是《lrcparser》是由……")),
        ],
    ),
    LrcLine(
        start_time=LrcTime(28, 33, 750),
        text=LrcText(LrcTextSegment(LrcTime(28, 33, 750), "Line 6")),
        translations=None,
    ),
]

>>> attributes
{
    "ti": "test_lyric",
    "al": "TEST ~AVOIDING ERRORS~",
    "by": "283375",
    "offset": "250",
}
```
spacy-utils 0.0.1
Some basic spaCy utility functions.

# About

This repository houses a series of utility functions for spaCy. I designed these during the course of my work at the Smithsonian Institution and United States Holocaust Memorial Museum.


# Functions

This will serve as the basic docs for the functions found in this repository.

## `count_spans`

spaCy comes built with a `count_by()` method for the Doc container. It can count anything that sits in a the nlp object's vocab. This works for NER because the position of ENT_TYPE is 78 in the nlp.vocab. Span labels, however, are large numbers that cannot be processed via this approach because of how spaCy uses NumPy. This is a naive approach to resolve this issue.

This function takes a Spacy Doc object and a string span_key as input. The span_key argument is used to specify the type of span to count such as "named_entities" or "noun_chunks".

The function then initializes two empty lists, spans and labels. It loops through all the spans of the specified type in the doc object, and for each span, it appends a tuple of (span.text, span.label_) to the spans list, where span.text is the actual text of the span and span.label_ is the label of the span. The function also appends the span.label_ to the labels list.

The function then creates two Counter objects: span_counts and label_counts. The Counter object span_counts counts the frequency of each unique (span.text, span.label_) tuple in the spans list, while the Counter object label_counts counts the frequency of each unique span.label_ in the labels list.

Finally, the function returns a tuple containing the two Counter objects span_counts and label_counts. The span_counts object maps each unique (span.text, span.label_) tuple to its frequency in the document, while the label_counts object maps each unique span.label_ to its frequency in the document.