[Artifact] A magic weapon for graduates, one-click weight reduction of thesis~!

[Artifact] A magic weapon for graduates, one-click weight reduction of thesis~!


Those who are interested in code and programming can follow old K to play code and communicate with me!
[Artifact] A magic weapon for graduates, one-click weight reduction of thesis~!

[Artifact] A magic weapon for graduates, one-click weight reduction of thesis~!


“声明:本文旨在技术分享,谢绝以此投机取巧~!
  • Students facing graduation must have had the horrific experience of being dominated by heavy investigations. Wanfang, turnitin, HowNet, PP, and PT have different check rates for each platform.
  • The most frustrating thing is that schools have very high requirements for repetition rates. The more top schools, the higher the requirements for duplication checks.

  • I have graduated for more than ten years, and I shudder every time I think of working hard all night for the repetition rate of my thesis.
  • It's good now, as long as you Taobao, there are various weight reduction services. What caught my attention was a tool called "AI Weight Reduction Software".
  • Out of curiosity, I spent some capital, bought the software, and then studied the code logic behind it.

    [Artifact] A magic weapon for graduates, one-click weight reduction of thesis~!

  • In fact, the so-called AI weight reduction is essentially the translation software from Chinese into a foreign language, and then the translation back. This way the semantics remain unchanged, but the text seems to have become another expression.
  • I think this idea is quite interesting, so I wrote the code by hand:

    1. Import the required third-party libraries


from selenium.webdriver import Chrome
  • The selenium library will be used this time. It needs to be equipped with webdriver to run. You can search for the keyword "webdriver chrome" on Google, and it is usually the first one.
  • Install webdriver in the directory where the script file is located.

    2. Make some initial settings for the simulated browser


dr = Chrome()
dr.implicitly_wait(5)
dr.maximize_window()
  1. The above are my basic settings for the browser.
    • If you like browserless mode, you can use the following code
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument('--headless')
dr = Chrome(options=options)
dr.implicitly_wait(5)
dr.maximize_window()

3. Excuse to check translation software request


[Artifact] A magic weapon for graduates, one-click weight reduction of thesis~!

  • I use Baidu Translator as an example.

From the above screenshots, we can see that the excuse of Baidu Translation is very concise, written using the get method. In the figure, zh is the input language name, en is the output language name, and the url link is the text content to be translated at the end. So our request code can be written like this

url = f"https://fanyi.baidu.com/#{input_lang}/{output_lang}/{text}"
dr.get(url)

4. Get translated text


After sending the request, wait for a few seconds. After the page is opened, save the corresponding translated text in the variable
text = dr.find_element_by_class_name("target-output").text.strip()
Different translation tools have different excuses and parsing paths . Still need some front-end selector knowledge.

5. Use translation tools to translate back to Chinese


This step is actually the repetition of the previous content, the only difference is to swap the input language and output language. The code will not be repeated here.

ex. Summary


The code content mentioned above is only used to display and share homework ideas. The complete code is as follows:

# encoding: utf-8
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options

def do_repetition(text):
    options = Options()
    options.add_argument('--headless')
    dr = Chrome(options=options)
    dr.implicitly_wait(5)
    dr.maximize_window()

    for i in range(2):
        if i == 0:
            input_lang = 'zh'
            output_lang = 'en'
        else:
            input_lang = 'en'
            output_lang = 'zh'
        url = f"https://fanyi.baidu.com/#{input_lang}/{output_lang}/{text}"
        dr.get(url)
        text = dr.find_element_by_class_name("target-output").text.strip()
    dr.close()
    return text

If you want to really realize the function of text weight reduction, you may need to polish the details, such as:

  • Time design for waiting for response;
  • Handling of request failure;
  • Handling of special characters;
  • Processing of text and pictures;
  • Text format setting;
  • Carriage return and line feed processing;
  • Constraints on proper nouns;
  • The need to keep the quoted and excerpted text unchanged, etc...
    To truly realize the one-click weight reduction of the paper, there are still many details to deal with.
    I will not share more detailed code in detail here, nor encourage the use of this opportunistic approach to academic research.
    Hope this article can inspire the technical colleagues.

Previous wonderful recommendations:


  • 11 must-read books recommended for beginners to learn Python by themselves
  • 18 Python open source libraries you must know
  • Learn the basic skills of JavaScript, old K recommends these books
  • Deep learning, which community forums do you watch?
  • [Hot recommendation] 7 Python deep learning projects that must be recommended

Fan benefits:


  • Read and share "Learn the basic skills of JavaScript, old K recommends these books", have a chance to get a copy of "JavaScript Advanced Programming"
  • Read and share "11 Must-Read Bibliographies Recommended for Newbies to Learn Python by themselves", and have a chance to get 1 copy of "Python Core Programming"
    [Artifact] A magic weapon for graduates, one-click weight reduction of thesis~!

Guess you like

Origin blog.51cto.com/15069443/2576236