Skip to content

Commit

Permalink
Cleaning the title of the article to keep only the name of the player
Browse files Browse the repository at this point in the history
  • Loading branch information
JorickPepin committed Aug 18, 2022
1 parent 391adc9 commit 7c7a8ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
34 changes: 19 additions & 15 deletions src/recordsnbawiki/packLogic/Header.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,46 @@
* @author Jorick
*/
public class Header {

private String header;

private final RealGM realGM;
private final ESPN espn;

private final String playerName;

public Header(RealGM realGM, ESPN espn, String playerName) throws FileNotFoundException, IOException {
this.realGM = realGM;
this.espn = espn;
this.playerName = playerName;

generateHeader();
}

/**
* Crée et retourne l'en-tête comprend le titre de section, le modèle,
* l'introduction et les références
*
* @throws FileNotFoundException
*/
private void generateHeader() throws FileNotFoundException, IOException {

BufferedReader br;

if (realGM.getADesRecordsEnPlayoffs()) { // le header n'est pas le même si le joueur a des records en playoffs ou non
try {
br = new BufferedReader (new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("data/header_playoffs.txt"), StandardCharsets.UTF_8));

if (realGM.getADesRecordsEnPlayoffs()) { // le header n'est pas le même si le joueur a des records en playoffs
// ou non
try {
br = new BufferedReader(new InputStreamReader(
this.getClass().getClassLoader().getResourceAsStream("data/header_playoffs.txt"),
StandardCharsets.UTF_8));
} catch (NullPointerException e) {
throw new FileNotFoundException("header_playoffs.txt");
}
} else {
try {
br = new BufferedReader (new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("data/header_noplayoffs.txt"), StandardCharsets.UTF_8));
br = new BufferedReader(new InputStreamReader(
this.getClass().getClassLoader().getResourceAsStream("data/header_noplayoffs.txt"),
StandardCharsets.UTF_8));
} catch (NullPointerException e) {
throw new FileNotFoundException("header_noplayoffs.txt");
}
Expand All @@ -59,7 +64,7 @@ private void generateHeader() throws FileNotFoundException, IOException {
sb.append(System.lineSeparator());
line = br.readLine();
}

String template = sb.toString();

br.close();
Expand All @@ -80,7 +85,7 @@ private void generateHeader() throws FileNotFoundException, IOException {

this.header = template;
}

/**
* Permet de savoir si une élision est nécessaire devant un nom
*
Expand All @@ -90,8 +95,7 @@ private void generateHeader() throws FileNotFoundException, IOException {
private boolean necessiteElision(char c) {
return "AEIOUaeiouHh".indexOf(c) != -1;
}



public String getContenu() {
return this.header;
}
Expand Down
2 changes: 1 addition & 1 deletion src/recordsnbawiki/packLogic/wikidata/Wikidata.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public Map<String, String> retrieveEntity(String playerId) throws WikidataExcept

data.put("realgmId", realgmId);
data.put("espnId", espnId);
data.put("name", name);
data.put("name", name.split(" \\(")[0]); // Franz Wagner (basket-ball) -> Franz Wagner

return data;

Expand Down

0 comments on commit 7c7a8ff

Please sign in to comment.