Package net.sf.nlpshell.domain.word.verb

Examples of net.sf.nlpshell.domain.word.verb.Verb


    SemanticFrame searchFrame = pos.frame();
    String frameString = searchFrame.toFrameString();
    System.out.println("Frame : " + frameString);

    // extract verb
    Verb verb = searchFrame.getVerb();

    // choose lemma
    IndexWord iw = Dictionary.getInstance().lookupIndexWord(
        net.didion.jwnl.data.POS.VERB, verb.text);
    System.out.println("lemma : " + iw.getLemma());
    System.out.println("senses : " + iw.getSenseCount());
    String verbLemma = iw.getLemma();

    // find verb interpretation
    File verbnetDir = new File("verbnet-3.1");
    if (!verbnetDir.exists()) {
      throw new IllegalStateException("Non trovo verbnet : ["
          + verbnetDir.getAbsolutePath() + "]");
    }
    Map<String, Set<VNCLASS>> frameMembers = new LinkedHashMap<String, Set<VNCLASS>>();
    Map<String, Set<VNSUBCLASS>> frameSubclassMembers = new LinkedHashMap<String, Set<VNSUBCLASS>>();
    JAXBContext jaxbContext = JAXBContext.newInstance("vn");
    Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
    FilenameFilter wildcardFileFilter = new WildcardFileFilter("*.xml");
    for (File verbnetFile : verbnetDir.listFiles(wildcardFileFilter)) {
      JAXBElement<VNCLASS> jaxbElement;
      try {
        jaxbElement = unmarshaller.unmarshal(new StreamSource(
            verbnetFile), VNCLASS.class);
      } catch (Exception e) {
        throw new IllegalStateException("Impossibile elaborare : ["
            + verbnetFile.getAbsolutePath() + "]", e);
      }
      VNCLASS vnclass = jaxbElement.getValue();
      for (MEMBER member : vnclass.getMEMBERS().getMEMBER()) {
        if (frameMembers.containsKey(member.getName())) {
          frameMembers.get(member.getName()).add(vnclass);
        } else {
          Set<VNCLASS> classes = new HashSet<VNCLASS>();
          classes.add(vnclass);
          frameMembers.put(member.getName(), classes);
        }
      }
      for (VNSUBCLASS vnsubclass : vnclass.getSUBCLASSES()
          .getVNSUBCLASS()) {
        for (MEMBER member : vnsubclass.getMEMBERS().getMEMBER()) {
          if (frameMembers.containsKey(member.getName())) {
            frameMembers.get(member.getName()).add(vnclass);
          } else {
            Set<VNCLASS> classes = new HashSet<VNCLASS>();
            classes.add(vnclass);
            frameMembers.put(member.getName(), classes);
          }
          if (frameSubclassMembers.containsKey(member.getName())) {
            frameSubclassMembers.get(member.getName()).add(
                vnsubclass);
          } else {
            Set<VNSUBCLASS> classes = new HashSet<VNSUBCLASS>();
            classes.add(vnsubclass);
            frameSubclassMembers.put(member.getName(), classes);
          }
        }
      }
    }

    Set<String> knownPredicates = new HashSet<String>();
    knownPredicates.add("discover");
    Set<VNCLASS> vnclasses = frameMembers.get(verbLemma);
    // Set<VNSUBCLASS> vnSubclasses = frameSubclassMembers.get(verbLemma);
    VerbnetInfo verbnetInfo = chooseFrame(searchFrame, knownPredicates,
        vnclasses);
    int position = 0;
    List<Object> npOrVERBOrADJOrADVOrPREPOrLEX = verbnetInfo.frame
        .getSYNTAX().getNPOrVERBOrADJOrADVOrPREPOrLEX();
    for (final Object object : npOrVERBOrADJOrADVOrPREPOrLEX) {
      if (object instanceof NP) {
        NP np = (NP) object;
        FrameItem frameItem = searchFrame.components.get(position);
        frameItem.pos.thematicRole = ThematicRoles.valueOf(np
            .getValue().toUpperCase());
      }
      if (object instanceof VERB) {
        FrameItem frameItem = searchFrame.components.get(position);
        System.out.println("Verb : " + frameItem.pos.text);
        Verb v = ((Verb) frameItem.pos);
        v.predicate = Predicates.valueOf(verbnetInfo.predicate
            .getValue().toUpperCase());
      }
      position++;
    }
View Full Code Here


    }
    return frameString;
  }

  public Verb getVerb() {
    Verb v = null;
    for (FrameItem frameItem : this.components) {
      if (frameItem.pos instanceof Verb) {
        v = (Verb) frameItem.pos;
      }
    }
View Full Code Here

TOP

Related Classes of net.sf.nlpshell.domain.word.verb.Verb

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.