Johnsd11 commented on issue #64:
URL: https://github.com/apache/ctakes/issues/64#issuecomment-2836001362
To start, I would use XmiTreeReader to read in the XMI file(s). It can read
a single file or multiple files in a directory tree.
In your piper file, just add the line: "reader XmiTreeReader"
XmiTreeReader will automatically store metadata like doc ID, and file path.
The file path is stored in the cas as a DocumentPath type. To get it, you
can use code like the following (stolen from AbstractFileWriter):
/**
* @param jCas ye olde
* @return the full path to the file containing the processed text, or an
empty string ("") if unknown
*/
protected String getSourceFilePath( final JCas jCas ) {
final Collection<DocumentPath> documentPaths = JCasUtil.select( jCas,
DocumentPath.class );
if ( documentPaths == null || documentPaths.isEmpty() ) {
return "";
}
for ( DocumentPath documentPath : documentPaths ) {
final String path = documentPath.getDocumentPath();
if ( path != null && !path.isEmpty() ) {
return path;
}
}
return "";
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]