将 srt 文件内容解析为格式良好的结构
项目描述
从 pip3 安装
pip3 install --verbose subtitlecore
python -m spacy download en_core_web_trf
python -m spacy download es_dep_news_trf
用法
请参考api 文档。
可执行的用法
- 获取字幕内容
subtitlecore_content --srtfile test.srt --lang en
- 将 srtfile 解析为带有时间戳的句子
subtitlecore_parse2sens --srtfile test.srt --lang en
- 将 srtfile 解析为纯文本
subtitlecore_parse2text --srtfile test.srt --lang en
包使用
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)
发展
克隆项目
git clone https://github.com/qishe-nlp/subtitlecore.git
安装诗歌
安装依赖项
poetry update
测试
poetry run pytest -rP
在哪个运行测试tests/*
执行
poetry run subtitlecore_content --help
poetry run subtitlecore_parse2sens --help
poetry run subtitlecore_parse2text --help
创建 sphinx 文档
poetry shell
cd apidocs
sphinx-apidoc -f -o source ../subtitlecore
make html
python -m http.server -d build/html
github页面上的软管文档
cp -rf apidocs/build/html/* docs/
建造
- 变化和
version
_pyproject.toml
subtitlecore/__init__.py
- 构建python包
poetry build
Git 提交和推送
从本地开发环境发布
- 在poetry中设置pypi测试环境变量,参考poetry doc
- 发布到 pypi 测试由
poetry publish -r test
通过 CI 发布
- Github 操作构建和发布包以测试 pypi 存储库
git tag [x.x.x]
git push origin master
- 通过github action手动发布到pypi repo
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
subtitlecore-0.1.11.tar.gz
(4.5 kB
查看哈希)
内置分布
subtitlecore-0.1.11-py3-none-any.whl
(5.6 kB
查看哈希)
关
subtitlecore- 0.1.11 -py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 8adc5f6a9bae21d1c5092bf8343994cb2a95ccf4fed448bac0fe81790726413a |
|
MD5 | 71fbbeddbc477ee1817530faa84254d0 |
|
布莱克2-256 | cae9f3e0243cee358bae79736301ef9d373173c7aa45a6b62b1330b8c92b16d2 |