15 package cz.vutbr.fit.knot.annotations.modules.suggestionManager;
26 import cz.vutbr.fit.knot.annotations.modules.suggestionManager.alternative.*;
27 import cz.vutbr.fit.knot.annotations.modules.suggestionManager.attributes.*;
28 import java.io.IOException;
29 import java.io.StringReader;
30 import java.math.BigDecimal;
31 import java.text.SimpleDateFormat;
33 import java.util.logging.Level;
34 import java.util.logging.Logger;
35 import javax.xml.parsers.DocumentBuilder;
36 import javax.xml.parsers.DocumentBuilderFactory;
37 import javax.xml.parsers.ParserConfigurationException;
38 import org.w3c.dom.Document;
39 import org.w3c.dom.Node;
40 import org.w3c.dom.Element;
41 import org.w3c.dom.NodeList;
42 import org.xml.sax.InputSource;
43 import org.xml.sax.SAXException;
60 public static final String
MODULE_NAME =
"SECAPISuggestionTranslator";
101 HashMap<Integer, ArrayList<SuggestionFragment>> sugToLinFragments =
new HashMap<Integer, ArrayList<SuggestionFragment>>();
107 SECAPIResults = SECAPIResults.replace(
"<suggestion>",
108 "<suggestion xmlns:geo=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">");
111 Document doc =
parseXml(SECAPIResults);
114 String msg =
"Bad XML from SEC API: " + SECAPIResults;
115 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.SEVERE, msg);
120 Element docEl = doc.getDocumentElement();
121 HashMap<Integer,TranslateAlternativeHolder> alternatives =
new HashMap<Integer,TranslateAlternativeHolder>();
124 NodeList fragmentElements = docEl.getChildNodes();
125 int fCount = fragmentElements.getLength();
126 for (
int i= 0; i < fCount; i++) {
128 if(!(fragmentElements.item(i) instanceof Element)){
131 if(!((Element) fragmentElements.item(i)).getTagName().equalsIgnoreCase(
"text")){
135 Element fragmentEl = (Element) fragmentElements.item(i);
141 if(altFragment == null){
146 ArrayList<Alternative> alternativesFromSecApi =
processAlternatives(requestInfo,fragmentEl,newTypes,altFragment);
148 newAlternative.setUnconvertedAlternatives(alternativesFromSecApi);
151 dummyAlternative.setId(i);
152 dummyAlternative.addFragment(altFragment);
153 altFragment.setRefAlternative(dummyAlternative);
154 newAlternative.setDummyAlternative(dummyAlternative);
155 alternatives.put(i,newAlternative);
179 NodeList fragmentElements = atEl.getChildNodes();
180 int fCount = fragmentElements.getLength();
181 for (
int i = 0; i < fCount; i++) {
183 if (!(fragmentElements.item(i) instanceof Element)) {
186 if (!((Element) fragmentElements.item(i)).getTagName().equalsIgnoreCase(
"text")) {
190 Element fragmentEl = (Element) fragmentElements.item(i);
194 if (altFragment == null) {
198 NodeList annotationElements = fragmentEl.getChildNodes();
199 int aCount = annotationElements.getLength();
200 int alternativeCreated = 0;
205 for (
int j = 0; j < aCount; j++) {
209 if (!(annotationElements.item(j) instanceof Element)) {
212 if (!((Element) annotationElements.item(j)).getTagName().equalsIgnoreCase(
"annotation")) {
216 Element annotationEl = (Element) annotationElements.item(j);
220 if (nestedAlt != null) {
221 nestedAlt.setSourceDocument(requestInfo.getSession().getSyncDocument());
222 nestedAlt.setSource(requestInfo.getSession().getSyncDocument().getUriForAnnot());
223 nestedAlt.setSourceDocumentId(requestInfo.getSession().getSyncDocument().getId());
225 fr.setRefAlternative(nestedAlt);
226 nestedAlt.addFragment(fr);
244 ArrayList<Alternative> result =
new ArrayList<Alternative>();
245 NodeList annotationElements = alternatvesEl.getChildNodes();
246 int aCount = annotationElements.getLength();
247 int alternativeCreated = 0;
249 for (
int j = 0; j < aCount; j++) {
253 if(!(annotationElements.item(j) instanceof Element)){
256 if(!((Element) annotationElements.item(j)).getTagName().equalsIgnoreCase(
"annotation")){
260 Element annotationEl = (Element) annotationElements.item(j);
264 alt.setSourceDocument(requestInfo.getSession().getSyncDocument());
265 alt.setSource(requestInfo.getSession().getSyncDocument().getUriForAnnot());
266 alt.setSourceDocumentId(requestInfo.getSession().getSyncDocument().getId());
268 fr.setRefAlternative(alt);
285 String startOffsetStr = fragmentEl.getAttribute(
"s_offset");
286 String endOffsetStr = fragmentEl.getAttribute(
"e_offset");
287 String fragmentText = fragmentEl.getAttribute(
"string");
292 startOf = Integer.parseInt(startOffsetStr);
293 endOf = Integer.parseInt(endOffsetStr);
294 }
catch (Exception e) {
295 String msg =
"Bad fragment in SEC API output: " + startOffsetStr +
"," + endOffsetStr +
" " + fragmentText;
296 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.WARNING, msg);
299 if (startOf == null || endOf == null || startOf >= endOf) {
300 String msg =
"Bad fragment in SEC API output: " + startOffsetStr +
"," + endOffsetStr +
" " + fragmentText;
301 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.WARNING, msg);
317 HashMap<Integer, ArrayList<SuggestionFragment>> sugToLinFragments,
318 HashMap<Integer,TranslateAlternativeHolder> alternativesHolders){
320 ArrayList<AlternativeFragment> allLinFragments =
new ArrayList<AlternativeFragment>();
321 ArrayList<Alternative> result =
new ArrayList<Alternative>();
324 HashMap<String, Alternative> alternativeMap =
new HashMap<String, Alternative>();
325 ArrayList<AlternativeAttribute> nestedLinkedList =
new ArrayList<AlternativeAttribute>();
327 Iterator<TranslateAlternativeHolder> secAPIAlternativesIt = alternativesHolders.values().iterator();
328 while (secAPIAlternativesIt.hasNext()) {
330 ArrayList<Alternative> alternatives = currentAlternativeHolder.getUnconvertedAlternatives();
331 ArrayList<Suggestion> suggestionsFromDB = currentAlternativeHolder.getConvertedAlternatives();
334 Iterator<Alternative> altIt = alternatives.iterator();
335 while (altIt.hasNext()) {
337 if(tmpAlt.
getTmpId() != null && !tmpAlt.getTmpId().isEmpty()){
338 alternativeMap.put(tmpAlt.getTmpId(), tmpAlt);
346 altCount = currentAlternativeHolder.getConvertedAlternatives().size();
348 currentAlternativeHolder.sortUncoveredByCofidence();
350 Iterator<Alternative> alternativesIt = alternatives.iterator();
351 while (alternativesIt.hasNext()) {
352 Alternative currentAlternative = alternativesIt.next();
355 Suggestion alternativeOf = currentAlternative.getAlternativeOfSuggestion();
365 allLinFragments.add(currentAltFrag);
366 result.add(currentAlternative);
377 Iterator<AlternativeAttribute> attIt = currentAlternative.getAttributes().iterator();
378 while(attIt.hasNext()){
381 if(currentTmpAtt.
getUri() != null && !currentTmpAtt.getUri().isEmpty()){
382 nestedLinkedList.add(currentTmpAtt);
394 ArrayList<AlternativeAttribute>openNestedLinkedList = nestedLinkedList;
396 while(!openNestedLinkedList.isEmpty()){
399 if(alternativeMap.get(tmpAtt.
getUri()) != null){
400 Alternative alt = alternativeMap.get(tmpAtt.getUri());
405 if(tmpAtt.
getSimpleType().equalsIgnoreCase(
"NestedSuggestion")){
406 tmpAtt.setNestedAlternative(alt);
407 alt.setNestedInAlternative(tmpAtt.getRefAlternative());
409 else if (tmpAtt.
getSimpleType().equalsIgnoreCase(
"SuggestionLink")){
410 tmpAtt.setLinkedAlternative(alt);
413 if(!result.contains(alt)){
415 allLinFragments.add(alt.getFragmentsAL().
get(0));
418 Iterator<AlternativeAttribute> tmpIt = alt.getAttributes().iterator();
419 while(tmpIt.hasNext()){
422 openNestedLinkedList.add(at);
433 openNestedLinkedList.remove(tmpAtt);
436 @SuppressWarnings(
"unchecked")
437 ArrayList<Alternative> retList =
convertLinFragments(requestInfo, result, allLinFragments,
true);
450 private void findAlternativeSuggestions(HashMap<Integer,TranslateAlternativeHolder> alternatives, ArrayList<Suggestion> validSuggestions,HashMap<Integer, ArrayList<SuggestionFragment>> sugToLinFragments){
452 Iterator<TranslateAlternativeHolder> alternativesFromSECIt = alternatives.values().iterator();
453 while(alternativesFromSECIt.hasNext()){
456 Iterator<AlternativeFragment> currentFragmentsIt = currentAlternative.getDummyAlternative().getFragmentsAL().iterator();
457 while(currentFragmentsIt.hasNext()){
462 for (Iterator<Suggestion> sgIt = validSuggestions.iterator(); sgIt.hasNext();) {
464 if (!sugToLinFragments.containsKey(sg.
getId())) {
473 if (alternativeOf == null) {
477 currentFrag.getRefAlternative().setAlternativeOfSuggestion(alternativeOf);
479 currentAlternative.setAlternativeOf(alternativeOf);
481 ArrayList<Suggestion> findedSugg =
new ArrayList<Suggestion>();
483 List<Suggestion> alternativeSuggestions = AlternativeManager.getOtherSuggestions(alternativeOf.getId());
484 for (Iterator<Suggestion> sugIt = alternativeSuggestions.iterator(); sugIt.hasNext();) {
486 Integer sgId = sugg.getId();
487 if(!findedSugg.contains(sugg)){
488 findedSugg.add(sugg);
491 currentAlternative.setConvertedAlternatives(findedSugg);
505 public static void linearizeSuggestions(HashMap<Integer, ArrayList<SuggestionFragment>> linFragmentsMap, Document doc, ArrayList<Suggestion> suggestions){
506 ArrayList<ArrayList<SuggestionFragment>> notConverted =
new ArrayList<ArrayList<SuggestionFragment>>();
507 ArrayList<SuggestionFragment> linearizedFragments;
508 ArrayList<ArrayList<SuggestionFragment>> normalFragments =
new ArrayList<ArrayList<SuggestionFragment>>();
510 Iterator<Suggestion> suggestionsIt = suggestions.iterator();
511 while(suggestionsIt.hasNext()){
512 Suggestion currentSuggestion = suggestionsIt.next();
513 normalFragments.add(currentSuggestion.getFragmentsAL());
517 linearizedFragments = Linearizer.fragmentsToLinSugFragments(normalFragments,doc, notConverted,
true);
519 if(!linearizedFragments.isEmpty()){
520 Iterator<SuggestionFragment> linearizedFragsIt = linearizedFragments.iterator();
521 while(linearizedFragsIt.hasNext()){
525 if (currentLinFragment != null) {
526 if(linFragmentsMap.containsKey(currentLinFragment.
getRefSuggestion().getId())){
527 ArrayList<SuggestionFragment> resutFragments = linFragmentsMap.get(currentLinFragment.getSuggestion());
528 resutFragments.add(currentLinFragment);
530 ArrayList<SuggestionFragment> currentLinFrag =
new ArrayList<SuggestionFragment>();
531 currentLinFrag.add(currentLinFragment);
532 linFragmentsMap.put(currentLinFragment.getRefSuggestion().getId(), currentLinFrag);
548 HashMap<Integer, ArrayList<SuggestionFragment>> sugToLinFragments) {
549 for (Iterator<Suggestion> it = suggestions.iterator(); it.hasNext(); ) {
566 Document doc = requestInfo.getSession().getParsedSyncDocument();
569 ArrayList<AlternativeFragment> input =
new ArrayList<AlternativeFragment>();
571 ArrayList<ArrayList<AlternativeFragment>> badFragments =
new ArrayList<ArrayList<AlternativeFragment>>();
572 ArrayList<ArrayList<AlternativeFragment>> convertedFragments = Linearizer.linAltFragmentsToFragments(input, doc, badFragments);
574 String info =
"<module name=\"" + SECAPISuggestionTranslator.MODULE_NAME +
"\"/>";
575 int langNum = requestInfo.getSession().getLanguageNum();
578 if (convertedFragments == null || convertedFragments.size() != 1) {
581 ArrayList<AlternativeFragment> output = convertedFragments.get(0);
582 if (output.size() < 1) {
588 ArrayList<ArrayList<AlternativeFragment>> notConverted =
new ArrayList<ArrayList<AlternativeFragment>>();
589 ArrayList<ArrayList<AlternativeFragment>> comFragments =
new ArrayList<ArrayList<AlternativeFragment>>();
591 ArrayList<AlternativeFragment> input2 =
new ArrayList<AlternativeFragment>();
593 comFragments.add(input2);
595 ArrayList<AlternativeFragment> linearizedList;
596 linearizedList = Linearizer.fragmentsToLinAltFragments(comFragments,doc, notConverted,
true);
598 if (linearizedList.isEmpty()) {
602 return linearizedList.get(0);
614 ArrayList<Suggestion> result =
new ArrayList<Suggestion>();
615 ArrayList<SuggestionFragment> allLinFragments =
new ArrayList<SuggestionFragment>();
619 SECAPIResults = SECAPIResults.replace(
"<suggestion>",
620 "<suggestion xmlns:geo=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">");
623 Document doc =
parseXml(SECAPIResults);
626 String msg =
"Bad XML from SEC API: " + SECAPIResults;
627 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.SEVERE, msg);
631 Element docEl = doc.getDocumentElement();
632 HashMap<String, SugNestedAttribute> nestedInMap =
new HashMap<String, SugNestedAttribute>();
633 HashMap<String, ArrayList<SugLinkedAttribute>> linkedInMap =
new HashMap<String, ArrayList<SugLinkedAttribute>>();
635 NodeList fragmentElements = docEl.getChildNodes();
636 int fCount = fragmentElements.getLength();
637 for (
int i= 0; i < fCount; i++) {
639 if(!(fragmentElements.item(i) instanceof Element)){
642 if(!((Element) fragmentElements.item(i)).getTagName().equalsIgnoreCase(
"text")){
646 Element fragmentEl = (Element) fragmentElements.item(i);
647 String startOffsetStr = fragmentEl.getAttribute(
"s_offset");
648 String endOffsetStr = fragmentEl.getAttribute(
"e_offset");
649 String fragmentText = fragmentEl.getAttribute(
"string");
654 startOf = Integer.parseInt(startOffsetStr);
655 endOf = Integer.parseInt(endOffsetStr);
656 }
catch (Exception e) {
657 String msg =
"Bad fragment in SEC API output: " + startOffsetStr +
"," + endOffsetStr +
" " + fragmentText;
658 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.WARNING, msg);
661 if (startOf == null || endOf == null || startOf >= endOf) {
662 String msg =
"Bad fragment in SEC API output: " + startOffsetStr +
"," + endOffsetStr +
" " + fragmentText;
663 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.WARNING, msg);
667 NodeList annotationElements = fragmentEl.getChildNodes();
668 int aCount = annotationElements.getLength();
669 for (
int j = 0; j < aCount; j++) {
671 if(!(annotationElements.item(j) instanceof Element)){
674 if(!((Element) annotationElements.item(j)).getTagName().equalsIgnoreCase(
"annotation")){
678 Element annotationEl = (Element) annotationElements.item(j);
682 sug.setSourceDocument(requestInfo.getSession().getSyncDocument());
683 sug.setSource(requestInfo.getSession().getSyncDocument().getUriForAnnot());
684 sug.setSourceDocumentId(requestInfo.getSession().getSyncDocument().getId());
685 sug.setIsFromSECAPI(
true);
686 if (requestInfo.
getSession() != null && requestInfo.getSession().getSugRequestFlag()) {
687 sug.setDisplayConfidence(
true);
690 fr.setRefSuggestion(sug);
692 allLinFragments.add(fr);
704 Iterator<SugBaseAttribute> attrIt = sug.getAttributes().iterator();
705 while(attrIt.hasNext()){
707 if(tmpAttr.
getSimpleType().equalsIgnoreCase(
"NestedSuggestion")){
708 if(tmpAttr.
getUri() != null && !tmpAttr.getUri().isEmpty()){
712 else if(tmpAttr.
getSimpleType().equalsIgnoreCase(
"SuggestionLink")){
713 if(tmpAttr.
getUri() != null && !tmpAttr.getUri().isEmpty()){
714 ArrayList<SugLinkedAttribute> list = linkedInMap.get(tmpAttr.getUri());
716 list =
new ArrayList<SugLinkedAttribute>();
719 linkedInMap.put(tmpAttr.getUri(), list);
734 Iterator<Suggestion> sugIt = result.iterator();
735 while(sugIt.hasNext()){
737 if(nestedInMap.get(s.
getTmpId()) != null){
738 s.setNestedInSuggestion(nestedInMap.get(s.getTmpId()).getRefSuggestion());
739 nestedInMap.get(s.getTmpId()).setNestedSuggestion(s);
740 nestedInMap.remove(s.getTmpId());
742 else if(linkedInMap.get(s.
getTmpId()) != null){
743 Iterator<SugLinkedAttribute> attIt = linkedInMap.get(s.getTmpId()).iterator();
744 while(attIt.hasNext()){
745 attIt.next().setLinkedSuggestion(s);
747 linkedInMap.remove(s.getTmpId());
752 Iterator<SugNestedAttribute> nestedAttIt = nestedInMap.values().iterator();
753 while(nestedAttIt.hasNext()){
754 nestedAttIt.next().setUri(null);
757 Iterator<ArrayList<SugLinkedAttribute>> linkedALIt = linkedInMap.values().iterator();
758 while(linkedALIt.hasNext()){
759 Iterator<SugLinkedAttribute> linkedAttIt = linkedALIt.next().iterator();
760 while(linkedAttIt.hasNext()){
761 linkedAttIt.next().setUri(null);
765 @SuppressWarnings(
"unchecked")
766 ArrayList<Suggestion> retList =
convertLinFragments(requestInfo, result, allLinFragments,
false);
784 NodeList fragmentElements = attEl.getChildNodes();
785 int fCount = fragmentElements.getLength();
786 for (
int i = 0; i < fCount; i++) {
788 if (!(fragmentElements.item(i) instanceof Element)) {
791 if (!((Element) fragmentElements.item(i)).getTagName().equalsIgnoreCase(
"text")) {
794 Element fragmentEl = (Element) fragmentElements.item(i);
795 String startOffsetStr = fragmentEl.getAttribute(
"s_offset");
796 String endOffsetStr = fragmentEl.getAttribute(
"e_offset");
797 String fragmentText = fragmentEl.getAttribute(
"string");
802 startOf = Integer.parseInt(startOffsetStr);
803 endOf = Integer.parseInt(endOffsetStr);
804 }
catch (Exception e) {
805 String msg =
"Bad fragment in SEC API output: " + startOffsetStr +
"," + endOffsetStr +
" " + fragmentText;
806 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.WARNING, msg);
809 if (startOf == null || endOf == null || startOf >= endOf) {
810 String msg =
"Bad fragment in SEC API output: " + startOffsetStr +
"," + endOffsetStr +
" " + fragmentText;
811 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.WARNING, msg);
815 NodeList annotationElements = fragmentEl.getChildNodes();
816 int aCount = annotationElements.getLength();
817 for (
int j = 0; j < aCount; j++) {
819 if (!(annotationElements.item(j) instanceof Element)) {
822 if (!((Element) annotationElements.item(j)).getTagName().equalsIgnoreCase(
"annotation")) {
826 Element annotationEl = (Element) annotationElements.item(j);
830 sug.setSourceDocument(requestInfo.getSession().getSyncDocument());
831 sug.setSource(requestInfo.getSession().getSyncDocument().getUriForAnnot());
832 sug.setSourceDocumentId(requestInfo.getSession().getSyncDocument().getId());
833 sug.setIsFromSECAPI(
true);
835 fr.setRefSuggestion(sug);
854 @SuppressWarnings(
"unchecked")
859 Collections.sort(allLinFragments);
860 }
catch (Exception e) {
862 String msg =
"Some fragments from SEC API was not sorted successfully.";
863 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.SEVERE, msg);
865 return (useAlternatives ?
new ArrayList<Alternative>() :
new ArrayList<Suggestion>());
869 ArrayList sortedSug = (useAlternatives ?
new ArrayList<Alternative>() :
new ArrayList<Suggestion>());
870 Iterator allInIterator = allLinFragments.iterator();
871 while(allInIterator.hasNext()){
873 sortedSug.add(frag.getRefSecSuggestion());
877 Iterator unsortedSugIt = result.iterator();
878 while(unsortedSugIt.hasNext()){
880 if(actualSug.
getFragments() != null || !actualSug.getFragments().isEmpty()){
881 unsortedSugIt.remove();
886 result.addAll(0, sortedSug);
889 ArrayList badFragments = (useAlternatives ?
890 new ArrayList<ArrayList<AlternativeFragment>>()
891 :
new ArrayList<ArrayList<SuggestionFragment>>());
893 ArrayList convertedFragments = (useAlternatives ?
894 Linearizer.linAltFragmentsToFragments(allLinFragments, requestInfo.getSession().getParsedSyncDocument(), badFragments)
897 String info =
"<module name=\"" + SECAPISuggestionTranslator.MODULE_NAME +
"\"/>";
898 int langNum = requestInfo.getSession().getLanguageNum();
901 if (convertedFragments == null || convertedFragments.size() != allLinFragments.size()) {
902 int lod = requestInfo.getSession().getProtocolLOD();
905 String msg =
"Some fragments from SEC API was not converted successfully.";
906 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.SEVERE, msg);
908 return (useAlternatives ?
new ArrayList<Alternative>() :
new ArrayList<Suggestion>());
911 if (badFragments != null) {
912 Iterator badFrIt = badFragments.iterator();
913 while (badFrIt.hasNext()) {
914 ArrayList badFrListForSug = (useAlternatives ?
915 (ArrayList<AlternativeFragment>) badFrIt.next()
916 : (ArrayList<SuggestionFragment>) badFrIt.next());
917 Iterator badFrItForSug = badFrListForSug.iterator();
918 while (badFrItForSug.hasNext()) {
920 String msg =
"This fragment from SEC API was not converted successfully: ";
921 msg = msg +
" offset: " + fragment.getOffset()
922 +
" length: " + fragment.
getLength() +
" text: " + fragment.getAnnotatedText();
923 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.SEVERE, msg);
929 Iterator linFrIt = allLinFragments.iterator();
930 Iterator newFrIt = convertedFragments.iterator();
931 for (Iterator sIt = result.iterator(); sIt.hasNext();) {
934 if (sug.
getFragments() != null && sug.getFragments().isEmpty()) {
937 if (useAlternatives) {
938 ((
Alternative) sug).setFragments(
new ArrayList<AlternativeFragment>());
940 ((
Suggestion) sug).setFragments(
new ArrayList<SuggestionFragment>());
943 ArrayList fragments = (ArrayList) newFrIt.next();
944 for (Iterator nFrIt = fragments.iterator(); nFrIt.hasNext();) {
946 newFr.setRefSecSuggestion(linFr.getRefSecSuggestion());
947 sug.addSecFragment(newFr);
962 @SuppressWarnings(
"unchecked")
964 int lNum = requestInfo.getSession().getLanguageNum();
966 String typeStr = el.getAttribute(
"type");
967 String tmpIdStr = el.getAttribute(
"id");
969 if (typeStr == null || typeStr.isEmpty()) {
971 String msg =
"Suggestion from SEC API without type.";
972 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.SEVERE, msg);
977 String typePath = typeStr;
978 Integer typeIndex = Localisation.TYPE_PATH_NUMBERS.get(typeStr);
979 if (typeIndex != null) {
980 typePath = Localisation.getKBStr(lNum, typeIndex);
983 NodeList attributeElements = el.getChildNodes();
984 int atCount = attributeElements.getLength();
986 boolean isCorefefence =
false;
987 for (
int i = 0; i < atCount; i++) {
988 if(!(attributeElements.item(i) instanceof Element)){
991 if(!((Element) attributeElements.item(i)).getTagName().equalsIgnoreCase(
"attribute")){
995 Element attrEl = (Element) attributeElements.item(i);
996 String nameStr = attrEl.getAttribute(
"name");
997 if (nameStr != null && nameStr.equalsIgnoreCase(
"coreference")) {
998 String valueStr = MessageProcessor.getElementContent(attrEl);
999 if (valueStr != null) {
1002 v = Integer.parseInt(valueStr);
1003 }
catch (Exception e) {
1005 if ((v != null && v > 0) || valueStr.equalsIgnoreCase(
"true")) {
1006 isCorefefence =
true;
1013 if (isCorefefence) {
1017 boolean typeCreated =
false;
1018 ArrayList<AnnotTypeAttr> atList =
new ArrayList<AnnotTypeAttr>();
1021 if (annotType == null) {
1023 String msg =
"Unable to obtain suggestion type";
1024 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.SEVERE, msg);
1029 else if (annotType.getId() == null && annotType.getAttributes().isEmpty()) {
1030 newTypes.addAll(SuggestionManager.breakdownType(annotType, requestInfo, newTypes));
1031 newTypes.add(annotType);
1036 ArrayList sugAList = (useAlternatives ?
new ArrayList<AlternativeAttribute>() :
new ArrayList<SugBaseAttribute>());
1038 HashMap<String, Integer> atPriorities =
getPriorities(typeStr);
1039 HashMap<String, Integer> usedPriorities =
new HashMap<String, Integer>();
1042 for (
int i = 0; i < atCount; i++) {
1043 if(!(attributeElements.item(i) instanceof Element)){
1046 if(!((Element) attributeElements.item(i)).getTagName().equalsIgnoreCase(
"attribute")){
1051 Element attrEl = (Element) attributeElements.item(i);
1053 String nameStr = attrEl.getAttribute(
"name");
1054 if (nameStr != null && nameStr.equalsIgnoreCase(
"coreference")) {
1058 if(nameStr != null && nameStr.equalsIgnoreCase(
"confidence")){
1060 String confidenceRawVal = MessageProcessor.getElementContent(attrEl);
1061 Integer confidenceValue;
1063 confidenceValue = Integer.parseInt(confidenceRawVal);
1064 }
catch (Exception e) {
1067 String msg =
"Can't decode confidence attribute from sec api. Attribute:" + confidenceRawVal;
1068 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.SEVERE, msg);
1074 if(useAlternatives){
1075 Alternative tmpAlt = (Alternative) sug;
1076 tmpAlt.setConfidence(confidenceValue);
1079 tmpSug.setConfidence(confidenceValue);
1084 SecAttribute attr =
processAttributeEl(requestInfo, attrEl, sugAList, atPriorities, usedPriorities, pGen, atList, useAlternatives, sug, newTypes);
1087 attr.setRefSecSuggestion(sug);
1095 if (useAlternatives) {
1096 Alternative tmpAlt = (Alternative) sug;
1108 Iterator<SecAttribute> sait = sugAList.iterator();
1112 while (sait.hasNext()) {
1117 pri = sba.getPriority();
1123 pri = sba.getPriority();
1129 if (latitude != null && longitude != null) {
1131 BigDecimal lat = null;
1132 BigDecimal lon = null;
1133 String latStr = latitude.getStringValue();
1134 if (latStr != null && latStr.startsWith(
"\"") && latStr.endsWith(
"\"")) {
1135 latStr = latStr.substring(1,latStr.length() - 1);
1137 String longStr = longitude.getStringValue();
1138 if (longStr != null && longStr.startsWith(
"\"") && longStr.endsWith(
"\"")) {
1139 longStr = longStr.substring(1,longStr.length() - 1);
1141 if (latitude.getStringValue() != null && !latitude.getStringValue().equals(
"")) {
1142 lat =
new BigDecimal(latStr);
1144 if (longitude.
getStringValue() != null && !longitude.getStringValue().equals(
"")) {
1145 lon =
new BigDecimal(longStr);
1147 if (latitude.getDecValue() != null) {
1148 lat = latitude.getDecValue();
1151 lon = longitude.getDecValue();
1155 geoAt.setRefSecSuggestion(sug);
1156 sugAList.add(geoAt);
1157 }
catch (NumberFormatException e) {
1158 if (latitude.getStringValue() != null && longitude.getStringValue() != null) {
1163 geoAt.setRefSecSuggestion(sug);
1164 sugAList.add(geoAt);
1167 }
else if (latitude != null) {
1168 sugAList.add(latitude);
1169 }
else if (longitude != null) {
1170 sugAList.add(longitude);
1173 if (useAlternatives) {
1174 ((Alternative) sug).setAttributes(sugAList);
1175 ((Alternative) sug).setTmpId(tmpIdStr);
1183 Iterator<AnnotTypeAttr> atIt = atList.iterator();
1184 while (atIt.hasNext()) {
1186 ata.setAnnotationType(annotType);
1188 annotType.setAttributes(atList);
1201 ArrayList<SecApiReqTypeDef> des = AppBean.getDesTypeDefinitions();
1202 Iterator<SecApiReqTypeDef> dIt = des.iterator();
1203 while (dIt.hasNext()) {
1207 return rtd.getPriorities();
1212 return new HashMap<String, Integer>();
1232 HashMap<String, Integer>atPriorities,
1233 HashMap<String, Integer>usedPriorities,
1234 int pGen, ArrayList<AnnotTypeAttr> atList,
1235 boolean useAlternatives,
1237 ArrayList<AnnotType> newTypes) {
1238 int lNum = requestInfo.getSession().getLanguageNum();
1240 String nameStr = atEl.getAttribute(
"name");
1241 String typeStr = atEl.getAttribute(
"type");
1242 String valueStr = null;
1247 if(!typeStr.equalsIgnoreCase(
"entity")){
1248 valueStr = MessageProcessor.getElementContent(atEl);
1252 if (nameStr == null || nameStr.isEmpty()) {
1254 String msg =
"Attribute of suggestion from SEC API without name.";
1255 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.SEVERE, msg);
1259 if (typeStr == null || typeStr.isEmpty()) {
1261 String msg =
"Attribute of suggestion from SEC API without type.";
1262 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.SEVERE, msg);
1267 if (typeStr.equals(
"url") || typeStr.equals(
"Url") || typeStr.equals(
"uri") || typeStr.equals(
"Uri")) {
1271 String origName = nameStr;
1273 Integer nameIndex = Localisation.KB_STRINGS_INTERNAL.indexOf(nameStr);
1276 if (typeStr.equals(
"URI") && valueStr != null && !valueStr.isEmpty()) {
1277 sug.setSAEntityIdentifier(valueStr);
1281 }
else if (nameIndex > 0) {
1282 nameStr = Localisation.getKBStr(lNum, nameIndex);
1285 String ucType = Character.toUpperCase(typeStr.charAt(0)) + typeStr.substring(1);
1288 && !valueStr.startsWith(
"http")) {
1289 valueStr = AppBean.getKBImagePrefix() + valueStr;
1295 if (ucType.equals(
"Date")) {
1296 if (valueStr == null || valueStr.isEmpty()) {
1297 result = (useAlternatives ?
1302 if (dateVal == null) {
1303 result = (useAlternatives ?
1307 result = (useAlternatives ?
1310 if (useAlternatives) {
1311 AlternativeAttribute tmpAt = (AlternativeAttribute) result;
1312 tmpAt.setBoolVAlue(
true);
1315 tmpAt.setBoolVAlue(
true);
1323 else if(ucType.equalsIgnoreCase(
"GeoPoint")){
1326 result = (useAlternatives ?
1333 if (useAlternatives) {
1338 }
catch (ClassNotFoundException ex) {
1340 String msg =
"Unknown type of attribute of suggestion from SEC API: " + typeStr;
1341 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.SEVERE, msg);
1344 }
catch (IllegalArgumentException ex) {
1346 String msg =
"Bad value of attribute of suggestion from SEC API: " + valueStr +
" (type " + typeStr +
")";
1347 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.WARNING, msg);
1349 result = (useAlternatives ?
1358 else if(ucType.equalsIgnoreCase(
"Entity")){
1361 result = (useAlternatives ?
1366 if (useAlternatives) {
1367 ArrayList<AltEntityAdditionalAttribute> altAddAttList;
1371 ArrayList<SugEntityAdditionalAttribute> sugAddAttList;
1376 }
catch (ClassNotFoundException ex) {
1378 String msg =
"Unknown type of attribute of suggestion from SEC API: " + typeStr;
1379 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.SEVERE, msg);
1386 result = (useAlternatives ?
1389 if (useAlternatives) {
1394 }
catch (ClassNotFoundException ex) {
1396 String msg =
"Unknown type of attribute of suggestion from SEC API: " + typeStr;
1397 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.SEVERE, msg);
1400 }
catch (IllegalArgumentException ex) {
1402 String msg =
"Bad value of attribute of suggestion from SEC API: " + valueStr +
" (type " + typeStr +
")";
1403 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.WARNING, msg);
1405 result = (useAlternatives ?
1414 if (ucType.equalsIgnoreCase(
"LinkedAnnotation") || ucType.equalsIgnoreCase(
"AnnotationLink")) {
1417 result = (useAlternatives
1421 String typeName = atEl.getAttribute(
"annotType");
1424 if (typeName != null) {
1425 Integer typeIndex = Localisation.TYPE_PATH_NUMBERS.get(typeStr);
1426 if (typeIndex != null) {
1427 typeName = Localisation.getKBStr(lNum, typeIndex);
1429 type =
findType(requestInfo, newTypes, typeName);
1433 String msg =
"Unable to obtain suggestion type";
1434 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.SEVERE, msg);
1439 else if (type.getId() == null && type.getAttributes().isEmpty()) {
1440 newTypes.addAll(SuggestionManager.breakdownType(type, requestInfo, newTypes));
1445 if (useAlternatives) {
1451 if (valueStr != null && !valueStr.isEmpty()) {
1452 if (useAlternatives) {
1458 }
catch (ClassNotFoundException ex) {
1460 String msg =
"Unknown type of attribute of suggestion from SEC API: " + typeStr;
1461 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.SEVERE, msg);
1469 else if (ucType.equalsIgnoreCase(
"NestedAnnotation")) {
1472 result = (useAlternatives ?
1476 String typeName = atEl.getAttribute(
"annotType");
1479 if (typeName != null) {
1480 Integer typeIndex = Localisation.TYPE_PATH_NUMBERS.get(typeStr);
1481 if (typeIndex != null) {
1482 typeName = Localisation.getKBStr(lNum, typeIndex);
1484 type =
findType(requestInfo, newTypes, typeName);
1488 String msg =
"Unable to obtain suggestion type";
1489 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.SEVERE, msg);
1494 else if (type.getId() == null && type.getAttributes().isEmpty()) {
1495 newTypes.addAll(SuggestionManager.breakdownType(type, requestInfo, newTypes));
1500 if (useAlternatives) {
1506 String tmpUri = valueStr;
1507 if (valueStr.startsWith(
"<text")) {
1509 }
else if (valueStr.replaceAll(
"[\\s\\u00A0]+$",
"").contentEquals(
"")) {
1512 if (tmpUri != null && !tmpUri.isEmpty()) {
1513 if (useAlternatives) {
1520 if (useAlternatives) {
1531 }
catch (ClassNotFoundException ex) {
1533 String msg =
"Unknown type of attribute of suggestion from SEC API: " + typeStr;
1534 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.SEVERE, msg);
1541 Integer p = usedPriorities.get(origName);
1543 p = atPriorities.get(origName);
1548 while (usedPriorities.containsValue(p)) {
1552 if (result != null) {
1553 result.setPriority(p);
1554 usedPriorities.put(origName, p);
1558 if (useAlternatives) {
1585 ArrayList<SugEntityAdditionalAttribute> result =
new ArrayList<SugEntityAdditionalAttribute>();
1586 for (Node node = el.getFirstChild(); node != null; node = node.getNextSibling()) {
1587 if (!(node instanceof Element)) {
1590 if (!((Element) node).getTagName().equalsIgnoreCase(
"entityAttribute")) {
1594 String nameStr = ((Element) node).getAttribute(
"name");
1595 String typeStr = ((Element) node).getAttribute(
"type");
1596 String valueStr = MessageProcessor.getElementContent(((Element) node));
1615 ArrayList<AltEntityAdditionalAttribute> result =
new ArrayList<AltEntityAdditionalAttribute>();
1616 for (Node node = el.getFirstChild(); node != null; node = node.getNextSibling()) {
1617 if (!(node instanceof Element)) {
1620 if (!((Element) node).getTagName().equalsIgnoreCase(
"entityAttribute")) {
1624 String nameStr = ((Element) node).getAttribute(
"name");
1625 String typeStr = ((Element) node).getAttribute(
"type");
1626 String valueStr = MessageProcessor.getElementContent(((Element) node));
1643 for (Node node = el.getFirstChild(); node != null; node = node.getNextSibling()) {
1644 if (!(node instanceof Element)) {
1648 Element tmpEl = (Element) node;
1649 if (tmpEl.getTagName().equals(
"geo:Point")) {
1650 for (Node innerNode = tmpEl.getFirstChild(); innerNode != null; innerNode = innerNode.getNextSibling()) {
1651 if (!(innerNode instanceof Element)) {
1654 if (((Element) innerNode).getTagName().equals(
"geo:lat")) {
1658 }
else if (((Element) innerNode).getTagName().equals(
"geo:long")) {
1679 for (Node n = node; n != null; n = n.getNextSibling()) {
1680 if (n.getNodeValue() != null) {
1681 return n.getNodeValue();
1695 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
1696 dbf.setNamespaceAware(
true);
1699 DocumentBuilder db = dbf.newDocumentBuilder();
1700 InputSource is =
new InputSource();
1701 is.setCharacterStream(
new StringReader(XMLString));
1703 }
catch (ParserConfigurationException pce) {
1705 String msg =
"ParserConfigurationException while parsing XML from the SEC API.";
1706 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.SEVERE, msg, pce);
1709 }
catch (SAXException se) {
1711 String msg =
"SAXException while parsing XML from the SEC API.";
1712 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.ALL, msg, se);
1715 }
catch (IOException ioe) {
1717 String msg =
"IOException while parsing XML from the SEC API.";
1718 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.SEVERE, msg, ioe);
1733 if (sDate == null || sDate.isEmpty()) {
1736 if (sDate.length() == 4 || sDate.length() == 7) {
1739 if (sDate.length() < 10) {
1741 String msg =
"Wrong date format from SEC API: " + sDate;
1742 Logger.getLogger(SECAPISuggestionTranslator.class.getName()).log(Level.SEVERE, msg);
1746 int index1 = sDate.indexOf(
"-");
1747 int index2 = sDate.lastIndexOf(
"-");
1748 if (index1 == -1 || index2 == -1 || index1 == index2) {
1751 if (sDate.substring(index1 + 1, index2).equals(
"00")) {
1754 if (sDate.length() - index2 == 3) {
1755 if (sDate.substring(index2 + 1).equals(
"00")) {
1761 date =
new SimpleDateFormat(
"yyyy-MM-dd").parse(sDate);
1762 }
catch (Exception e) {
1788 String typeUri =
baseTypeUri +
"g" + group.getId() +
"/" + typePath;
1791 return typesBuffer.get(typeUri);
1794 if (newTypes != null && !newTypes.isEmpty()) {
1795 Iterator<AnnotType> annotTypeIt = newTypes.iterator();
1796 while (annotTypeIt.hasNext()) {
1798 if (aT.
getUri() != null && aT.getUri().equals(typeUri)) {
1804 Object[] params =
new Object[2];
1806 params[1] = typeUri;
1808 List tList = AppBean.getPersistenceManager().queryDB(
"AnnotType.findByUri", params);
1810 if (tList != null && !tList.isEmpty()) {
1811 typesBuffer.put(typeUri, (
AnnotType) tList.get(0));
1816 return new AnnotType(typeUri, typePath, null, group);
1893 Iterator<Alternative> unconvertedIt = unconvertedAlternatives.iterator();
1894 while(unconvertedIt.hasNext()){
1895 unconvertedIt.next().setAlternativeOfSuggestion(alternativeOf);
1915 int result = o1.getConfidence().compareTo(o2.
getConfidence());
1919 return (result * (-1));
void sortUncoveredByCofidence()
ArrayList< Alternative > unconvertedAlternatives
Class representing attribute of alternative of suggestion.
static HashMap< String, Integer > getPriorities(String name)
Alternative processNestedAlternative(Element atEl, RequestInfo requestInfo, ArrayList< AnnotType > newTypes)
Suggestion getRefSuggestion()
Class representing attribute of type Date for prupose of suggestion.
static ArrayList< AltEntityAdditionalAttribute > processAltEntityAddAttributes(Element el, AlternativeAttribute refAltAtt)
Utility functions for document linearization.
static String processGeoPoint(Element el, boolean latitude)
static final int LOG_LEVEL_ALL_ERRORS
int compare(Alternative o1, Alternative o2)
Additional attribute of entity in suggestion attribute.
Attribute manager provides a way how to create new attributes for prupose of suggestion.
UserGroup defaultUserGroup
Interface for Suggestion and Alternative.
static AlternativeFragment processAlternativeFragment(Element fragmentEl)
Class representing attribute of type of annotation.
static void linearizeSuggestions(HashMap< Integer, ArrayList< SuggestionFragment >> linFragmentsMap, Document doc, ArrayList< Suggestion > suggestions)
static final int KB_ENTITY_URI
Class for manipulation with alternatives of suggestions.
static final String STRING_ATT_VALUES_SEPARATOR
static final int KB_LATITUDE
static final int KB_PERSON_NAME
SecAttribute processAttributeEl(RequestInfo requestInfo, Element atEl, ArrayList sugAList, HashMap< String, Integer >atPriorities, HashMap< String, Integer >usedPriorities, int pGen, ArrayList< AnnotTypeAttr > atList, boolean useAlternatives, SecSuggestion sug, ArrayList< AnnotType > newTypes)
static Document parseXml(String XMLString)
String getAnnotatedText()
Class representing attribute of type NestedAnnotation for peupose of suggestion.
static final int LOG_LEVEL_SERVER_INTERNAL_ERRORS
Singleton for storing global variables.
boolean isAlternativeInSuggestionList(List< Suggestion > suggestions, Alternative alt, HashMap< Integer, ArrayList< SuggestionFragment >> sugToLinFragments)
Class representing vocabulary entity attribute for prupose of suggestion.
static final Boolean COMPLETE_IMAGE_URI
ArrayList< Alternative > processAlternatives(RequestInfo requestInfo, Element alternatvesEl, ArrayList< AnnotType > newTypes, AlternativeFragment altFragment)
Class representing attribute of type GeoPoint.
Class representing attribute of suggestion.
Class representing suggested annotation fragment.
static final Boolean DISPLAY_TERM_TO_NAME
ArrayList< Suggestion > getConvertedAlternatives()
static final ArrayList< String > SIMPLE_TYPES
Static class which parses and process XML with messages.
Class representing user group.
Interface for SugBaseAttribute and AlternativeAttribuge.
void findAlternativeSuggestions(HashMap< Integer, TranslateAlternativeHolder > alternatives, ArrayList< Suggestion > validSuggestions, HashMap< Integer, ArrayList< SuggestionFragment >> sugToLinFragments)
ArrayList convertLinFragments(RequestInfo requestInfo, ArrayList result, ArrayList allLinFragments, boolean useAlternatives)
Methods for translating output from SEC API to the Suggestion objects.
static final String LONGITUDE_NAME
static final int KB_COREFERENCE_TO
Class representing attribute of type String for prupose of suggestion.
static String getGeoPointNodeValue(Node node)
ArrayList< Suggestion > convertedAlternatives
Class representing fragment for suggestion alternative.
ArrayList< Alternative > translateAlternativeFromSecApi(RequestInfo requestInfo, String SECAPIResults, ArrayList< AnnotType > newTypes, ArrayList< Suggestion > validSuggestions)
void setConvertedAlternatives(ArrayList< Suggestion > convertedAlternatives)
Class for creating of requested type definition for SEC API.
static final int MAX_COUNT_OF_ALTERNATIVES_TO_ONE_SUGGESTION
Alternative getDummyAlternative()
AlternativeFragment fixAlternativeFragment(RequestInfo requestInfo, AlternativeFragment frg)
static final int LOG_LEVEL
static final int DEFAULT_SUGGESTION_CONFIDENCE
static SugBaseAttribute createAttribute()
HashMap< String, Integer > getPriorities()
Class representing type of annotation.
SecSuggestion createSugFromElement(RequestInfo requestInfo, Element el, ArrayList< AnnotType > newTypes, boolean useAlternatives)
ArrayList< Alternative > makeNewAlternative(RequestInfo requestInfo, HashMap< Integer, ArrayList< SuggestionFragment >> sugToLinFragments, HashMap< Integer, TranslateAlternativeHolder > alternativesHolders)
static final String TEXT_ATT_VALUES_SEPARATOR
static final String LATITUDE_NAME
EditorSession getSession()
static final int LOG_LEVEL_ALL
Class representing additional attribute of entity in alternative attribute.
static boolean overlappingFragment(ArrayList< SuggestionFragment > sugFragments, int newFragStart, int newFragEnd)
Class representing attribute of type AnnotationLink for prupose of suggestion.
Alternative dummyAlternative
static String createErrorMsg(int version, int lNum, int error)
static ArrayList< ArrayList< SuggestionFragment > > linSugFragmentsToFragments(ArrayList< SuggestionFragment > linFragments, Document doc, ArrayList< ArrayList< SuggestionFragment >> badFragments)
Class consisting of traversing method and compare method.
static final String MODULE_NAME
Class representing alternative of suggestion.
Suggestion processNestedSugg(Element attEl, RequestInfo requestInfo, ArrayList< AnnotType > newTypes)
static final int LOG_LEVEL_SERVER_ERRORS
AnnotType findType(RequestInfo requestInfo, ArrayList< AnnotType > newTypes, String typePath)
Processed informations about client request.
Class representing suggestion of annotation.
static final int KB_LONGITUDE
static final Boolean IDENTIFIER_TO_ENTITY_URI
void setDummyAlternative(Alternative dummyAlternative)
The object that hold informations ipmortant for translate of alternative from SEC Api...
The object implements comparator of Alternative objects that are compared by confidence (from highest...
Class responsible for localised strings.
void setAlternativeOf(Suggestion alternativeOf)
boolean contentEqualsForSec(Suggestion other, ArrayList< SuggestionFragment > linearizedFragments, boolean testFragments)
HashMap< String, AnnotType > typesBuffer
static Date parseDate(String sDate)
static final int KB_GEO_LOCATION
void setUnconvertedAlternatives(ArrayList< Alternative > unconvertedAlternatives)
static String getKBStr(int langNum, int stringNum)
static ArrayList< SugEntityAdditionalAttribute > processSugEntityAddAttributes(Element el, SugEntityAttribute refEntity)
static final int ERROR_33_MODULE_ERROR
Interface for SuggestionFragment and AlternativeFragment.
ArrayList< Suggestion > translateSugFromSecApi(RequestInfo requestInfo, String SECAPIResults, ArrayList< AnnotType > newTypes)
ArrayList< Alternative > getUnconvertedAlternatives()
SECAPISuggestionTranslator(UserGroup userGroup)