Skip to main content

将 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.tomlsubtitlecore/__init__.py
  • 构建python包poetry build

Git 提交和推送

从本地开发环境发布

  • 在poetry中设置pypi测试环境变量,参考poetry doc
  • 发布到 pypi 测试由poetry publish -r test

通过 CI 发布

git tag [x.x.x]
git push origin master

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

subtitlecore-0.1.11.tar.gz (4.5 kB 查看哈希

已上传 source

内置分布

subtitlecore-0.1.11-py3-none-any.whl (5.6 kB 查看哈希)

已上传 py3