package ever.pipeline; import java.io.Serializable; import java.util.ArrayList; import java.util.Scanner; import java.util.regex.Pattern; /** * This class is used to store the output file from the SUNDANCE information extraction tool, * Modells the CaseFrame in the sense of the Sundance info. extraction tool * Example: * CaseFrame: ActVp_:POS__PREHEAT * Negation: false * Trigger(s): (PREHEAT) * DOBJ_Extraction = "a grill" [ENTITY,UNKNOWN] (POS) */ public class CaseFrame implements Serializable{ /** * */ private static final long serialVersionUID = 3; private static String ls =System.getProperty("line.separator"); /** *name of CF Ex: POS_PREHEAT */ private String name; /** * type of CF Ex: ActVp_ */ private String type; /** * Negation of CF: Ex: false */ private boolean neg; /** * Trigger of CF Ex: PREHEAT */ private String trigger; /** * what we extract ex: DOBJ_Extraction */ private String objectType; /** * Extraction of cf EX: a grill */ private String ex; /** * Semantic type of extracted Obj ex : ENTITY, UNKNOWN */ private String sem; /** * Type of pre positional expression for example until, to, with etc */ private String ppType; /** * Extracts the information for a Case Frame out of a String */ public CaseFrame(String in) { Scanner sc = new Scanner(in); sc.useDelimiter(ls); //skip empty line sc.next(); String[] oneLine = sc.next().split(":"); type=oneLine[1].trim(); name=oneLine[2].trim(); neg=Boolean.parseBoolean(sc.next().split(":")[1].trim()); trigger= sc.next().split(":")[1].trim(); trigger=trigger.replaceAll(Pattern.quote("("),""); trigger=trigger.replaceAll(Pattern.quote(")"),""); oneLine=sc.next().split("="); objectType=oneLine[0].trim(); ex=oneLine[1].split("\"")[1].trim(); ex=cleanValue(ex); if(oneLine.length>1) { String[] split2=oneLine[1].split("\""); if(split2.length>2) sem = split2[2].trim(); } if(type.equals("ActVp_Prep_")) { ppType=objectType.replace(")_Extraction", ""); ppType=ppType.replace("PP(",""); } } public String getName() { return name; } public boolean isNeg() { return neg; } public String getTrigger() { return trigger; } public String getType() { return type; } public String getEx() { return ex; } public String getSem() { return sem; } public String getPpType() { return ppType; } /* * Removes marker of sundance */ private String cleanValue(String in) { String out=""; out=in.replace("&&", ""); return out; } }