Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
package com.piranframework.ganjex.api;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
Expand All @@ -40,6 +43,9 @@
* @since 1.0
*/
public final class ServiceContext {

private static final Logger log = LoggerFactory.getLogger(ServiceContext.class);

private final String fileName;
private final String name;
private final int version;
Expand All @@ -55,8 +61,12 @@ public ServiceContext(String fileName, ClassLoader classLoader) throws IOExcepti
manifest.load(urlConnection.getInputStream());
this.fileName = fileName;
this.name = manifest.getProperty("name");
//TODO:handle exception
this.version = Integer.parseInt(manifest.getProperty("version"));
try {
this.version = Integer.parseInt(manifest.getProperty("version"));
} catch (Exception e) {
log.error("error in parsing version as int check your version in manifest.properties");
throw e;
}
this.classLoader = classLoader;
}

Expand Down
53 changes: 53 additions & 0 deletions sample/twitterAnalyzer/ja-hashtag-analyzer/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>ja-hashtag-analyzer</groupId>
<artifactId>ja-hashtag-analyzer</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>[4.0,)</version>
</dependency>
<dependency>
<groupId>com.sample</groupId>
<artifactId>twitter-api</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>

<properties>
<jdk.version>1.8</jdk.version>
</properties>
<build>
<finalName>ja-hashtag-analyzer</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.twitter.crawler;

import com.sample.twitter.Analyzer;
import com.sample.twitter.AnalyzerMethod;
import twitter4j.*;
import twitter4j.conf.ConfigurationBuilder;

import java.util.ArrayList;
import java.util.List;

public class JAHashtagAnalyzer extends Analyzer {
@AnalyzerMethod
public List<String> analyze() throws TwitterException {
Twitter twitter = getTwitter();
List<String> analyzedTweets = new ArrayList<String>();
for (int i = 1; i < 2; i++) {
ResponseList<Status> homeTimeline = twitter.getHomeTimeline(new Paging(i, 20));
for (Status status : homeTimeline) {
HashtagEntity[] hashtagEntities = status.getHashtagEntities();
for (HashtagEntity hashtagEntity : hashtagEntities) {
if (hashtagEntity.getText().contains("ج.ا")) {
analyzedTweets.add(status.getText());
}
}
}
}
return analyzedTweets;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name=JaHashtagAnalyzer
version=1
58 changes: 58 additions & 0 deletions sample/twitterAnalyzer/ja-text-analyzer/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>ja-text-analyzer</groupId>
<artifactId>ja-text-analyzer</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>[4.0,)</version>
</dependency>
<dependency>
<groupId>com.sample</groupId>
<artifactId>twitter-api</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>

<properties>
<jdk.version>1.8</jdk.version>
</properties>
<build>
<finalName>ja-text-analyzer</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.twitter.crawler.JAHashtagAnalyzer</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.twitter.crawler;

import com.sample.twitter.Analyzer;
import com.sample.twitter.AnalyzerMethod;
import twitter4j.*;
import twitter4j.conf.ConfigurationBuilder;

import java.util.ArrayList;
import java.util.List;

public class JATextAnalyzer extends Analyzer {
@AnalyzerMethod
public List<String> analyze() throws TwitterException {
Twitter twitter = getTwitter();
List<String> analyzedTweets = new ArrayList<String>();
for (int i = 1; i < 2; i++) {
ResponseList<Status> homeTimeline = twitter.getHomeTimeline(new Paging(i, 20));
for (Status status : homeTimeline) {
if (status.getText().contains("ج.ا")) {
analyzedTweets.add(status.getText());
}
}
}
return analyzedTweets;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name=JATextAnalyzer
version=1
58 changes: 58 additions & 0 deletions sample/twitterAnalyzer/mee-too-hashtag-analyzer/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>me-too-hashtag-analyzer</groupId>
<artifactId>me-too-hashtag-analyzer</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>[4.0,)</version>
</dependency>
<dependency>
<groupId>com.sample</groupId>
<artifactId>twitter-api</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>

<properties>
<jdk.version>1.8</jdk.version>
</properties>
<build>
<finalName>mee-too-hashtag-analyzer</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.twitter.crawler.JAHashtagAnalyzer</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.twitter.crawler;

import com.sample.twitter.Analyzer;
import com.sample.twitter.AnalyzerMethod;
import twitter4j.*;
import twitter4j.conf.ConfigurationBuilder;

import java.util.ArrayList;
import java.util.List;

public class MeTooHashTagAnalyzer extends Analyzer {
@AnalyzerMethod
public List<String> analyze() throws TwitterException {
Twitter twitter = getTwitter();
List<String> analyzedTweets = new ArrayList<String>();
for (int i = 1; i < 2; i++) {
ResponseList<Status> homeTimeline = twitter.getHomeTimeline(new Paging(i, 20));
for (Status status : homeTimeline) {
HashtagEntity[] hashtagEntities = status.getHashtagEntities();
for (HashtagEntity hashtagEntity : hashtagEntities) {
if (hashtagEntity.getText().contains("MeToo")) {
analyzedTweets.add(status.getText());
}
}
}
}
return analyzedTweets;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name=MeTooHashTagAnalyzer
version=1
58 changes: 58 additions & 0 deletions sample/twitterAnalyzer/mee-too-text-analyzer/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>me-too-text-analyzer</groupId>
<artifactId>me-too-text-analyzer</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>[4.0,)</version>
</dependency>
<dependency>
<groupId>com.sample</groupId>
<artifactId>twitter-api</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>

<properties>
<jdk.version>1.8</jdk.version>
</properties>
<build>
<finalName>mee-too-text-analyzer</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.twitter.crawler.JAHashtagAnalyzer</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.twitter.crawler;

import com.sample.twitter.Analyzer;
import com.sample.twitter.AnalyzerMethod;
import twitter4j.*;
import twitter4j.conf.ConfigurationBuilder;

import java.util.ArrayList;
import java.util.List;

public class MeTooTextAnalyzer extends Analyzer {
@AnalyzerMethod
public List<String> analyze() throws TwitterException {
Twitter twitter = getTwitter();
List<String> analyzedTweets = new ArrayList<String>();
for (int i = 1; i < 2; i++) {
ResponseList<Status> homeTimeline = twitter.getHomeTimeline(new Paging(i, 20));
for (Status status : homeTimeline) {
if (status.getText().contains("MeToo")) {
analyzedTweets.add(status.getText());
}
}
}
return analyzedTweets;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name=MeeTooTextAnalyzer
version=1
Loading