[Solved] COMP249 Assignment3-BibCreator

$25

File Name: COMP249_Assignment3-BibCreator.zip
File Size: 282.6 KB

SKU: [Solved] COMP249 Assignment3-BibCreator Category: Tag:
5/5 - (1 vote)

The purpose of this assignment is to allow you practice Exception Handling, and File I/O, as well as other previous object-oriented concepts.

JavaScript Object Notation or JSON is a well-known, lightweight data-interchange format, which is easily readable/writable by humans [1][2]. It is also easy for machines to parse and generate. JSON is based on data objects consisting of attributevalue pairs and array data types. It is widely used for asynchronous browserserver communication, including as a replacement for XML in some AJAX-style systems. As such, many journals and scientific servers are supporting this format. This format is easily extendable. The following is a typical sample (modified from an existing IEEE paper).

@ARTICLE{

8247289,

author={J. Park and J. N. James and Q. Li and Y. Xu and W. Huang}, journal={IEEE Transactions on Vehicular Technology}, title={Optimal DASH-Multicasting over LTE}, year={2018}, volume={PP}, number={99}, pages={15-27}, keywords={Forward error correction;Long Term Evolution;Maintenance engineering;Multicast communication;Resource management;Static VAr compensators;Streaming media;DASH;LTE;convex optimization;eMBMS;multicasting}, doi={10.1109/TVT.2018.2789899}, ISSN={0018-9545},

month={January},

}

In JSON, the fields however do not need to be placed in specific order. For example, in the above example, you can have the number filed for instance, be written above the year field, and so on.

There are many parsers available for JSON developed in may programming language as library, API, etc. Mendeley [3] is one example that uses this format. With Mendeley you can create your own library from all articles that you have read so far and you can use them when you want to write an article. Consequently, this is very good for inserting the needed references on a published paper and managing them afterwards. In particular, such tools can import the article(s) information from a bibliography file (.bib) and generate the reference(s) in particular format according to the conference or journal publisher standard.

For example, the representation of this file in IEEE format would be (this is a slightly simplified version than the actual one; however you need to follow this format for the scope of this assignment):

  1. Park, J. N. James, Q. Li, Y. Xu, W. Huang. Optimal DASH-Multicasting over LTE, IEEE Transactions on Vehicular Technology, vol. PP, no. 99, p. 15-27, January 2018.

Or in ACM format would be:

[1] J. Park et al. 2018. Optimal DASH-Multicasting over LTE. IEEE Transactions on Vehicular Technology. PP, 99 (2018), 15-27. DOI:https://doi.org/10.1109/TVT.2018.2789899.

And finally, in Nature Journal (NJ), which is one of the most famous journals in natural science, would be

  1. Park & J. N. James & Q. Li & Y. Xu & W. Huang. Optimal DASH-Multicasting over LTE. IEEE Transactions on Vehicular Technology. PP, 15-27(2018).

You should have a very detailed look at these formats to see how they are mapped from the original record of the article.

In this assignment, you will be designing and implementing an alternative tool (to the existing ones), called BibliographyFactory. The main task of this tool is read and process a given .bib file (which has one or more articles) and create 3 different files with the correct reference formats for IEEE, ACM and NJ.

In short, you are given 10 files, called Latex1.bib to Latex10.bib. You BibliographyFactory application will need to read all 10 input files (in one execution), determine whether each of these files is valid or not (details given below). If a file is valid, then BibliographyFactory will create 3 different files based on the articles in this file, one for IEEE format, one for ACM format and the last for NJ format. To distinguish our application from other existing similar software, we will call these files IEEEi.json, ACMi.json, and NJi.json (although in fact, the created files contain the references to the articles, and not json records!), where i is the Latex file #. For instance, Latex3.bib will result in the creation of 3 files called: IEEE3.json, ACM3.json and NJ3.json. If a file is invalid, then none of the 3 output reference files (for this invalid file) is created. So, in best case, BibliographyFactory execution will result in the creation of 30 output files if all given Latex files are valid, and in worst case it will create 0 files (when all 10 input files are invalid).

