Sorry about the spam

Help
Anonymous
2003-11-25
2003-11-26
  • Anonymous - 2003-11-25

    Hi a couple of questions:

    Firstly I'm trying to find the common parent (between 2 nouns) from a relationship and then put it into an arraylist as either a string using getlemma or an indexword. Here is my non working code. Any help would be greatly apreciated, this is part of my final year project at uni.

                Synset[] synsetA = ((IndexWord) indexWordsList.get(0)).getSenses();
                Synset[] synsetB = ((IndexWord) indexWordsList.get(1)).getSenses();
               
                RelationshipList list = RelationshipFinder.getInstance().findRelationships(synsetA[0], synsetB[0], PointerType.HYPERNYM);

                    AsymmetricRelationship relationship  = (AsymmetricRelationship) list.getShallowest();
                   
                    PointerTargetNode n = (PointerTargetNode) relationship.getNodeList().get(relationship.getCommonParentIndex());
                    wordsNet.add(n.getWord().getLemma());

    Also this is the way im finding the POS of a given string, it seems very dirty is there a better way?

        public ArrayList changeWords(ArrayList words) throws JWNLException {
            ArrayList wordsNet = new ArrayList();
            ArrayList indexWordsList = new ArrayList();
            for(int i=0;i<words.size();i++){
                try{
                    Dictionary.getInstance().lookupIndexWord(POS.NOUN, ((String) words.get(i))).getLemma();
                    indexWordsList.add(Dictionary.getInstance().lookupIndexWord(POS.NOUN, ((String) words.get(i))));
                }
                catch (Exception e){
                    try{
                        Dictionary.getInstance().lookupIndexWord(POS.VERB, ((String) words.get(i))).getLemma();
                    }
                    catch (Exception f){
                        try{
                            Dictionary.getInstance().lookupIndexWord(POS.ADJECTIVE, ((String) words.get(i))).getLemma();
                           
                        }
                        catch (Exception g){
                            try{
                                Dictionary.getInstance().lookupIndexWord(POS.ADVERB, ((String) words.get(i))).getLemma();
                            }
                            catch (Exception h){
                                wordsNet.add((String) words.get(i));
                            }
                        }
                    }
                }
            }

    Again any help would be appreciated. I'm not an expert on wordnet or java (as you can indoubtedly tell) so if you think there is a better way of doing it please tell me.

    Given unlimited time I'm sure I would crack it, but deadlines are approaching.

    email me at nph4@ukc.ac.uk

     
    • Anonymous - 2003-11-26

      I'm now using this

                      wordsNet.add(n.getSynset().getWord(0).getLemma());

      instead which seems to work

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks