Parse srt file content into well-formed structures
Project description
Installation from pip3
pip3 install --verbose subtitlecore
python -m spacy download en_core_web_trf
python -m spacy download es_dep_news_trf
Usage
Please refer to api docs.
Excutable usage
- Get subtitle content
subtitlecore_content --srtfile test.srt --lang en
- Parse srtfile into sentences with timestamp
subtitlecore_parse2sens --srtfile test.srt --lang en
- Parse srtfile into plain text
subtitlecore_parse2text --srtfile test.srt --lang en
Package usage
from subtitlecore import Subtitle
def get_subtitle_content(srtfile, lang):
st = Subtitle(srtfile, lang)
for line_info in st.content:
print(line_info)
def parse2sens(srtfile, lang):
st = Subtitle(srtfile, lang)
content_sens = st.sentenize()
for e in content_sens:
print(e)
def parse2text(srtfile, lang):
st = Subtitle(srtfile, lang)
text = st.plaintext()
print(text)
Development
Clone project
git clone https://github.com/qishe-nlp/subtitlecore.git
Install poetry
Install dependencies
poetry update
Test
poetry run pytest -rP
which run tests under tests/*
Execute
poetry run subtitlecore_content --help
poetry run subtitlecore_parse2sens --help
poetry run subtitlecore_parse2text --help
Create sphinx docs
poetry shell
cd apidocs
sphinx-apidoc -f -o source ../subtitlecore
make html
python -m http.server -d build/html
Host docs on github pages
cp -rf apidocs/build/html/* docs/
Build
- Change
version
inpyproject.toml
andsubtitlecore/__init__.py
- Build python package by
poetry build
Git commit and push
Publish from local dev env
- Set pypi test environment variables in poetry, refer to poetry doc
- Publish to pypi test by
poetry publish -r test
Publish through CI
- Github action build and publish package to test pypi repo
git tag [x.x.x]
git push origin master
- Manually publish to pypi repo through github action
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
subtitlecore-0.1.14.tar.gz
(3.5 kB
view details)
Built Distribution
File details
Details for the file subtitlecore-0.1.14.tar.gz
.
File metadata
- Download URL: subtitlecore-0.1.14.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.0 Linux/6.2.0-1014-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 214e3f19b663a1b461e7dc504d390472d9358a80cd03a948a73cb4c6c43c0750 |
|
MD5 | 1cafd27a6d7fbac09b1af23781324984 |
|
BLAKE2b-256 | af3d25215bf3dfc322169062f3256a2b6bede7101269b883be32d7d1487064e1 |
File details
Details for the file subtitlecore-0.1.14-py3-none-any.whl
.
File metadata
- Download URL: subtitlecore-0.1.14-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.0 Linux/6.2.0-1014-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0ff89f0b96645251ec1d2aed7175693ec328307e23fcac66b9b4fc6fe8eee9f |
|
MD5 | 0f0f8ee0c4cb628d5beb6ac24eb82516 |
|
BLAKE2b-256 | 54d5ef4ef1024684b99283656528bee6494ce147079fbb94a8b406ddfb51660f |