monarch-initiative / HpoTextMining

Perform text mining for identification of HPO terms in free text from scientific publication.
10 stars 2 forks source link

String index out of range: -10 #19

Open pnrobinson opened 4 years ago

pnrobinson commented 4 years ago

The following text causes a crash:

d an 11-year-old girl (patient 2) who had onset of intractable seizures at 6 weeks of age. Seizure types included clustered focal seizures, infantile spasms, tonic, tonic-clonic, and myoclonic seizures. EEG at age 2 years showed slow and disorganized background with multifocal epileptiform discharges. Brain imaging at age 9 showed hypomyelination. At age 11, she had microcephaly, cerebral palsy, severe hypotonia, asymmetric lower extremity spasticity with inability to walk, cortical visual impairment, and profoundly impaired intellectual development with inability to speak.

Exception in thread "JavaFX Application Thread" java.lang.StringIndexOutOfBoundsException: String index out of range: -10
at java.lang.String.substring(String.java:1967)
at org.monarchinitiative.hpotextmining.gui.controller.Present.colorizeHTML4ciGraph(Present.java:226)
at org.monarchinitiative.hpotextmining.gui.controller.Present.setResults(Present.java:441)
at org.monarchinitiative.hpotextmining.gui.controller.HpoTextMining.lambda$new$0(HpoTextMining.java:88)
pnrobinson commented 4 years ago

This functionality works well in the vast majority of cases. I suppose there are some quick fixes

 int start = Math.max(term.getBegin(), offset);

can be changed to

 int start = Math.max(0,Math.max(term.getBegin(), offset));

or just have the SimplePhenotypeTerm never return less than zero

 @Override
    public int getBegin() {
        return begin;
    }

to

 @Override
    public int getBegin() {
        return Math.max(0,begin);
    }