Commit b6bee1cb authored by Zied SELLAMI's avatar Zied SELLAMI
Browse files

Update priority-inbox

parent 2d3ed9b0
......@@ -63,7 +63,7 @@ Sample of json file:
"Date" : "Mon, 28 Jan 2019 07:56:43 +0000",
"in-Reply-To" : "messageId_in_reply_to",
"subject" : "IMPORTANT: Testing The Priority Inbox",
"body" : "\nDear, \n\n this a test of the priority inbox\n regards, first_name last_name of to1\nDirector Tester",
"body" : "\nDear, \n\n this a test of the priority inbox\n regards,\nfirst_name last_name\nDirector Tester",
"attachments" : [{
"file_size" : "243534",
"content_name" : "presentation.pdf",
......@@ -83,6 +83,6 @@ Expected result:
```
{
"category" : "IMPORTANT",
"score" : 4.25
"score" : 20.25
}
```
......@@ -20,8 +20,9 @@ import org.linagora.priorityInbox.data.EmailAttachment;
public class JSONReader {
private static MailDateFormat emailDateFormatter = new MailDateFormat();
public static void main(String [] args) {
File f = new File("email.json");
toEmail(f);
File f = new File("test.json");
Email email = toEmail(f);
System.out.println(email);
}
public static Email toEmail(File file) {
......@@ -85,11 +86,10 @@ public class JSONReader {
String user = json.getString("user");
email.setUser(user);
}catch(Exception e) {
e.printStackTrace();
System.err.println("User is null");
email.setUser(null);
}
//reading alternativeAddress
try {
List<Object> alternativeAddress = json.getJSONArray("alternativeAddress").toList();
......@@ -222,9 +222,7 @@ public class JSONReader {
}catch(Exception e) {
e.printStackTrace();
}
return email;
}
......
package org.linagora.priorityInbox.data;
import java.io.File;
import java.util.List;
import javax.mail.internet.InternetAddress;
import org.apache.commons.io.FileUtils;
import org.joda.time.DateTime;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
public class Email {
......@@ -187,22 +182,4 @@ public class Email {
this.alternativeAddress = alternativeAddress;
}
public void toJson() {
try {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
String json = mapper.writeValueAsString(this);
FileUtils.write(new File(this.getMessageId()), json);
}catch(Exception e) {
}
}
}
......@@ -5,15 +5,12 @@ import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.linagora.priorityInbox.feature.PositionRank;
public class TextCleaner {
public static File CLEANING_REGEX = null;
......@@ -141,6 +138,6 @@ public class TextCleaner {
String reply = cleanReplyBlock(body);
return reply.replace(signature, "").trim();
}
}
......@@ -23,7 +23,7 @@
"Date" : "Mon, 28 Jan 2019 07:56:43 +0000",
"in-Reply-To" : "messageId_in_reply_to",
"subject" : "IMPORTANT: Testing The Priority Inbox",
"body" : "\nDear, \n\n this a test of the priority inbox\n regards, first_name last_name of to1\nDirector Tester",
"body" : "\nDear, \n\n this a test of the priority inbox\n regards,\nfirst_name last_name\nDirector Tester",
"attachments" : [{
"file_size" : "243534",
"content_name" : "presentation.pdf",
......@@ -37,5 +37,4 @@
"user" : "first_name last_name of to1",
"alternativeAddress" : [ "t1@test.com", "first_name.last_name@test.com" ],
"X-Spam-Flag" : "NO"
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment