Skip to content

Comments

fix working directory alteration#8

Open
hoangnv735 wants to merge 1 commit intothelinhbkhn2014:masterfrom
hoangnv735:master
Open

fix working directory alteration#8
hoangnv735 wants to merge 1 commit intothelinhbkhn2014:masterfrom
hoangnv735:master

Conversation

@hoangnv735
Copy link

@hoangnv735 hoangnv735 commented Oct 13, 2022

Fix working directory alteration when initializing VnCoreNLP.

When creating a VnCoreNLP instance, the working directory is changed to save_dir. This behavior cause errors when using with some package like Flask or Hydra.
After loading the annotation model, I added a line to change it back to self.current_working_dir to fix.

I have tried some workaround to avoid changing the working directory, but I finally realized that the Java code of VnCoreNLP load models by related path. So I guess working directory alteration is inevitable now.
Below is the Java code from VnCoreNLP

public class WordSegmenter {
    private  Node root;
    private static WordSegmenter wordSegmenter = null;
    public final static Logger LOGGER = Logger.getLogger(WordSegmenter.class);
    public WordSegmenter()
            throws IOException {
        LOGGER.info("Loading Word Segmentation model");
        String modelPath = System.getProperty("user.dir") + "/models/wordsegmenter/wordsegmenter.rdr";
        if (!new File(modelPath).exists())
            throw new IOException("WordSegmenter: " + modelPath + " is not found!");

        this.constructTreeFromRulesFile(modelPath);
    }

Fix working directory alteration when initializing VnCoreNLP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant