Tag Archives: development language

python chatterbot [nltk_data] Error loading stopwords: <urlopen error [Errno 11004]

The following error occurred while running the project:

[nltk_data] Error loading stopwords: <urlopen error [Errno 11004]
[nltk_data]     getaddrinfo failed>
[nltk_data] Error loading averaged_perceptron_tagger: <urlopen error
[nltk_data]     [Errno 11004] getaddrinfo failed>

The Solution is as follows:

Go to: https://github.com/nltk/nltk_data

Go to the directory /packages/corpora/ and find the corresponding file stopwords.zip and put it under the corresponding file

It is recommended that the entire nltk_data project is downloaded with a size of 695M to avoid other problems that cannot be downloaded!

Extract the zip file

nltk_data-gh-pages.zip\nltk_data-gh-pages\packages

all files to the following directory

C:\Users\Administrator\AppData\Roaming\nltk_data

Here the installation directory may be different for each person, here I am in the above directory.

Modify the corresponding file.

\venv\Lib\site-packages\chatterbot\utils.py under the current project directory

(Some children’s directory may not be under the current project, you can find the corresponding site-packages directory according to your own configuration and then find the corresponding files to modify)

The corresponding code nltk_download_corpus(‘xxx’) needs to be modified as follows:


def download_nltk_stopwords():
    """
    Download required NLTK stopwords corpus if it has not already been downloaded.
    """
    nltk_download_corpus('corpora/stopwords')


def download_nltk_wordnet():
    """
    Download required NLTK corpora if they have not already been downloaded.
    """
    nltk_download_corpus('corpora/wordnet')


def download_nltk_averaged_perceptron_tagger():
    """
    Download the NLTK averaged perceptron tagger that is required for this algorithm
    to run only if the corpora has not already been downloaded.
    """
    nltk_download_corpus('taggers/averaged_perceptron_tagger')


def download_nltk_vader_lexicon():
    """
    Download the NLTK vader lexicon for sentiment analysis
    that is required for this algorithm to run.
    """
    nltk_download_corpus('sentiment/vader_lexicon')

Done!

[Solved] Crypto-JS Failed to Decrypt Error: Uncaught Error: Malformed UTF-8 data

java encrypt js decrypt, an error is reported: Uncaught Error: Malformed UTF-8 data

public static String encrypt(String strToEncrypt, SecretKey secretKey) {
    try {
      Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7PADDING");
      cipher.init(Cipher.ENCRYPT_MODE, secretKey);
      encryptedString = new String(Base64.encodeBase64String(cipher.doFinal(strToEncrypt.getBytes())));
    } catch (Exception e) {
      System.out.println("Error while encrypting: " + e.toString());
    }

    return encryptedString;
  }

JS:

decrypt(secret_key,code) {
        return CryptoJS.AES.decrypt(code, this.parse(secret_key), {
          mode: CryptoJS.mode.ECB,
          padding: CryptoJS.pad.Pkcs7
        }).toString(CryptoJS.enc.Utf8);
      }

The reason is that the string has a newline character, Base64 generates a newline, change to NO_WRAP

 Base64.encodeBase64String(hashPassword,Base64.NO_WRAP)

Recommended Read: https://stackoverflow.com/questions/21852889/remove-r-and-n-from-aes-encrypted-string

 

How to Solve Error: Error parsing mapper XML

[Solved] Error parsing Mapper XML

Error parsing mapper xml
this error message is essentially a mapper XML error
failed resolve xxx XML, etc.
here we analyze some problems that will not become popular when writing, and that will cause errors when starting

1. ID conflict

The conflicts here are
resultmap

<resultMap type="com.newtouch.business.module.dto.T01agentComDTO" id="t01agentComMap">

<resultMap type="com.cpi.newtouch.business.module.dto.T01comDTO" id="t01agentComMap">

Specific SQL

<select id="findBy" >
<update id="findBy">

As long as two or more IDs are the same, an error will be reported. This usually happens because you don’t pay attention to copy and paste. You need to be careful!

2. Return type error

<resultMap type="com.newtouch.business.module.dto.T01agentComDTO" id="t01agentComMap">
<select id="findBy" resultType="t01agentComMap">

Like here, I returned the resultmap, but wrote the resulttype

Similarly, for example, if I return a string type, but I write a resultmap, I will also report an error

3. Not writing the full class name

<resultMap type="com.newtouch.business.module.dto.T01agentComDTO" id="t01agentComMap">

The resultmap, if I write it like this

<resultMap type="T01agentComDTO" id="t01agentComMap">

An error will be reported. Of course, if relevant settings are configured

[Solved] Golang Error: main.go:5:2: package go_code/chapter10/factory/model is not in GOROOT

golang Error: is not in GOROOT

The following errors are reported during operation

PS C:\goproject\src\go_code\chapter10\factory\main> go run main.go
main.go:5:2: package go_code/chapter10/factory/model is not in GOROOT (C:\go\src\go_code\chapter10\factory\model)

The process is as follows

PS C:\goproject\src\go_code\chapter10\factory\main> go run main.go
main.go:5:2: package go_code/chapter10/factory/model is not in GOROOT (C:\go\src\go_code\chapter10\factory\model)

