Skip to content

Commit

Permalink
summarization part done
Browse files Browse the repository at this point in the history
  • Loading branch information
Harounnn committed Apr 25, 2024
1 parent 646d165 commit dcae4b2
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 6 deletions.
4 changes: 3 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ dependencies {
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")

implementation("edu.stanford.nlp:stanford-corenlp:4.4.0")
implementation("com.github.shubham0204:Text2Summary-Android:alpha-05")


}
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ReadITAI"
tools:targetApi="31">
tools:targetApi="31"
tools:replace="android:theme">
<activity
android:name=".Hub"
android:exported="true">
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/example/readitai/Adapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void onClick(View v) {
intent.putExtra("title", models.get(holder.getAdapterPosition()).getTitle());
intent.putExtra("image", models.get(holder.getAdapterPosition()).getUrlToImage());
intent.putExtra("link", models.get(holder.getAdapterPosition()).getUrl());
intent.putExtra("content", models.get(holder.getAdapterPosition()).getContent());

v.getContext().startActivity(intent);
}
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/java/com/example/readitai/Summarizer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.example.readitai;

import com.ml.quaterion.text2summary.Text2Summary;

public class Summarizer {

String text;

public Summarizer(String text){
this.text = text;
}

public String summarize(){
System.out.println(text);
String summary = Text2Summary.summarize(text, 0.9F);
System.out.println(summary);
return summary;
}
}
8 changes: 7 additions & 1 deletion app/src/main/java/com/example/readitai/sumNews.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;

import com.bumptech.glide.Glide;

Expand All @@ -22,6 +21,7 @@ protected void onCreate(Bundle savedInstanceState){

TextView title = findViewById(R.id.headline);
ImageView image = findViewById(R.id.imagesum);
TextView text = findViewById(R.id.summary);
TextView link = findViewById(R.id.link);

Intent i = getIntent();
Expand All @@ -31,6 +31,12 @@ protected void onCreate(Bundle savedInstanceState){
Glide.with(this).load(b.get("image")).into(image);
link.setText((String) b.get("link"));

Summarizer summarizer = new Summarizer((String) b.get("content"));

String summary = summarizer.summarize();

text.setText(summary);

}


Expand Down
11 changes: 8 additions & 3 deletions app/src/main/res/layout/summarization.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<android.widget.RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="@color/blue">

<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
Expand Down Expand Up @@ -61,7 +62,9 @@
android:background="@color/darkGray"
android:textColor="@color/lightBlue"
android:textAlignment="center"
android:id="@+id/summary">
android:id="@+id/summary"
android:textSize="25sp"
android:textStyle="bold">

</TextView>
<TextView
Expand All @@ -74,7 +77,9 @@
android:background="@color/darkGray"
android:textColor="@color/lightBlue"
android:textAlignment="center"
android:id="@+id/link">
android:id="@+id/link"
android:textSize="20sp"
android:textStyle="italic">

</TextView>

Expand Down

0 comments on commit dcae4b2

Please sign in to comment.