LocalFileWrapper.java
Go to the documentation of this file.
00001 package instruction.wrapper;
00002 
00003 import java.io.File;
00004 import java.io.FileReader;
00005 import java.util.ArrayList;
00006 import java.util.List;
00007 
00008 public class LocalFileWrapper implements IHowtoWebsiteWrapper {
00009         
00010         String title = "";
00011         List<String> instructions = new ArrayList<String>();
00012         String url = null;
00013 
00014         public String getHowtoTitle() {
00015                 return title;
00016         }
00017 
00018         public List<String> getInstructions() {
00019                 return instructions;
00020         }
00021 
00022         public void load( String url ) {
00023                 File file = new File( url );
00024                 
00025                 this.url = url;
00026 
00027                 try {
00028                         // Read file to parse.
00029                         String parseString = "";
00030                         FileReader reader = new FileReader( file );
00031                         int read = reader.read();
00032 
00033                         while ( read >= 0 ) {
00034                                 parseString += (char) read;
00035                                 read = reader.read();
00036                         }
00037                         reader.close();
00038 
00039                         // Parse every sentence since Standford Parser
00040                         // can only cope with single sentences.
00041                         parseString = parseString.replaceAll( "\r", "" );
00042                         String[] sent = parseString.split( "\n" );
00043                         instructions.clear();
00044 
00045                         for ( int i = 0; i < sent.length; i++ ) {
00046                                 instructions.add( sent[i] );
00047                         }
00048                         
00049                         // Get title of HowTo
00050                         title = file.getName().replaceAll( "_", " " );
00051                         
00052                 }
00053                 catch ( Exception e ) {
00054                         e.printStackTrace();
00055                 }
00056         }
00057 
00058         public String getUrl() {
00059 
00060                 return url;
00061         }
00062 
00063 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends


comp_ehow
Author(s): Moritz Tenorth, Daniel Nyga
autogenerated on Tue Apr 16 2013 00:18:02