PS C:\goproject\src\go_code\chapter10\factory\main>  go env
set GO111MODULE=

PS C:\goproject\src\go_code\chapter10\factory\main> go env -w GO111MODULE=off
PS C:\goproject\src\go_code\chapter10\factory\main> go run main.go
{tom 78.9}

[Solved] SpringCloud Compile Error: java: JPS incremental annotation processing is disabled. Compilation results on partial recompilation may be inaccurate.

Error:

SpringCloud Compile Error: java: JPS incremental annotation processing is disabled. Compilation results on partial recompilation may be inaccurate. Use build process “jps.track.ap.dependencies” VM flag to enable/disable incremental annotation processing environment.

 

Solution:
1.Add: -Djps.track.ap.dependencies=false

2. Clear the caches

[Solved] matlab Error: Error in port widths or dimensions. ‘Output Port 1‘ of ‘sl_arm_ibvs/camera‘

When running the Manipulator Simulation in MATLAB visual servo toolbox, the following problems are encountered: error in port widths or dimensions. ‘ Output Port 1’ of ‘sl_ arm_ ibvs/camera’ is a [28×1] matrix.

The problem is caused by the wrong input vector dimension at the red circle dimension in the figure below.

Here the p for the camera pixel coordinate system under the coordinate value, should be 2 * 4 vectors.

Solution: The new version of Machine Vision Toolbox for MATLAB toolbox lacks the module “slcamera.m”, open the camera module in simulate.

Double click the MATLAB FCN module, and you will be prompted that “slcamera” cannot be found. Select new:

Type the following code:

function p = slcamera(cam, u)
    %if all(u == 0)
     if (u(1:16,:)==0)
        % Simulink is probing for the dimensions
        np = (length(u)-16)/3;
        p = zeros(2, np);
    else
        p = zeros(2, 4);
        P = reshape(u(17:end), 3, []);
        Tcam = reshape(u(1:16), 4, 4);
        p = cam.plot(P, 'pose', Tcam, 'drawnow');
        
    end

Run simulate again, you can see the error report and disappear, then you should encounter the following error.

Error in ‘sl_arm_ibvs/camera/MATLAB Fcn’. Evaluation of expression resulted in an invalid output.
Only finite double vector or matrix outputs are supported

I am also working on a solution for this error, so please stay tuned.

[Solved] This error might have occurred since this system does not have Windows Long Path support enabled.

This error might have occurred since this system does not have Windows Long Path support enabled.

pip install rife_ncnn_vulkan_python
WARNING: Ignoring invalid distribution -ip (d:\python3.8\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\python3.8\lib\site-packages)
Collecting rife_ncnn_vulkan_python
Using cached rife-ncnn-vulkan-python-1.1.2.post3.tar.gz (21.5 MB)
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: ‘C:\Users\Administrator\AppData\Local\Temp\pip-install-ti2fh5nq\rife-ncnn-vulkan-python_464f213e18974938aa0e4a998e825356\rife_ncnn_vulkan_python/rife-ncnn-vulkan/src/ncnn/glslang/Test/baseResults/spv.WorkgroupMemoryExplicitLayout.MixBlockNonBlock_Errors.comp.out’
HINT: This error might have occurred since this system does not have Windows Long Path support enabled. You can find information on how to enable this at https://pip.pypa.io/warnings/enable-long-paths

 

Solution:

[Solved] Error:maven-resources-production:ruoyi-ywjs: java.lang.NegativeArraySizeException

Error:maven-resources-production:ruoyi-ywjs: java.lang.NegativeArraySizeException

Cause: nothing is done. This exception is reported when restarting the project: array exception

Error:maven-resources-production:ruoyi-ywjs: java.lang.NegativeArraySizeException

Solution:

1. Click file,

2 Click void cache/restart,

3 Click: invalidate and restart,

4 Just restart the project

[Solved] Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find cla

preface

The problem encountered when learning Mybatis for the first time, when writing the global configuration file SqlMapConfig.xml, in the database connection pool section would like to introduce the configuration of db.properties as follows.

db.properties configuration

SqlMapConfig.xml

The error reports given are:

Error setting driver on UnpooledDataSource. Cause:java.lang.ClassNotFoundException: Cannot find class: ${jdbc.driver}

No corresponding connection was obtained. Because the properties file was not loaded:

After Add <properties> labeling, the program runs normally.

Done.

[Solved] javax.crypto.BadPaddingException: Decryption error

javax.crypto.BadPaddingException: Decryption error

When using RSA encrypt body spring boot for decryption. This error occurred

I access the interface in postman. As follows:

This error appears.

Solution:

The value in raw contains all the requested parameters.

The @RequestBody is also required, otherwise it will not receive the value it should.

back-end:

    @Encrypt
    @GetMapping("/encrypt")
    public Student encrypt(){
        Student stu = new Student();
        stu.setId(1);
        stu.setName("test");
        return stu;
    }


    @Decrypt
    @PostMapping("/decrypt")
    public String testDecrypt(@RequestBody String username){
        System.out.println(username);
        return username;
    }

The correct postman is as follows:

At this time, pay attention to the data format of the transfer. There may be a problem with submitting the wrong data type. Text is not necessarily right. After that problem, I changed to JSON.

[Solved] PageHelper Error: syntax error, error in :‘it 1 LIMIT ? ‘

Error Messages:

syntax error, error in :‘it 1 LIMIT ? ‘

 

Problem Cause:
The PageHelper method uses static ThreadLocal parameters, and the paging parameters and threads are bound.
This is safe as long as we ensure that the PageHelper method is called immediately after the MyBatis query method. This is because PageHelper automatically clears the ThreadLocal stored object in the finally snippet.
The page started in the thread does not guarantee that the thread will have cleared the page variable by the time the current execution exits.
One PageHelper paging process is as follows.
i. Set the page parameter
Second, execute the query method
Third, the Interceptor interface checks whether there is a set page parameter in ThreadLocal
If the page parameter exists, regenerate count sql and page sql, and execute the query. If the page parameter does not exist, return the query result directly.
V. Execute LOCAL_PAGE.remove() to clear the page parameter.

Solution:
Call PageHelper.clearPage() at the end of the method using PageHelper;

[Solved] PDF.js Error: Cannot use the same canvas during multiple render()

Background of the problem: business in the preview pdf file, the pdf to zoom in and out operations, if the frequency of operation is too fast or multiple execution page to display the contents of the pdf file is lost, the display is incomplete, the content is inverted and other phenomena. Open the console to find an error message: ERROR Error: Uncaught (in promise): Error: Cannot use the same canvas during multiple render() operations. use different canvas or Use different canvas or ensure previous operations were cancelled or completed.

Reason analysis: the meaning of the error may be the canvas tag in the display of pdf file content, pdf rendering errors, the problem may be in the scaling operation of the logic code in what operation caused.

Check the code found here to display the pdf file is not paged display, so in the scaling operation, go through all the canvas tags, and then the implementation of the pdf.getPage () this r function, re-modify the width and length of the canvasde rendering pdf. page.render (renderContext) is an asynchronous operation, traversing the canvas to modify the canvas rendering pdf may cause the last asynchronous rendering operation has not yet finished and start a new render, which will report an error resulting in pdf rendering errors.

pdfStreamRenderPage = (num) => { // A string of pdf 64-bit streams with zoom in/out rotation
      if (self.pageRendering) {
        self.pageNumPending = num;
      } else {

        const container = document.getElementById('thisCanvas1').getElementsByTagName('canvas');
        // This traversal operation will result in an error
        for (let i = 1; i <= container.length; i++) {
          self.pageRendering = true;
          self.pdfDoc.getPage(i).then((page) => {
            const viewport = page.getViewport(self.scale, self.rotate);
            container[i - 1].height = viewport.height;
            container[i - 1].width = viewport.width;
            const ctx = container[i - 1].getContext('2d');
            const renderContext = {
              canvasContext: ctx,
              viewport
            };
            const renderTask = page.render(renderContext);
            // You can wait here for rendering to finish before manipulating the next canvas
            renderTask.promise.then(() => {
              self.pageRendering = false;
              if (self.pageNumPending !== null) {
                renderPage(self.pageNumPending);
                self.pageNumPending = null;
              }
            });
          });
        }
      }
    };

Optimize this traversal operation logic to wait for the previous renderTask.promise.then() canvas rendering to finish before executing the next canvas rendering operation.
Modified code:

const pdfStreamRenderPage = (num) => {
      // A string of pdf 64-bit streams with zoom in/out rotation
      if (self.pageRendering) {
        self.pageNumPending = num;
      } else {
        const canvasElementMap = document.getElementById('thisCanvas1').getElementsByTagName('canvas');
        const canvasElement = canvasElementMap[0]
        const pageNum = 1
        scalePdfCanvas(canvasElement, pageNum, canvasElementMap)
      }
    };
 
     /**
     * Scaling the contents of each pdf page
     * @param canvasElement current page canvas
     * @param num current page number
     * @param canvasElementMap the set of all rendering pdf's canvas
     */
    const scalePdfCanvas = (
      canvasElement: HTMLCanvasElement, 
      num: number, 
      canvasElementMap: HTMLCollectionOf<HTMLCanvasElement>
      ) => {
        self.pageRendering = true;
        self.pdfDoc.getPage(num).then((page) => {
        const viewport = page.getViewport(self.scale, self.rotate);
        canvasElement.height = viewport.height;
        canvasElement.width = viewport.width;
        const ctx = canvasElement.getContext('2d');

        // Render PDF page into canvas context
        const renderContext = {
          canvasContext: ctx,
          viewport,
        };

        const renderTask = page.render(renderContext);
        // Wait for rendering to finish
        renderTask.promise.then(() => {
          self.pageRendering = false;
          num++;
          if (num <= canvasElementMap.length) {
            // scale next canvas
            scalePdfCanvas(canvasElementMap[num-1], num, canvasElementMap)
          }
          if (self.pageNumPending !== null) {
            // New page rendering is pending
            pdfStreamRenderPage(self.pageNumPending);
            self.pageNumPending = null;
          }
        });
      });
    }