No project description provided
Project description
Installation from pip3
pip3 install --verbose subtitle_analyzer
python -m spacy download en_core_web_trf
python -m spacy download es_dep_news_trf
python -m spacy download de_dep_news_trf
Usage
Please refer to api docs.
Excutable usage
Since the x2cdict needs environment variables DICT_DB_HOST and DEEPL_AUTH_KEY, so Don't forget!!!.
- Write ass file with vocabulary information
sta_vocab --srtfile movie.srt --lang en --assfile en_vocab.ass --external False
- Write ass file with phrase information
sta_phrase --srtfile movie.srt --lang en --assfile en_phrase.ass --external False
Package usage
from subtitlecore import Subtitle
from subtitle_analyzer import VocabAnalyzer, PhraseAnalyzer
from subtitle_analyzer import VocabASSWriter, PhraseASSWriter
import json
def subtitle_vocab(srtfile, lang, assfile, external):
phase = {"step": 1, "msg": "Start sentenizing"}
print(json.dumps(phase), flush=True)
sf = Subtitle(srtfile, lang)
sens = sf.sentenize()
for e in sens:
print(e)
phase = {"step": 2, "msg": "Finish sentenizing"}
print(json.dumps(phase), flush=True)
analyzer = VocabAnalyzer(lang)
exs = analyzer.get_line_vocabs(sens, external)
shown = exs[:20]
phase = {"step": 3, "msg": "Finish vocabs dictionary lookup", "vocabs": shown}
print(json.dumps(phase), flush=True)
if assfile:
ass_writer = VocabASSWriter(srtfile)
ass_writer.write(exs, assfile, {"animation": False})
phase = {"step": 4, "msg": "Finish ass saving"}
print(json.dumps(phase), flush=True)
def subtitle_phrase(srtfile, lang, assfile, external):
phase = {"step": 1, "msg": "Start sentenizing"}
print(json.dumps(phase), flush=True)
sf = Subtitle(srtfile, lang)
sens = sf.sentenize()
for e in sens:
print(e)
phase = {"step": 2, "msg": "Finish sentenizing"}
print(json.dumps(phase), flush=True)
analyzer = PhraseAnalyzer(lang)
exs = analyzer.get_line_phrases(sens, external)
phase = {"step": 3, "msg": "Finish phrases dictionary lookup", "vocabs": exs[:10]}
print(json.dumps(phase), flush=True)
if assfile:
ass_writer = PhraseASSWriter(srtfile)
ass_writer.write(exs, assfile, {"animation": False})
phase = {"step": 4, "msg": "Finish ass saving"}
print(json.dumps(phase), flush=True)
Development
Clone project
git clone https://github.com/qishe-nlp/subtitle-analyzer.git
Install poetry
Install dependencies
poetry update
Test
poetry run pytest -rP
which run tests under tests/*
Execute
poetry run sta_vocab --help
poetry run sta_phrase --help
Create sphinx docs
poetry shell
cd apidocs
sphinx-apidoc -f -o source ../subtitle_analyzer
make html
python -m http.server -d build/html
Host docs on github pages
cp -rf apidocs/build/html/* docs/
Build
- Change
versioninpyproject.tomlandsubtitle_analyzer/__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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file subtitle_analyzer-0.1.23.tar.gz.
File metadata
- Download URL: subtitle_analyzer-0.1.23.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.0 Linux/5.15.0-1034-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d979776ffc1bb7d215013a30f9910bbb84de8974328c1dde8b85d62df44824d6
|
|
| MD5 |
0feb1fa94347fdeb7fd766538ac1108f
|
|
| BLAKE2b-256 |
a05cf2f9216a5d6ccd1af833fb9512799ec6e692b935a163fc302e87c68657ad
|
File details
Details for the file subtitle_analyzer-0.1.23-py3-none-any.whl.
File metadata
- Download URL: subtitle_analyzer-0.1.23-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.0 Linux/5.15.0-1034-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22f101f9e9ea759fff3c119f6f95d23d979a5eef609f5a34785476bd3a3d1967
|
|
| MD5 |
fd5ebc07e41029d02acdfa4b80ddf962
|
|
| BLAKE2b-256 |
8f0f68271706debf2e6e77a7c68f28b39fd10a15e2f828865724707e56ddbfa3
|