Fixed problem.
Running similar program in the ctakes source trunk/examples...,
I see that
FileLocator.getResource() method should be using
location=resources/org/apache/ctakes/dictionary/lookup/fast/sno_rx_16ab/sno_rx_16ab.script
url=file:/home/
me
/projects/ctakes/trunk/resources/org/apache/ctakes/dictionary/lookup/fast/sno_rx_16ab/sno_rx_16ab.script
Problem appears to be within FileLocator.getSearchPaths() not including the
location that I have the resource
folder in my project (
which does not conform to
a certain convention
that the method seems to be expecting
(
which
was never mentioned in the ctakes documentation
so far as I could find
)). The
relevant
code snippet from the intellij
debugging tool
for the FileLocator.class
when debugging
looks like:
-------------------------------------------------------------------------------------------
private static Collection<String> getFileSearchPaths(String location) {
Collection<String> paths = new ArrayList();
// getting current working directory (I assume being registered as
my toplevel intellij project location)
String dir = System.getProperty("user.dir");
if (dir != null && !dir.isEmpty()) {
paths.add(dir + "/" + location);
paths.add(dir + "/resources/" + location);
}
String cTakesHome = System.getenv("CTAKES_HOME");
if (cTakesHome != null && !cTakesHome.isEmpty()) {
paths.add(cTakesHome + "/" + location);
paths.add(cTakesHome + "/resources/" + location);
}
if (dir != null && !dir.isEmpty()) {
File ancestor = new File(dir);
// then starting from the parent folder of the CWD...
while(ancestor.getParentFile() != null) {
ancestor = ancestor.getParentFile();
// ...recursively building back down into each "child"
folder to form a list of possible paths following the conventions
shown here
paths.add(ancestor + "/" + location);
paths.add(ancestor + "/ctakes/" + location);
paths.add(ancestor + "/resources/" + location);
}
}
return paths;
}
-------------------------------------------------------------------------------------------
Examining the "paths" variable before the function returns, I see that it
expects a certain absolute path convention (when the CTAKES_HOME env.
variable is not explicitly set).
Solution seemes to be to move the resources/ folder to one of the locations
that the ctakes-core FileLocator.class
is expecting it to be.
My previous project structure looked like:
$HOME/
project/
play-space/
/resouces ("marked as" resource root in intellij)
/desc (still don't know if I even need this, so please let me
know)
/src
<my java files>
changing this to
$HOME/
project/
play-space/
/src
<my java files>
/resouces ("marked as" resource root in intellij)
/desc (still don't know if I even need this, so please let me know)
seems to have fixed that issue. If there is anything else I should know
related to this issue that is not explicitly documented in the ctakes docs,
please let me know.
On Wed, Apr 4, 2018 at 1:00 PM, Reed Villanueva <[email protected]>
wrote:
> As the title states, I am having trouble understanding where to place the
> /resources (and /desc ?) folders in an intellij IDEA project that is trying
> to use ctakes (don't work with java often).
>
> *TLDR: In intellij, how do I use the resources/ and des/ folders that come
> in ctakes binary distributions? What is going on under the surface that
> lets these things be recognized and used (even when outside of intellij)?*
>
> Currently I have added the jars by copying them to some folder and
> pointing intellij to that folder as a library in the File --> Project
> Structure. The way I am using the resources/ folder right now is by having
> it in the same folder as a src folder in the intellij project ("marked as"
> as "source" folder) and using the context menu on this resources/ copy to
> "mark as" a "resource root".
>
> Testing with a simple variation of the HelloWorldAggregatePipeline.java
> that can be found in the ctakes trunk/ctakes-examples/..., the code seems
> to run, but I see errors like:
>
> ** Configuration Error: file:$PROJECT_HOME/project/
>> out/production/project/org/apache/ctakes/lvg/data/config/lvg.properties
>> (No such file or directory)
>> ** Error: problem of opening/reading config file: 'file:$PROJECT_HOME
>> /project/out/production/project/org/apache/ctakes/lvg/data/config/lvg.properties'.
>> Use -x option to specify the config file path.
>> ** Configuration Error: file:$PROJECT_HOME/project/
>> out/production/project/org/apache/ctakes/lvg/data/config/lvg.properties
>> (No such file or directory)
>> ** Error: problem of opening/reading config file: 'file:$PROJECT_HOME
>> /project/out/production/project/org/apache/ctakes/lvg/data/config/lvg.properties'.
>> Use -x option to specify the config file path.
>
>
> even though, checking in that location of the project, properties is
> clearly there and I can open it and see its contents.
>
> This makes me suspect that I have not added them to the project correctly,
> so what should be done? Thanks for advice.
>