Skip to main content

自动重写内容SDK 英文版本

主要是调用的封装

实现自动重写内容,英文版本

##安装

pip install tkitAutoRewriter

示例

自动对内容筛选

import re
from pprint import pprint

from sentence_splitter import SentenceSplitter

from tkitAutoRewriter import AutoReWrite, SentenceClassification
from tkitAutoRewriter.api import get_markdown_images
from tkitAutoRewriter.diff import similar_diff_qk_ratio

from tkitreadability import tkitReadability




html = """
<div class="row">
        <div class="col"></div>
        <div class="col-md-auto">
            <p class="text-lg-center">The sentence splitter tool allows you to break up large amounts of text into individual sentences.
                Put a large
                block of text into the box below and click convert. The tool will then split the text below so
                that each sentence is on its own line and colored differently from the line above. You can also download
                the finished result as a word document as well. </p>
        </div>
        <div class="col"></div>
    </div>

            <div class="full-component-wrapper">

                </div>
        <img src="/sites/default/files/styles/ttt_image_510/public/2021-07/border-collie.jpg?itok=jhilnwqZ" alt="Border Collie" typeof="foaf:Image" loading="lazy">
                <div class="text-image--text-wrapper col-12 col-xl-5 order-3 order-xl-2">

                  <div class="text-image--text">

                    <div class="clearfix text-formatted field field--name-field-c-sideimagetext-summary field--type-text-long field--label-hidden field__item"><h2>Pet Card</h2>

        <ul>
            <li><strong>Living Considerations:</strong> Not hypoallergenic, suitable for apartment living, good with older children</li>
            <li><strong>Size:</strong> Medium</li>
            <li><strong>Height:</strong> Males - 48 to 56 centimetres at the withers, Females - 45 to 53 centimetres at the withers</li>
            <li><strong>Weight:</strong> Males -13 to 20 kilograms, Females - 12 to 19 kilograms</li>
            <li><strong>Coat:</strong> Medium/Long</li>
            <li><strong>Energy:</strong> High</li>
            <li><strong>Colour:</strong> All colours or colour combinations</li>
            <li><strong>Activities:</strong> Agility, Conformation, Herding, Obedience, Rally Obedience, Tracking</li>
            <li><strong>Indoor/Outdoor:</strong> Both</li>
        </ul>
        </div>

                  </div>

                          </div>
                  </div>
          </div>
        </div>



                      <div class="col-md-auto">
            <p class="text-lg-center">The sentence splitter tool allows you to break up large amounts of text into individual sentences.
                Put a large
                block of text into the box below and click convert. The tool will then split the text below so
                that each sentence is on its own line and colored differently from the line above. You can also download
                the finished result as a word document as well. </p>
        </div>

              </div>


"""
Readability = tkitReadability()
content = Readability.html2text(html,
                                ignore_links=True,
                                bypass_tables=True,  # 用 HTML 格式而不是 Markdown 语法来格式化表格。
                                ignore_images=False,
                                images_to_alt=False,
                                images_as_html=False,
                                images_with_size=True,
                                ignore_emphasis=True)

out = Readability.markdown2Html(content)
# print(out)



rewriter = AutoReWrite(api='http://192.168.1.18:3008')
out = rewriter.rewriter(content, simlimit=0.7, simlimitmax=1,
                        auto_sample=True, pre_text="del summary paraphrase: ")
print("".join(out['items']))


print("images",out['images'])

print(out)

ratio = similar_diff_qk_ratio(content, "".join(out['items']))
print(ratio)





# ## Pet Card

# 1.Considerations: Not hypoallergenic, suitable for apartment living, good with older children
# 2.Size: Medium
# 3.Height: Females - 45 to 53 centimetres at the withers , males - 48 to 56 centimetre at the UNK .
# 4.Weight: Males -13 to 20 kilograms, Females - 12 to 19 kilograms .
# 5. Coat: Medium/Long paraphrase: Coat: medium/Long.
# 6.Energy: High
# 7.Colour: All colours or colour combinations .
# 8.Activities: Agility, Conformation, Herding, Obedience, Rally Obedience and Tracking .
# 9.Indoor/Outdoor: Both
# The sentence splitter tool allows you to break up large amounts of text into individual sentences.Put a large block of text into the box below and click convert.The tool will then split the text below so that each sentence is on its own line.You can also download the finished result as a word document as well


# images [('Border Collie', '/sites/default/files/styles/ttt_image_510/public/2021-07/border-collie.jpg?itok=jhilnwqZ')]
# {'items': ['The sentence splitter tool allows you to break up large amounts of text into single sentences.', 'Take a large block of text into the box below and click convert.', 'The tool will then split the text below so that each sentence is colored differently from the line above.', 'You can also download the finished result as a word document.', '\n', '![Border Collie](/sites/default/files/styles/ttt_image_510/public/2021-07/border-collie.jpg?itok=jhilnwqZ)  ', '\n', '', '\n', '## Pet Card', '\n', '\n', '1.', 'Considerations: Not hypoallergenic, suitable for apartment living, good with older children', '\n', '2.', 'Size: Medium', '\n', '3.', 'Height: Females - 45 to 53 centimetres at the withers , males - 48 to 56 centimetre at the UNK .', '\n', '4.', 'Weight: Males -13 to 20 kilograms, Females - 12 to 19 kilograms .', '\n', '5.', ' Coat: Medium/Long paraphrase: Coat: medium/Long.', '\n', '6.', 'Energy: High', '\n', '7.', 'Colour: All colours or colour combinations .', '\n', '8.', 'Activities: Agility, Conformation, Herding, Obedience, Rally Obedience and Tracking .', '\n', '9.', 'Indoor/Outdoor: Both', '\n', 'The sentence splitter tool allows you to break up large amounts of text into individual sentences.', 'Put a large block of text into the box below and click convert.', 'The tool will then split the text below so that each sentence is on its own line.', 'You can also download the finished result as a word document as well', '\n', '\n'], 'images': [('Border Collie', '/sites/default/files/styles/ttt_image_510/public/2021-07/border-collie.jpg?itok=jhilnwqZ')]}

内容重写示例

from tkitAutoRewriter import AutoReWrite, SentenceClassification

text = """

The Border Collie is a British breed of herding dog of medium size. They are descended from landrace sheepdogs once found all over the British Isles, but became standardized in the Anglo-Scottish border region. Presently they are used primarily as working dogs to herd livestock, specifically sheep.[1]

The Border Collie is considered a highly intelligent, extremely energetic, acrobatic and athletic dog. They frequently compete with great success in sheepdog trials and a range of dog sports like dog obedience, disc dog, herding and dog agility. They are one of the most intelligent domestic dog breeds.[2] Border Collies continue to be employed in their traditional work of herding livestock throughout the world and are kept as pets.

"""
rewriter = AutoReWrite(api='http://192.168.1.18:3008')
out = rewriter.rewriter(text, simlimit=0.7)
print("".join(out))
# The Border Collie is a medium-sized herding dog.They are descended from landrace sheepdogs that were once found all over the British Isles, but became standardized in the Anglo-Scottish border region.They are mostly used as working dogs to herd sheep.Presently they are used primarily as working dogs to herd livestock, specifically sheep.[1]The Border Collie is a dog that is very athletic and energetic.They compete in a variety of dog sports, including sheepdog trials and dog agility.Border Collies are one of the most intelligent domestic dog breeds, and are kept as pets.

容器镜像托管

内容判别 https://gitlab.com/napoler/SequenceClassification/container_registry

英文生成相关 https://gitlab.com/napoler/tkittextensummary/container_registry

更多内容 博客 https://www.terrychan.org/2022/07/%e8%8b%b1%e6%96%87%e5%86%85%e5%ae%b9%e8%87%aa%e5%8a%a8%e9%87%8d%e5%86%99sdk/

Update

0.0.0.9

添加图片段落分割,文本优化接口

0.0.0.8

添加文本优化接口

0.0.0.7

修改段落分割参数,段落更短

0.0.0.3

优化摘要生成参数,使用wandb调参自动优化。

Metadata

Release files for tkitAutoRewriter 0.0.1.16701444

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tkitAutoRewriter 0.0.1.16701444
File Size Uploaded
tkitAutoRewriter-0.0.1.16701444.tar.gz 356.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tkitAutoRewriter 0.0.1.16701444
File Interpreter ABI Platform
tkitAutoRewriter-0.0.1.16701444-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 714.5 kB

Release files / tkitAutoRewriter-0.0.1.16701444.tar.gz

Download URL tkitAutoRewriter-0.0.1.16701444.tar.gz
Size 356.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9b4d1b37faafe4d5e3618a3aa131cd65f1408aa05062bea0ad7057fe68e73ff8
BLAKE2b-256 checksum
How to use checksums
f79f245c6ebe9b397776a44d79f12f1c35ae708c2001d5793f4f2ab78c4b2099
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release files / tkitAutoRewriter-0.0.1.16701444-py2.py3-none-any.whl

Download URL tkitAutoRewriter-0.0.1.16701444-py2.py3-none-any.whl
Size 357.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
904ba3f36c48b577bfb12b5a341ec23aa83704bc407b5f6eeb733632d5beb8c2
BLAKE2b-256 checksum
How to use checksums
079453dc84a51a8a0f76969cb97da806ed01609ef47fa73351fdbe87a1a84d0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release history Release notifications | RSS feed

This release

0.0.1.16701444 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page