자바 이클립스에서 문장에 특정 단어가 포함되어 있는지 여부를 구분할 수있는 도구를 만들고 있습니다.특정 단어에 대해 텍스트 파일 읽기
twitter4j 도구를 사용하여 트위터에서 트윗을 검색 할 수 있습니다.
저는 트위터에서 트윗에 태그를 지정할 수 있도록 스탠포드 NLP 태그를 사용했습니다. 이것은 텍스트 파일에 저장됩니다.
다음은 코드 내 다음 단계는 EntityTagged.txt에서 태그가 달린 트윗을 사용하고 긍정적 인 단어와 부정적인 단어의 문자열이를 비교하는 것입니다
public class TextTag {
public static void main(String[] args) throws IOException,
ClassNotFoundException {
String tagged;
// Initialize the tagger
MaxentTagger tagger = new MaxentTagger("taggers/english-left3words-distsim.tagger");
// The sample string
String sample = "Output Tagged";
//The tagged string
tagged = tagger.tagString(sample);
//output the tagged sample string onto your console
//System.out.println(tagged);
/*pick up some sentences from the file ouput.txt and store the output of
tagged sentences in another file EntityTagged.txt. */
FileInputStream fstream = new FileInputStream("Output.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
//we will now pick up sentences line by line from the file ouput.txt and store it in the string sample
while((sample = br.readLine())!=null)
{
//tag the string
tagged = tagger.tagString(sample);
FileWriter q = new FileWriter("EntityTagged.txt",true);
BufferedWriter out =new BufferedWriter(q);
//write it to the file EntityTagged.txt
out.write(tagged);
out.newLine();
out.close();
}
입니다.
나는 2 개의 텍스트 파일, 긍정적 인 단어의 목록과 부정적인 단어의 목록을 만들었고 나의 목표는 'EntityTagged.txt'파일의 10 개의 다른 태그가 달린 트윗을 positive.txt와 음수로 반복하는 것입니다. 단어 트윗이 양 또는 음이
내 최종 결과가 있어야하는 경우 그래서 내가 구별 할 수 나오면 .txt 인 파일을 찾을 수 있습니다
트윗 1 : 긍정적 인 트윗 2 : 부정적인 트윗 3 : 부정적인
등
순간, 나는 여기 내 5 분 알고리즘의 어떤 도움이 많이
을 이해할 수있을 것이다이당신에게
도움을 주셔서 대단히 감사합니다. 어떻게하면 긍정적 인 단어, 부정적인 단어 및 트윗을 위해 이미 작성한 텍스트 파일을 읽을 수 있습니까? – user3406318
GitHub에 대한 예제가 있습니다 : https://github.com/CoachEd/JavaExamples/tree/master/ReadTextFileExample. 이것은 텍스트 파일을 한 줄씩 읽습니다. 그런 다음 각 줄을 적절하게 구문 분석 할 수 있습니다. –