System.out.println("See Also: " + sense.getRelatedWords(WiktionaryRelation.SEE_ALSO).getMutableCollectionCopy()); System.out.println("Synonyms: " + sense.getRelatedWords(WiktionaryRelation.SYNONYM).getMutableCollectionCopy()); System.out.println("Gloss: " + sense.getGloss()); System.out.println("Parsed gloss terms: " + sense.getRelatedWords(WiktionaryRelation.GLOSS_TERMS).getMutableCollectionCopy()); ImmutableList<String> hypernyms = sense.getRelatedWords(WiktionaryRelation.HYPERNYM); System.out.println("Hypernyms: " + hypernyms.getMutableCollectionCopy()); System.out.println("\n***********************************************************\n");
ImmutableList<Map<Integer, Double>> featureVectors = treeHistory.getFeaturesVectors(); boolean withFeatureVectors = false; if (featureVectors.size()>0) if (featureVectors.size()!=specs.size())throw new TeEngineMlException("Malformed TreeHistory."); ImmutableIterator<Map<Integer, Double>> featureVectorIterator = featureVectors.iterator(); for (Specification spec : specs)
/** * redraw the tree and text in the "Selected Tree" pane * @throws ClassifierException * @throws VisualTracingToolException * @throws TeEngineMlException * @throws TreeAndParentMapException */ private void redrawCurrentSingleTreePane() throws ClassifierException, VisualTracingToolException, TeEngineMlException, TreeAndParentMapException { // double check if ((underLyingSystem != null) && (currentDisplayedTreeComponent != null) && (selectedTreeNextStack != null)) { // calc the index of the current component in the sequence of operations the user had selected in the "Existing Trees" pane SingleTreeComponent firstComponent = selectedTreeNextStack.isEmpty() ? currentDisplayedTreeComponent : selectedTreeNextStack.firstElement(); int ndxOfCurrentTreeComponent = firstComponent.getHistory().getComponents().size() - selectedTreeNextStack.size() -1; displaySingleTree(firstComponent, currentDisplayedTreeComponent, ndxOfCurrentTreeComponent); } }
private void redrawRegularSeachTreeAfterUpdatingTheComponentIndex() throws VisualTracingToolException { TreeHistoryComponent component = historyComponents.get(historyComponentsIndex); String imageTitle = makeTreeImageTitle(historyComponentsIndex, component.getSpecification().toString()); createAndDrawImageInComponent(component.getTree(), component.getAffectedNodes(), imageTitle, cpe.getRegularSearchImagePane()); }
public String toString() { return String.format("%s(%s, %s)", getClass().getSimpleName(), nominal, verbs.mutableListToString()); }
matchingTrees.addAll(thisIterationMatchingTrees); ImmutableList<SingleOperationItem> operations = script.getItemListForIteration(iterationIndex, treesSet); if (logger.isDebugEnabled()){logger.debug("#"+iterationIndex+": operations = "+operations.toString());} Set<TreeAndFeatureVector> generatedTrees = generateTreesFromSet(treesSet, operations); treesSet.addAll(generatedTrees);
try { relatedWords = sense.getRelatedWords(relation); } catch (WiktionaryException e) { throw new LexicalResourceException("Error in getRelatedWords for " + sense + " and for " + relation , e); } if (relation != null && relatedWords.contains(targetLemma))
displaySingleTree(treeComponent, treeComponent, treeComponent.getHistory().getComponents().size()-1);
@Override public Map<Integer, Double> updateFeatureVector( Map<Integer, Double> originalFeatureVector, FeatureUpdate featureUpdate, TreeAndParentMap<ExtendedInfo, ExtendedNode> textTree, TreeAndParentMap<ExtendedInfo, ExtendedNode> hypothesisTree, GenerationOperation<ExtendedInfo, ExtendedNode> operation, RuleSubstituteNodeSpecification<ChainOfLexicalRules> specification) throws TeEngineMlException { List<ConfidenceChainItem> chain = new ArrayList<ConfidenceChainItem>(specification.getRule().getChain().size()); for (LexicalRuleWithName lexicalRule : specification.getRule().getChain()) { chain.add( new ConfidenceChainItem(lexicalRule.getRuleBaseName(),lexicalRule.getRule().getConfidence())); } return featureUpdate.forChainOfRules(originalFeatureVector, new ImmutableListWrapper<ConfidenceChainItem>(chain)); }
logger.debug("costProfitGain = "+childElement.getCostProfitGain()+". History size = "+childElement.getHistory().getSpecifications().size());
public ChainOfLexicalRules(String lhsLemma, PartOfSpeech lhsPos, String rhsLemma, PartOfSpeech rhsPos, double confidence, ImmutableList<LexicalRuleWithName> chain) throws TeEngineMlException { super(lhsLemma, lhsPos, rhsLemma, rhsPos, confidence); this.chain = chain; if (null==chain) throw new TeEngineMlException("Null chain"); if (chain.size()==0)throw new TeEngineMlException("Empty chain"); if (!chain.get(0).getRule().getLhsLemma().equals(lhsLemma)) throw new TeEngineMlException("Bad chain: expected: "+lhsLemma+" but found: "+chain.get(0).getRule().getLhsLemma()+parametersDescription(lhsLemma, lhsPos, rhsLemma, rhsPos, confidence, chain)); if (!simplerPos(chain.get(0).getRule().getLhsPos().getCanonicalPosTag()).equals(simplerPos(lhsPos.getCanonicalPosTag()))) throw new TeEngineMlException("Bad chain: expected pos: "+simplerPos(lhsPos.getCanonicalPosTag())+", but found: "+simplerPos(chain.get(0).getRule().getLhsPos().getCanonicalPosTag())+parametersDescription(lhsLemma, lhsPos, rhsLemma, rhsPos, confidence, chain)); if (!chain.get(chain.size()-1).getRule().getRhsLemma().equals(rhsLemma)) throw new TeEngineMlException("Bad chain: expected rhsLemma: "+rhsLemma+" but found: "+chain.get(chain.size()-1).getRule().getRhsLemma()+parametersDescription(lhsLemma, lhsPos, rhsLemma, rhsPos, confidence, chain)); if (!simplerPos(chain.get(chain.size()-1).getRule().getRhsPos().getCanonicalPosTag()).equals(simplerPos(rhsPos.getCanonicalPosTag()))) throw new TeEngineMlException("Bad chain: expected rhs pos: "+simplerPos(rhsPos.getCanonicalPosTag())+", but found: "+simplerPos(chain.get(chain.size()-1).getRule().getRhsPos().getCanonicalPosTag())+parametersDescription(lhsLemma, lhsPos, rhsLemma, rhsPos, confidence, chain)); }
public static <I, S extends AbstractNode<I,S>> ChainOfRulesWithConfidenceAndDescription<I,S> fromChainOfLexicalRules(ChainOfLexicalRules chain, RuleWithConfidenceAndDescription<I, S> rule) { ArrayList<ConfidenceChainItem> list = new ArrayList<ConfidenceChainItem>(chain.getChain().size()); for (LexicalRuleWithName lexicalRule : chain.getChain()) { list.add(new ConfidenceChainItem(lexicalRule.getRuleBaseName(), lexicalRule.getRule().getConfidence())); } return new ChainOfRulesWithConfidenceAndDescription<I, S>( rule.getRule(), rule.getConfidence(), rule.getDescription()+": "+createDescription(chain), new ImmutableListWrapper<ConfidenceChainItem>(list)); }
if (historyComponents!=null){if (historyComponents.size()>0){if(null==sortedHistory){throw new VisualTracingToolException("sortedHistory is null");}}} if (originalTreeSentence == null) throw new VisualTracingToolException("Bug. no originalTreeSentence."); currentComponent = historyComponents.get(historyComponentsIndex); if (historyComponentsIndex==0) previousComponent = historyComponents.get(historyComponentsIndex-1);
if (historyComponentsIndex == historyComponents.size()) // if we are after clicking the "Perform Regular Search" button but before clicking Next/Previous
if (historyComponentsIndex < (historyComponents.size() - 1)) { ++historyComponentsIndex; redrawRegularSeachTreeAfterUpdatingTheComponentIndex(); if (historyComponentsIndex < (historyComponents.size() - 1)) { historyComponentsIndex = historyComponents.size() - 1; redrawRegularSeachTreeAfterUpdatingTheComponentIndex();