次のステートメントを作成しようとしています: InvertedFile.invertedFile.add(d.getAccessionNumber(), d.getWords());
これにより、新しいinvertedListオブジェクトが作成され、リンクされたリスト(invertedfile)に追加されます。次のエラーが表示されます。
2 つのエラーが見つかりました: ファイル: C:\Users\Name\Database.java [行: 21] エラー: C:\Users\Name\Database.java:21: シンボル symbol が見つかりません: メソッド add(int,WordList) 場所: class java.util.LinkedList ファイル: C:\Users\Name\InvertedFile.java [行: 39]
エラー: C:\Users\Name\InvertedFile.java:39: シンボル symbol が見つかりません: メソッド add(int,java. lang.String) 場所: class java.util.LinkedList エラーの場所:
public int add( Document d ){
int accessNumber = d.getAccessionNumber();
//Stores document text in InvertedFile data structure
InvertedFile.invertedFile.add(d.getAccessionNumber(), d.getWords());
//Adds document to accessNumber index of LinkedList of documents
if (documentList.size()<accessNumber){
documentList.add(accessNumber,d);
docNumber++;
return accessNumber;
}
else return -1;
}
Inverted File クラス
import java.util.*;
public class InvertedFile implements InvertedFileInterface {
public static LinkedList<InvertedList> invertedFile = new LinkedList<InvertedList>();
public InvertedFile(){
}
//Takes in docAccessionNumber and WordList and updates/creates invertedList files for each word in wordlist
public boolean add(int docNumber, WordList w){
String words = w.toString();
StringTokenizer parseWords = new StringTokenizer(words);
//Checks to see if InvertedFile already contains invertedLists for the given words, if so adds docID to existing lists
while (parseWords.hasMoreTokens()){
String checkWord = parseWords.nextToken();
for (int k = 0; k<invertedFile.size()-1; k++){
InvertedList temp = invertedFile.get(k);
if (checkWord.equals(temp.getWord())){
temp.add(docNumber);
}
}
}
//Checks to see if invertedFile contains lists for given words, if not, makes a new one and adds docNumber to the list
String wordsToCheck = w.toString();
StringTokenizer processWords = new StringTokenizer(wordsToCheck);
while (processWords.hasMoreTokens()){
String word = processWords.nextToken();
Boolean notFound = true;
for (int k = 0; k<invertedFile.size()-1; k++){
if (word.equals(invertedFile.get(k).getWord())){
notFound = false;
}
}
if (notFound){
InvertedFile.invertedFile.add(docNumber, word);
}
}
Database.docNumber++;
return true;
}
public int numLists(){
return invertedFile.size();
}
public int numTokens(){
return invertedFile.size();
}
public InvertedList getInvertedList( String word ){
for (int k = 0; k<invertedFile.size()-1; k++){
if (word.equals(invertedFile.get(k).getWord())){
return invertedFile.get(k);
}
}
逆リスト クラス:
import java.util.*;
public class InvertedList implements InvertedListInterface {
public static LinkedList<Integer> documentsContainingWord = new LinkedList<Integer>();
public String targetWord;
public InvertedList( String word ){
String targetWord = word;
//Scans documents in database for word
for (int j = 1; j<=Database.documentList.size(); j++){
Document temp = Database.documentList.get(j);
WordList words = temp.getWords();
//If document wordList contains word, and LinkedList doesn't already have that doc listed, add to LinkedList
//Already sorted since processed from 1 to size
if (words.contains(word) && !documentsContainingWord.contains(temp.getAccessionNumber())){
documentsContainingWord.add(temp.getAccessionNumber());
}
}
}
//Creator method
public InvertedList(int docNumber, String word){
String targetWord = word;
documentsContainingWord.add(docNumber);
}
public String getWord(){
return targetWord;
}
//Adds docNumber to sorted position of LinkedList documentsContainingWord
public boolean add( int docNumber ){
//If document already in list, don't add
if (!documentsContainingWord.contains(docNumber)){
//Places number at sorted position on list
//If document should be placed at index 0 (has smallest accessionNumber)
if (docNumber<documentsContainingWord.get(0)){
return documentsContainingWord.offerFirst(docNumber);
}
//If document should be placed in middle
if (docNumber<documentsContainingWord.get(documentsContainingWord.size()) && docNumber>documentsContainingWord.get(0)){
int temp = 1;
int index = 0;
while (temp<docNumber){
temp = documentsContainingWord.get(index);
index++;
}
documentsContainingWord.add(index+1, docNumber);
return true;
}
//If document should be placed at end
if (docNumber>documentsContainingWord.get(documentsContainingWord.size())){
return documentsContainingWord.offerLast(docNumber);
}
//Else document number already in inverted list
else {
return false;
}
}
return false;
}
public LinkedList getList(){
return documentsContainingWord;
}
Thank you!!