From f6ed9b9c0f10770bd8da27f677a0777f9465b999 Mon Sep 17 00:00:00 2001 From: zkwip Date: Wed, 20 May 2015 17:32:35 +0200 Subject: summary shit geeft wel maar een regel --- .../java/org/rssin/summaries/SentenceItem.java | 53 ++ app/src/main/java/org/rssin/summaries/Special.java | 60 ++ app/src/main/java/org/rssin/summaries/Stemmer.java | 852 +++++++++++++++++++++ .../main/java/org/rssin/summaries/Stopword.java | 74 ++ .../main/java/org/rssin/summaries/SummaryAPI.java | 328 ++++++-- .../org/rssin/summaries/SummaryAPIInterface.java | 3 +- .../main/java/org/rssin/summaries/TxtStatic.java | 26 + .../main/java/org/rssin/summaries/WordItem.java | 78 ++ app/src/main/java/org/rssin/summaries/specials.txt | 18 + .../main/java/org/rssin/summaries/stopwords.txt | 345 +++++++++ 10 files changed, 1787 insertions(+), 50 deletions(-) create mode 100644 app/src/main/java/org/rssin/summaries/SentenceItem.java create mode 100644 app/src/main/java/org/rssin/summaries/Special.java create mode 100644 app/src/main/java/org/rssin/summaries/Stemmer.java create mode 100644 app/src/main/java/org/rssin/summaries/Stopword.java create mode 100644 app/src/main/java/org/rssin/summaries/TxtStatic.java create mode 100644 app/src/main/java/org/rssin/summaries/WordItem.java create mode 100644 app/src/main/java/org/rssin/summaries/specials.txt create mode 100644 app/src/main/java/org/rssin/summaries/stopwords.txt (limited to 'app/src') diff --git a/app/src/main/java/org/rssin/summaries/SentenceItem.java b/app/src/main/java/org/rssin/summaries/SentenceItem.java new file mode 100644 index 0000000..e8e0e0b --- /dev/null +++ b/app/src/main/java/org/rssin/summaries/SentenceItem.java @@ -0,0 +1,53 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.rssin.summaries; + +public class SentenceItem +{ + + private String rsen = ""; + private String srsen = ""; + + private double wght; + + public SentenceItem(String s) + { + rsen = new String(s); + wght = 0.0; + } + + + public void setRawSentecse(String sen) + { + rsen = sen; + } + + public void setSRSentence(String rsen) + { + srsen = rsen; + } + + public String getRawSentence() + { + return rsen; + } + public String getSRSentence() + { + return srsen; + } + + public void addWeight(double wg) + { + wght=wght+wg; + } + + public double getWeight() + { + return wght; + } + + +} \ No newline at end of file diff --git a/app/src/main/java/org/rssin/summaries/Special.java b/app/src/main/java/org/rssin/summaries/Special.java new file mode 100644 index 0000000..36cb0ad --- /dev/null +++ b/app/src/main/java/org/rssin/summaries/Special.java @@ -0,0 +1,60 @@ +package org.rssin.summaries; + +import java.io.*; +import java.util.StringTokenizer; + +public class Special +{ + + char spch[]; + + public Special() + { + /*int cnt=0,sz=0;char bt[]=null; + try { + File fp=new File("specials.txt"); + FileReader fis=new FileReader(fp); + sz=(int)fp.length(); + bt=new char[sz]; + fis.read(bt); + fis.close(); + } + catch(IOException ex) {} + spch=getTokens(new String(bt));*/ + spch = new TxtStatic().getSpecial(); + } + + + public char[] getTokens(String sen) + { + int sz=0,cnt=0;char words[]=null; + StringTokenizer stk=new StringTokenizer(sen); + sz=stk.countTokens(); + words=new char[sz]; + while ( stk.hasMoreTokens()) + { + words[cnt]=new String(stk.nextToken()).charAt(0); + cnt++; + } + return words; + } + + public String remove(String sen) + { + String dsen=new String(sen); + + for (int j=0;j 0) { + if (length - el > 1) { + String ending = word.substring(length - el); + String conditionCode = null; + switch (el) { + case 11: conditionCode = (String)m_l11.get(ending); + break; + case 10: conditionCode = (String)m_l10.get(ending); + break; + case 9: conditionCode = (String)m_l9.get(ending); + break; + case 8: conditionCode = (String)m_l8.get(ending); + break; + case 7: conditionCode = (String)m_l7.get(ending); + break; + case 6: conditionCode = (String)m_l6.get(ending); + break; + case 5: conditionCode = (String)m_l5.get(ending); + break; + case 4: conditionCode = (String)m_l4.get(ending); + break; + case 3: conditionCode = (String)m_l3.get(ending); + break; + case 2: conditionCode = (String)m_l2.get(ending); + break; + case 1: conditionCode = (String)m_l1.get(ending); + break; + default: + } + if (conditionCode != null) { + switch (conditionCode.charAt(0)) { + case 'A': + return word.substring(0, length - el); + case 'B': + if (length - el > 2) { + return word.substring(0, length - el); + } + break; + case 'C': + if (length - el > 3) { + return word.substring(0, length - el); + } + break; + case 'D': + if (length - el > 4) { + return word.substring(0, length - el); + } + break; + case 'E': + if (word.charAt(length - el - 1) != 'e') { + return word.substring(0, length - el); + } + break; + case 'F': + if ((length - el > 2) && + (word.charAt(length - el - 1) != 'e')) { + return word.substring(0, length - el); + } + break; + case 'G': + if ((length - el > 2) && + (word.charAt(length - el - 1) == 'f')) { + return word.substring(0, length - el); + } + break; + case 'H': + if ((word.charAt(length - el - 1) == 't') || + ((word.charAt(length - el - 1) == 'l') && + (word.charAt(length - el - 2) == 'l'))) { + return word.substring(0, length - el); + } + break; + case 'I': + if ((word.charAt(length - el - 1) != 'o') && + (word.charAt(length - el - 1) != 'e')) { + return word.substring(0, length - el); + } + break; + case 'J': + if ((word.charAt(length - el - 1) != 'a') && + (word.charAt(length - el - 1) != 'e')) { + return word.substring(0, length - el); + } + break; + case 'K': + if ((length - el > 2) && + ((word.charAt(length - el - 1) == 'l') || + (word.charAt(length - el - 1) == 'i') || + ((word.charAt(length - el - 1) == 'e') && + (word.charAt(length - el - 3) == 'u')))) { + return word.substring(0, length - el); + } + break; + case 'L': + if ((word.charAt(length - el - 1) != 'u') && + (word.charAt(length - el - 1) != 'x') && + ((word.charAt(length - el - 1) != 's') || + (word.charAt(length - el - 2) == 'o'))) { + return word.substring(0, length - el); + } + break; + case 'M': + if ((word.charAt(length - el - 1) != 'a') && + (word.charAt(length - el - 1) != 'c') && + (word.charAt(length - el - 1) != 'e') && + (word.charAt(length - el - 1) != 'm')) { + return word.substring(0, length - el); + } + break; + case 'N': + if ((length - el > 3) || + ((length - el == 3) && + ((word.charAt(length - el - 3) != 's')))) { + return word.substring(0, length - el); + } + break; + case 'O': + if ((word.charAt(length - el - 1) == 'l') || + (word.charAt(length - el - 1) == 'i')) { + return word.substring(0, length - el); + } + break; + case 'P': + if (word.charAt(length - el - 1) != 'c') { + return word.substring(0, length - el); + } + break; + case 'Q': + if ((length - el > 2) && + (word.charAt(length - el - 1) != 'l') && + (word.charAt(length - el - 1) != 'n')) { + return word.substring(0, length - el); + } + break; + case 'R': + if ((word.charAt(length - el - 1) == 'n') || + (word.charAt(length - el - 1) == 'r')) { + return word.substring(0, length - el); + } + break; + case 'S': + if (((word.charAt(length - el - 1) == 'r') && + (word.charAt(length - el - 2) == 'd')) || + ((word.charAt(length - el - 1) == 't') && + (word.charAt(length - el - 2) != 't'))) { + return word.substring(0, length - el); + } + break; + case 'T': + if ((word.charAt(length - el - 1) == 's') || + ((word.charAt(length - el - 1) == 't') && + (word.charAt(length - el - 2) != 'o'))) { + return word.substring(0, length - el); + } + break; + case 'U': + if ((word.charAt(length - el - 1) == 'l') || + (word.charAt(length - el - 1) == 'm') || + (word.charAt(length - el - 1) == 'n') || + (word.charAt(length - el - 1) == 'r')) { + return word.substring(0, length - el); + } + break; + case 'V': + if (word.charAt(length - el - 1) == 'c') { + return word.substring(0, length - el); + } + break; + case 'W': + if ((word.charAt(length - el - 1) != 's') && + (word.charAt(length - el - 1) != 'u')) { + return word.substring(0, length - el); + } + break; + case 'X': + if ((word.charAt(length - el - 1) == 'l') || + (word.charAt(length - el - 1) == 'i') || + ((length - el > 2) && + (word.charAt(length - el - 1) == 'e') && + (word.charAt(length - el - 3) == 'u'))) { + return word.substring(0, length - el); + } + break; + case 'Y': + if ((word.charAt(length - el - 1) == 'n') && + (word.charAt(length - el - 2) == 'i')) { + return word.substring(0, length - el); + } + break; + case 'Z': + if (word.charAt(length - el - 1) != 'f') { + return word.substring(0, length - el); + } + break; + case 'a': + if ((word.charAt(length - el - 1) == 'd') || + (word.charAt(length - el - 1) == 'f') || + (((word.charAt(length - el - 1) == 'h') && + (word.charAt(length - el - 2) == 'p'))) || + (((word.charAt(length - el - 1) == 'h') && + (word.charAt(length - el - 2) == 't'))) || + (word.charAt(length - el - 1) == 'l') || + (((word.charAt(length - el - 1) == 'r') && + (word.charAt(length - el - 2) == 'e'))) || + (((word.charAt(length - el - 1) == 'r') && + (word.charAt(length - el - 2) == 'o'))) || + (((word.charAt(length - el - 1) == 's') && + (word.charAt(length - el - 2) == 'e'))) || + (word.charAt(length - el - 1) == 't')) { + return word.substring(0, length - el); + } + break; + case 'b': + if (m_CompMode) { + if (((length - el == 3 ) && + (!((word.charAt(length - el - 1) == 't') && + (word.charAt(length - el - 2) == 'e') && + (word.charAt(length - el - 3) == 'm')))) || + ((length - el > 3) && + (!((word.charAt(length - el - 1) == 't') && + (word.charAt(length - el - 2) == 's') && + (word.charAt(length - el - 3) == 'y') && + (word.charAt(length - el - 4) == 'r'))))) { + return word.substring(0, length - el); + } + } else { + if ((length - el > 2) && + (!((word.charAt(length - el - 1) == 't') && + (word.charAt(length - el - 2) == 'e') && + (word.charAt(length - el - 3) == 'm'))) && + ((length - el < 4) || + (!((word.charAt(length - el - 1) == 't') && + (word.charAt(length - el - 2) == 's') && + (word.charAt(length - el - 3) == 'y') && + (word.charAt(length - el - 4) == 'r'))))) { + return word.substring(0, length - el); + } + } + break; + case 'c': + if (word.charAt(length - el - 1) == 'l') { + return word.substring(0, length - el); + } + break; + default: + throw new IllegalArgumentException("Fatal error."); + } + } + } + el--; + } + return word; + } + + private String recodeEnding(String word) { + + int lastPos = word.length() - 1; + + // Rule 1 + if (word.endsWith("bb") || + word.endsWith("dd") || + word.endsWith("gg") || + word.endsWith("ll") || + word.endsWith("mm") || + word.endsWith("nn") || + word.endsWith("pp") || + word.endsWith("rr") || + word.endsWith("ss") || + word.endsWith("tt")) { + word = word.substring(0, lastPos); + lastPos--; + } + + // Rule 2 + if (word.endsWith("iev")) { + word = word.substring(0, lastPos - 2).concat("ief"); + } + + // Rule 3 + if (word.endsWith("uct")) { + word = word.substring(0, lastPos - 2).concat("uc"); + lastPos--; + } + + // Rule 4 + if (word.endsWith("umpt")) { + word = word.substring(0, lastPos - 3).concat("um"); + lastPos -= 2; + } + + // Rule 5 + if (word.endsWith("rpt")) { + word = word.substring(0, lastPos - 2).concat("rb"); + lastPos--; + } + + // Rule 6 + if (word.endsWith("urs")) { + word = word.substring(0, lastPos - 2).concat("ur"); + lastPos--; + } + + // Rule 7 + if (word.endsWith("istr")) { + word = word.substring(0, lastPos - 3).concat("ister"); + lastPos++; + } + + // Rule 7a + if (word.endsWith("metr")) { + word = word.substring(0, lastPos - 3).concat("meter"); + lastPos++; + } + + // Rule 8 + if (word.endsWith("olv")) { + word = word.substring(0, lastPos - 2).concat("olut"); + lastPos++; + } + + // Rule 9 + if (word.endsWith("ul")) { + if ((lastPos - 2 < 0) || + ((word.charAt(lastPos - 2) != 'a') && + (word.charAt(lastPos - 2) != 'i') && + (word.charAt(lastPos - 2) != 'o'))) { + word = word.substring(0, lastPos - 1).concat("l"); + lastPos--; + } + } + + // Rule 10 + if (word.endsWith("bex")) { + word = word.substring(0, lastPos - 2).concat("bic"); + } + + // Rule 11 + if (word.endsWith("dex")) { + word = word.substring(0, lastPos - 2).concat("dic"); + } + + // Rule 12 + if (word.endsWith("pex")) { + word = word.substring(0, lastPos - 2).concat("pic"); + } + + // Rule 13 + if (word.endsWith("tex")) { + word = word.substring(0, lastPos - 2).concat("tic"); + } + + // Rule 14 + if (word.endsWith("ax")) { + word = word.substring(0, lastPos - 1).concat("ac"); + } + + // Rule 15 + if (word.endsWith("ex")) { + word = word.substring(0, lastPos - 1).concat("ec"); + } + + // Rule 16 + if (word.endsWith("ix")) { + word = word.substring(0, lastPos - 1).concat("ic"); + } + + // Rule 17 + if (word.endsWith("lux")) { + word = word.substring(0, lastPos - 2).concat("luc"); + } + + // Rule 18 + if (word.endsWith("uad")) { + word = word.substring(0, lastPos - 2).concat("uas"); + } + + // Rule 19 + if (word.endsWith("vad")) { + word = word.substring(0, lastPos - 2).concat("vas"); + } + + // Rule 20 + if (word.endsWith("cid")) { + word = word.substring(0, lastPos - 2).concat("cis"); + } + + // Rule 21 + if (word.endsWith("lid")) { + word = word.substring(0, lastPos - 2).concat("lis"); + } + + // Rule 22 + if (word.endsWith("erid")) { + word = word.substring(0, lastPos - 3).concat("eris"); + } + + // Rule 23 + if (word.endsWith("pand")) { + word = word.substring(0, lastPos - 3).concat("pans"); + } + + // Rule 24 + if (word.endsWith("end")) { + if ((lastPos - 3 < 0) || + (word.charAt(lastPos - 3) != 's')) { + word = word.substring(0, lastPos - 2).concat("ens"); + } + } + + // Rule 25 + if (word.endsWith("ond")) { + word = word.substring(0, lastPos - 2).concat("ons"); + } + + // Rule 26 + if (word.endsWith("lud")) { + word = word.substring(0, lastPos - 2).concat("lus"); + } + + // Rule 27 + if (word.endsWith("rud")) { + word = word.substring(0, lastPos - 2).concat("rus"); + } + + // Rule 28 + if (word.endsWith("her")) { + if ((lastPos - 3 < 0) || + ((word.charAt(lastPos - 3) != 'p') && + (word.charAt(lastPos - 3) != 't'))) { + word = word.substring(0, lastPos - 2).concat("hes"); + } + } + + // Rule 29 + if (word.endsWith("mit")) { + word = word.substring(0, lastPos - 2).concat("mis"); + } + + // Rule 30 + if (word.endsWith("end")) { + if ((lastPos - 3 < 0) || + (word.charAt(lastPos - 3) != 'm')) { + word = word.substring(0, lastPos - 2).concat("ens"); + } + } + + // Rule 31 + if (word.endsWith("ert")) { + word = word.substring(0, lastPos - 2).concat("ers"); + } + + // Rule 32 + if (word.endsWith("et")) { + if ((lastPos - 2 < 0) || + (word.charAt(lastPos - 2) != 'n')) { + word = word.substring(0, lastPos - 1).concat("es"); + } + } + + // Rule 33 + if (word.endsWith("yt")) { + word = word.substring(0, lastPos - 1).concat("ys"); + } + + // Rule 34 + if (word.endsWith("yz")) { + word = word.substring(0, lastPos - 1).concat("ys"); + } + + return word; + } + + public String stem(String word) { + + if (word.length() > 2) { + return recodeEnding(removeEnding(word.toLowerCase())); + } else { + return word.toLowerCase(); + } + } + + public String stemString(String str) { + + StringBuffer result = new StringBuffer(); + int start = -1; + for (int j = 0; j < str.length(); j++) { + char c = str.charAt(j); + if (Character.isLetterOrDigit(c)) { + if (start == -1) { + start = j; + } + } else if (c == '\'') { + if (start == -1) { + result.append(c); + } + } else { + if (start != -1) { + result.append(stem(str.substring(start, j))); + start = -1; + } + result.append(c); + } + } + if (start != -1) { + result.append(stem(str.substring(start, str.length()))); + } + return result.toString(); + } + +} + + diff --git a/app/src/main/java/org/rssin/summaries/Stopword.java b/app/src/main/java/org/rssin/summaries/Stopword.java new file mode 100644 index 0000000..af3bee6 --- /dev/null +++ b/app/src/main/java/org/rssin/summaries/Stopword.java @@ -0,0 +1,74 @@ +package org.rssin.summaries; + +import java.io.*; +import java.util.StringTokenizer; + +public class Stopword +{ + + String stwd[]; + + public Stopword () + { + /*int cnt=0,sz=0;char bt[]=null; + try + { + File fp = new File("stopwords.txt"); + FileReader fis = new FileReader(fp); + sz = (int)fp.length(); + bt = new char [sz]; + fis.read(bt); + fis.close(); + } + catch(IOException ex) {} + + stwd=getTokens(new String(bt)); */ + + stwd = new TxtStatic().getStopWords(); + } + +public void display () + { + for (int i=0;i=3) + addword(tok,i,wordcount,hs); + else if(hs.containsKey(tok) ) + upword(tok,i,wordcount,hs); + } + } + + //stemming + + stemming(hs); + + //significant + + Enumeration key=hs.keys(); + while (key.hasMoreElements() ) + delword(key.nextElement(), hs); + + //getWeight + + key=hs.keys(); + while (key.hasMoreElements()) + setWeight(key.nextElement(),hs, zinnen); + + //ranking + return :P + return ranking(zinnen, hs); + } + + private void setWeight(Object tok, Hashtable hs, ArrayList zinnen) + { + double wg=0.0; + WordItem wl=(WordItem)hs.get(tok); + double scnt = (double)zinnen.size(); + double tf=wl.getcount(); + double df=wl.sentensecount(); + wg = tf*Math.log10(scnt/df); + wl.addWeight(wg); + } + + public String ranking(ArrayList zinnen, Hashtable hs) + { + SentenceItem sl=null; + double max=0.0; + int mi=0; + + for(int i = 0; i < zinnen.size(); i++) + { + sl = zinnen.get(i); + String sen=sl.getSRSentence(); + Enumeration key = hs.keys(); + while(key.hasMoreElements()) + { + String str=(String)key.nextElement(); + if(sen.indexOf(str) != -1 ) + { + WordItem wl=(WordItem)hs.get(str); + sl.addWeight(wl.getWeight()); + } + } + } + + for(int i = 0; i < zinnen.size(); i++) + { + sl = (SentenceItem)zinnen.get(i); + if( sl.getWeight() > max ) + { + max = sl.getWeight(); + mi=i; + } + } + + String str1 = sl.getRawSentence(); + sl = zinnen.get(mi); + + return str1; + } + + private void delword(Object tok, Hashtable hs) + { + WordItem wl=(WordItem)hs.remove(tok); + if( wl.getcount() > 3 ) + hs.put(tok,wl); + } + + + private void stemword(String w1,String w2, Hashtable hs) + { + if( !hs.containsKey(w2) || !hs.containsKey(w1) ) + { + // System.out.print("return:"); + return; + } + WordItem wl1=(WordItem)hs.remove(w1); + WordItem wl2=(WordItem)hs.remove(w2); + + ArrayList wp=wl2.getwordpos(); + ArrayList sp=wl2.getsentensepos(); + + + for(int i=0;i= 3.0 ) + { + stemword(str1,str2,hs); + } + } + } + } + + private void addword(String tok,int sp,int wp, Hashtable hs) + { + WordItem wl=new WordItem(tok); + wl.incrcount(sp+1,wp); + hs.put(tok,wl); + } + private void upword(String tok,int sp,int wp, Hashtable hs) + { + WordItem wl=(WordItem)hs.remove(tok); + wl.incrcount(sp+1,wp); + hs.put(tok,wl); + } + + private ArrayList getSentences(String doc) + { + ArrayList als = new ArrayList(); + + int fs1=0; + int fs2=0; + int nx=0; + + while ( nx < (doc.length()-1) ) + { + nx=doc.indexOf(".",fs2); + if(nx==-1) + break; + else if( nx==doc.lastIndexOf(".") ) + { + String str=(doc.substring(fs1,nx+1)).toLowerCase(); + als.add(new SentenceItem(str)); + fs2=nx+1; + fs1=fs2; + break; + } + else if( doc.charAt(nx+1) ==' ' || doc.charAt(nx+1) =='\r' || doc.charAt(nx+1) =='\n') + { + String str=(doc.substring(fs1,nx+1).toLowerCase()).trim(); + als.add(new SentenceItem(str)); + fs2=nx+1; + fs1=fs2; + } + else + fs2=nx+1; + } + + return als; + } +} diff --git a/app/src/main/java/org/rssin/summaries/SummaryAPIInterface.java b/app/src/main/java/org/rssin/summaries/SummaryAPIInterface.java index 1caf922..17636de 100644 --- a/app/src/main/java/org/rssin/summaries/SummaryAPIInterface.java +++ b/app/src/main/java/org/rssin/summaries/SummaryAPIInterface.java @@ -1,9 +1,10 @@ package org.rssin.summaries; -import rss.FeedItem; +import org.rssin.rss.FeedItem; public interface SummaryAPIInterface { public Summary getSummary(FeedItem f); + public Summary getSummaryFromText(String t); } \ No newline at end of file diff --git a/app/src/main/java/org/rssin/summaries/TxtStatic.java b/app/src/main/java/org/rssin/summaries/TxtStatic.java new file mode 100644 index 0000000..d686beb --- /dev/null +++ b/app/src/main/java/org/rssin/summaries/TxtStatic.java @@ -0,0 +1,26 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.rssin.summaries; + +/** + * + * @author Joep + */ +public class TxtStatic { + + private final String[] stopwords = {"a","about","above","across","after","afterwards","again","against","all","almost","alone","along","already","also","although","always","am","among","amongst","amoungst","amount","an","and","another","any","anyhow","anyone","anything","anyway","anywhere","are","around","as","at","back","be","became","because","become","becomes","becoming","been","before","beforehand","behind","being","below","beside","besides","between","beyond","bill","both","bottom","but","by","by","call","can","common","cannot","cant","co","computer","con","could","couldnt","cry","de","describe","detail","do","does","done","down","due","during","each","eg","eight","either","eleven","else","elsewhere","empty","enough","etc","even","ever","every","everyone","everything","everywhere","except","few","fifteen","fify","fill","find","fire","first","five","for","former","formerly","forty","found","four","from","front","full","further","get","give","go","had","has","hasnt","have","he","hence","her","here","hereafter","hereby","herein","hereupon","hers","herself","him","himself","his","how","however","hundred","i","ie","if","in","inc","indeed","interest","into","is","it","its","itself","keep","last","latter","latterly","least","less","ltd","made","many","may","me","meanwhile","might","mill","mine","more","moreover","most","mostly","move","much","must","my","myself","name","namely","neither","never","nevertheless","next","nine","no","nobody","none","noone","nor","not","nothing","now","nowhere","of","off","often","on","once","one","only","onto","or","other","others","otherwise","our","ours","ourselves","out","over","own","part","per","perhaps","please","put","rather","re","same","see","seem","seemed","seeming","seems","serious","several","she","should","show","side","since","sincere","six","sixty","so","some","somehow","someone","something","sometime","sometimes","somewhere","still","such","system","take","ten","than","that","the","their","them","themselves","then","thence","there","thereafter","thereby","therefore","therein","thereupon","these","they","thick","thin","third","this","those","though","three","through","throughout","thru","thus","to","together","too","top","toward","towards","twelve","twenty","two","un","under","until","up","upon","us","usually","usual","very","via","was","we","well","were","what","whatever","when","whence","whenever","where","whereafter","whereas","whereby","whereinwhereupon","wherever","whether","which","while","whither","who","whoever","whole","whom","whose","why","will","with","within","without","would","yet","you","your","yours","yourself","yourselves","don't","won't","can't","didn't","it's","is'nt","aren't","wasn't","haven't","hasn't","hadn't","you've","it'hv","you'd","you're","hasn't","we�ll","you�re","we're","we've"}; + + private final char[] special = {'"', ',', ';', '!', '&', '/', '$', ':', '|', '%', ')', '(', '[', ']', '�', '�', '\'', '.', ' ', '\n'}; + + public String[] getStopWords() + { + return stopwords; + } + public char[] getSpecial() + { + return special; + } +} diff --git a/app/src/main/java/org/rssin/summaries/WordItem.java b/app/src/main/java/org/rssin/summaries/WordItem.java new file mode 100644 index 0000000..fb47749 --- /dev/null +++ b/app/src/main/java/org/rssin/summaries/WordItem.java @@ -0,0 +1,78 @@ +package org.rssin.summaries; + +import java.util.ArrayList; + +public class WordItem +{ + private String word; + private double cnt; + private double scnt; + private double wght; + + private ArrayList spl; + private ArrayList wpl; + + public WordItem (String wd) + { + word= new String(wd); + spl=new ArrayList(); + wpl=new ArrayList(); + cnt=0;scnt=0; + } + + public void incrcount(int sp,int wp) + { + cnt++; + sentensepos(sp); + wordpos(wp); + } + + public double getcount() + { + return cnt; + } + + public String getword() + { + return word; + } + + public void sentensepos(int sp) + { + if(! spl.contains(sp+"")) + scnt++; + spl.add(sp+""); + } + + public void wordpos(int wp) + { + wpl.add(wp+""); + } + + public ArrayList getwordpos() + { + return wpl; + } + + public ArrayList getsentensepos() + { + return spl; + } + + public void addWeight(double wg) + { + wght=wg; + } + + public double getWeight() + { + return wght; + } + + public double sentensecount() + { + return scnt; + } + + +} \ No newline at end of file diff --git a/app/src/main/java/org/rssin/summaries/specials.txt b/app/src/main/java/org/rssin/summaries/specials.txt new file mode 100644 index 0000000..046d05b --- /dev/null +++ b/app/src/main/java/org/rssin/summaries/specials.txt @@ -0,0 +1,18 @@ +, +" +; +! +& +/ +$ +: +| +% +) +( +[ +] +” +“ +' +. diff --git a/app/src/main/java/org/rssin/summaries/stopwords.txt b/app/src/main/java/org/rssin/summaries/stopwords.txt new file mode 100644 index 0000000..e621f2a --- /dev/null +++ b/app/src/main/java/org/rssin/summaries/stopwords.txt @@ -0,0 +1,345 @@ +a +about +above +across +after +afterwards +again +against +all +almost +alone +along +already +also +although +always +am +among +amongst +amoungst +amount +an +and +another +any +anyhow +anyone +anything +anyway +anywhere +are +around +as +at +back +be +became +because +become +becomes +becoming +been +before +beforehand +behind +being +below +beside +besides +between +beyond +bill +both +bottom +but +by +by +call +can +common +cannot +cant +co +computer +con +could +couldnt +cry +de +describe +detail +do +does +done +down +due +during +each +eg +eight +either +eleven +else +elsewhere +empty +enough +etc +even +ever +every +everyone +everything +everywhere +except +few +fifteen +fify +fill +find +fire +first +five +for +former +formerly +forty +found +four +from +front +full +further +get +give +go +had +has +hasnt +have +he +hence +her +here +hereafter +hereby +herein +hereupon +hers +herself +him +himself +his +how +however +hundred +i +ie +if +in +inc +indeed +interest +into +is +it +its +itself +keep +last +latter +latterly +least +less +ltd +made +many +may +me +meanwhile +might +mill +mine +more +moreover +most +mostly +move +much +must +my +myself +name +namely +neither +never +nevertheless +next +nine +no +nobody +none +noone +nor +not +nothing +now +nowhere +of +off +often +on +once +one +only +onto +or +other +others +otherwise +our +ours +ourselves +out +over +own +part +per +perhaps +please +put +rather +re +same +see +seem +seemed +seeming +seems +serious +several +she +should +show +side +since +sincere +six +sixty +so +some +somehow +someone +something +sometime +sometimes +somewhere +still +such +system +take +ten +than +that +the +their +them +themselves +then +thence +there +thereafter +thereby +therefore +therein +thereupon +these +they +thick +thin +third +this +those +though +three +through +throughout +thru +thus +to +together +too +top +toward +towards +twelve +twenty +two +un +under +until +up +upon +us +usually +usual +very +via +was +we +well +were +what +whatever +when +whence +whenever +where +whereafter +whereas +whereby +wherein +whereupon +wherever +whether +which +while +whither +who +whoever +whole +whom +whose +why +will +with +within +without +would +yet +you +your +yours +yourself +yourselves +don't +won't +can't +didn't +it's +is'nt +aren't +wasn't +haven't +hasn't +hadn't +you've +it'hv +you'd +you're +hasn't +we’ll +you’re +we're +we've + -- cgit v1.2.3