The fine details of what you need to do and how your BibliographyFactory should work are given below.

  1. For the purpose of this assignment, and to provide little simplifications, the following should be assumed in relation to the input files and the articles (records) in these input file:
    1. Each file may have one or more articles; the number is unknown before processing, and your code must assume that;
    2. An article starts with @ARTICLE followed by the body of the article (between { and

}). It is assumed that all articles have enclosing bodies;

  1. Inside each of these articles, there exists few fields; i.e. author, volume, year, etc. These fields are assumed to always start with the field name, followed by an = sign and a { character. For instance: pages={ , month= , etc.
  2. It also assumed that each of the bodies of these fields have a closing character for its body. In specific, it is assumed that each of these fields end with },;
  3. For simplicity, it is also assumed that there is a doi field, which maps to https://doi.org/
  4. The order of the article is NOT important. i.e., it is okay to have any of these fields above or below other fields;
  5. It is also assumed that empty lines can be there within the body of the articles, as well as between different articles;
  6. HOWEVER (read carefully), any of the input files may have some of these fields as empty; i.e. number={}, title={}, etc. This is what we classify as an Invalid File. In other words, for a file to be valid, the file cannot have an empty field at any of its articles. Below is an image of an invalid file.

Figure 1. Example of an Invalid Input File

  1. Write an exception class called FileInvalidException The class should have sufficient constructors allow:
  2. A default error message Error: Input file cannot be parsed due to missing information

(i.e. month={}, title={}, etc.) to be stored in the thrown object; and

  1. The passing of any different error message if desired. This is actually the constructor that you will be using throughout the assignment (see Figure 3 below).
  1. In the main() method of the BibilographyFactory class, attempt to open all 10 input files (Latex1.bib to Latex10.bib) for reading. You need to use the Scanner class for the reading these files. If any of these files does not exist, the program must display an error message indicating Could not open input file xxxxx for reading. Please check if file exists! Program will terminate after closing any opened files., and then exits. You MUST however, close all opened files before exiting the program. For example, if bib does not exist, then the following image shows the behavior of the program.

Figure 2. Example of Program Termination One of the Input Files does not Exist

  1. If all 10 input files can successfully be opened, the program will attempt to open/create all 30 output files (IEEE1.json to IEEE10.json, ACM1.json to ACM10.json, and NJ1.json to NJ10.json). You need to use PrintWriter to open these output files. If any of these output files cannot be created, then you must:
    1. Display a message to the user indicating which file could not be opened/created;
    2. Delete all other created output files (if any). That is, if you cannot create all of these output files, then you must clean the directory by deleting all other created files;
    3. Close all opened input files; then exit the program.

If you reach this step, then all 10 input files have been opened and all 30 output files have also been created (however, they are surely empty).

  1. Write a method (you should take advantage of static throughout the entire assignment!) called processFilesForValidation. This method will represent the core engine for processing the input files and creating the output ones. You can pass any needed parameters to this method, and the method may return any needed information. This method however must NOT declare any exceptions. In other words, all needed handling of any exceptions that may occur within this method, must be handled by the method. In specific:
    1. The method should work on the already opened files;
    2. A method must process each of these files to find out whether it is valid or not;
    3. If a file is valid, then the method must create the proper records for each of the 3 formats

(IEEE, ACM and NJ) and store them in these files;

  1. If a file is invalid, then the method must stop the processing of this file only, throws FileInvalidException to display the exception error message, then display a message indicating which file was detected as invalid, and where the first problem in that file was detected (See Figure 3). The corresponding output file MUST then be deleted;
  2. The method will then continue with the processing of the following file.

For instance, let us assume that the given input files (these files can be any files and they are not restricted to the ones provided with the assignment; in fact, the marker will execute your assignment with different files; so your code must work correctly for any given files) have 3 invalid files, Latex3.bib, Latex4.bib and Latex8.bib. Your program must detect these invalid files and show the following:

Figure 3. Example of Processing Number of Invalid Files and Particular Fields are Indicated

  1. Again, once the processing is done, all unsuccessfully created files MUST be deleted. Here is how the directory would look like at this point based on the above senario:

Figure 4. Contents of Current Directory after above processing Example

  1. Finally, at this point, the program needs to ask the user to enter the name of one of the created output files to display. If the user enters an invalid name, a FileNotFoundException should be thrown; however, the user is allowed a second and final chance to enter another name. If this second attempt also fails, then the program exits. Figure 5 and Figure 6 below show the behavior of this program. You must however apply the following:

If the entered file is valid, then your program must open this file for reading using the BufferedReader class. Do not use the Scanner class to read the file for that task.

  1. Finally, here are some general information:
    1. It may assist you greatly if you take advantage of static variables/attributes and static attributes throughout the assignment; in fact, it is not necessary to utilize other aspects such as Inheritance, Polymorphism, etc.
    2. You must exactly match the format and look of the expected output files. For instance, use & or et al. for the authors as expected, follow the exact order/format of the contents, use vol. instead of volume when as expected. In other words, a small difference in the expected output will surely result in mark deduction;
    3. For the processing of the authors, you may want to use the StringTokenizer class;
    4. You should minimize opening and closing the files as much as possible; a better mark will be given for that;
    5. Do not use any external libraries or existing software to produce what is needed; that will directly result in a 0 mark!
    6. Again, your program must work for any input files. The files provided with this assignment are only one possible version, and must not be considered as the general case when writing your code.
    7. To make sure that the requirments are very clear to you, Figure 7 given an image (partially) of a sample input file, and Figures 8, 9 & 10 show the output of this sample file in the 3 formats. These files are also provided with the assignment.

Figure 5. Example of Double-Fault for Displaying an Output File

Figure 6. Example of Displaying the Contents of a Successfully Created Output File

Figure 7. Example of a Sample Bib Input File Partial Image

Figure 8. The Created IEEE File for the above Sample Bib File

Figure 9. The Created ACM File for the above Sample Bib File

Figure 10. The Created Natural Journal File for the above Sample Bib File

General Guidelines When Writing Programs:

  • Include the following comments at the top of your source codes

//

// Assignment (include number)

// Question: (include question/part number, if applicable)

// Written by: (include your name and student ID)

//

  • In a comment, give a general explanation of what your program does. As the programming questions get more complex, the explanations will get lengthier.
  • Include comments in your program describing the main steps in your program.
  • Display a welcome message which includes your name(s).
  • Display clear prompts for users when you are expecting the user to enter data from the keyboard.
  • All output should be displayed with clear messages and in an easy to read format.
  • End your program with a closing message so that the user knows that the program has terminated.

JavaDoc Documentation:

Documentation for your program must be written in javaDoc. In addition, the following information must appear at the top of each file:

Name(s) and ID(s) (include full names and IDs)

COMP249

Assignment # (include the assignment number) Due Date (include the due date for this assignment)

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] COMP249 Assignment3-BibCreator
$25