0

I'm having a problem with assigning static files containing resources.

My working directory structure is:

|- README.md
|- nlp
|   |-- morpheme
|   |-- |-- morpheme_builder.py
|   |-- fsa_setup.py
| - tests
|   |-- test_fsa.py
| - res
|   |-- suffixes.xml

The code for fsa_setup.py is:

class FSASetup():
    fsa = None
    def get_suffixes():
        list_suffix = list()
        file = os.path.realpath("../res/suffixes.xml")
        .....
if __name__ == "__main__":
    FSASetup.get_suffixes()

The code for morpheme_builder.py is:

class MorphemeBuilder:
    def get_all_words_from_fsa(self):
        ......
if __name__ == "__main__":
    FSASetup.get_suffixes()

When it is called in fsa_setup.py, the file path's value is '\res\suffixes.xml' and that is correct, but when the other case realized, the file path value is '\nlp\res\suffixes.xml'.

I know how it works like this. So how can I give the path of the resource to the file.

1 Answer 1

1

The problem is that morpheme_builder.py is in the directory morphem. So when you say ../res/suffixes.xml it will go on directory back ... so it will go to nlp/res/suffixes.xml. What about if you use os.path.abspath("../res/suffixes.xml")?

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.