There's more...

If we desire to get the actual span displayed, we need to add the following code to the for loop:

String date = "";
for(int j=dateSpans[i].getStart(); j< dateSpans[i].getEnd(); j++) {
date += tokens[j] + " ";
}
System.out.println("Date: " + date);

This will produce the following output:

Entity: [1850s] was a date entity found starting at 6 and ending at 7
Date: 1850s
Entity: [March] was a date entity found starting at 13 and ending at 15
Date: March 3

This still does not give us an entire date that includes the year. Unfortunately, this is a limitation of the model. It treats the comma as the end of the date and ignores the year. If you remove the comma from the text, then the entire date will be retrieved.

We can also determine the probability that an entity was identified correctly. This is done using the NameFinderME class, probs method, which, when applied to the array of Span objects, will return an array of doubles representing the probability for each entity.

Replace the following statement that we used previously:

System.out.println("Date: " + date);

Add the following code sequence and re-execute the following code:

double[] spanProbs = nameFinderME.probs(dateSpans);
System.out.println("Date: " + date + " Probability: " + spanProbs[i]);

You will get the following output:

Entity: [1850s] was a date entity found starting at 6 and ending at 7
Date: 1850s Probability: 0.878211895731101
Entity: [March] was a date entity found starting at 13 and ending at 16
Date: March 3 Probability: 0.9937399307548391

The output reflects a high level of confidence that the date entities were identified correctly. The values returned will range from 0.0 to 1.0. The closer the value is to 1.0, the higher the level of confidence in the results

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.119.155