seboettg / citeproc-php

Full-featured CSL 1.0.1 processor for PHP
MIT License
75 stars 39 forks source link

Missing first letters in several words #88

Closed quartelmestre closed 4 years ago

quartelmestre commented 4 years ago

Please follow the general troubleshooting steps first:

Bug reports:

CiteProc 2.2.0, in an OJS-3.2.1-1 installation created from scratch, using git and composer, running under PHP 7.2 (tested under 7.2 and 7.3). Several citation styles are printing words without the first letter.

Correct output, using CSL associacao-brasileira-de-normas-tecnicas (our default style):

MARTINS, . V. M.; FERREIRA NETTO, . Retomada do tom médio após intervalos de sonoridade. Gradus - Revista Brasileira de Fonologia de Laboratório, Curitiba, v. 4, n. 2, p. 11-31, 2020. Disponível em: //gradusjournal.com/index.php/gradus/article/view/133. Acesso em: 13 jul. 2020.

Incorrect output, using chicago-author-date:

Martins, Marcus Vinicius Moreira, e Waldemar Ferreira Netto. 2020. “etomada o om médio após ntervalos e onoridade”. radus evista rasileira e onologia e Laboratório 4 (2). Curitiba:11-31. //gradusjournal.com/index.php/gradus/article/view/133.

I also note that there is an extra period in the author name when using associacao-brasileira-de-normas-tecnicas, and in both the URL is missing the protocol part at the start.

Used CSL stylesheet:

chicago-author-date (17th edition)

seboettg commented 4 years ago

Hi @quartelmestre! Thank you for this bug report. In order to reproduce the the faulty output, I need the raw input data in json format. Thank you in advance!

quartelmestre commented 4 years ago

Thanks for helping, Sebastian.

I'm not very handy with PHP, I hope that what I got is adequate. At the point where CiteProc is called in OJS code, I introduced a browser console dump of the data array. The result:

{
  "type": "article-journal",
  "id": 145,
  "title": "Estudo acústico sobre a dupla marcação de plural em adjetivos derivados em -oso(s) no português brasileiro",
  "container-title": "Gradus - Revista Brasileira de Fonologia de Laboratório",
  "publisher-place": "Curitiba",
  "abstract": "<p>Este artigo apresenta um estudo acústico sobre a dupla<br>marcac?a?o de plural em adjetivos derivados em *--osos* no portugue?s<br>brasileiro, observando possi?veis comportamentos metafo?nicos,<br>compreendidos como a alterac?a?o de timbre da vogal to?nica induzida pela<br>vogal postônica. Um experimento de produção com quatro condições de<br>teste foi realizado, duas com os adjetivos introduzidos em sintagmas<br>nominais objeto e duas com os adjetivos inseridos em sintagmas nominais<br>sujeito. Foram coletados dados de fala de quatro participantes do sexo<br>feminino de dois municípios do Estado de Sa?o Paulo. Com base na<br>Fonologia de Uso e na Teoria de Exemplares, observou-se que o fenômeno<br>metafônico se apresentou em maior número na primeira condição de teste,<br>na qual as palavras-alvo foram apresentadas pela primeira vez às<br>participantes. Nesta situação, a frequência de tipo tornou-se mais<br>significativa do que a própria frequência de ocorrência, uma vez que o<br>padrão no singular é o mais recorrente. Os resultados mostraram que a<br>dupla marcação de plural foi produzida em 75,52% das emisso?es. A<br>metafonia foi encontrada em 8,86% dos dados. Pelas análises acústicas,<br>em 14,58% das produções, foram verificadas vogais com qualidade<br>intermedia?ria entre a vogal aberta e a fechada, destacando o caráter<br>gradiente na produção das vogais, caro aos estudos baseados no uso. Por<br>fim, os resultados ainda mostraram que as mudanças sonoras foneticamente<br>motivadas, como a redução ou apagamento da vogal postônica [?], bem<br>como as mudanças sem motivação fonética, como a analogia ao tipo mais<br>frequente, atingiram tanto as palavras pouco frequentes quanto as muito<br>frequentes estabelecidas para o presente estudo.</p>",
  "container-title-short": "gradus",
  "volume": "4",
  "issue": "2",
  "section": "",
  "URL": "//gradusjournal.com/index.php/gradus/article/view/145",
  "accessed": {
    "raw": "2020-07-19"
  },
  "author": [
    {
      "family": "Belando",
      "given": "Mariane Garin"
    },
    {
      "family": "Seara",
      "given": "Izabel Christine"
    },
    {
      "family": "Agostinho",
      "given": "Ana Lívia"
    }
  ],
  "issued": {
    "raw": "2020-01-03"
  },
  "page": "32-58"
}
seboettg commented 4 years ago

Hi @quartelmestre, thanks for the metadata. I'm not familiar with OJS, but I assume that this metadata is what citeproc-php gets for rendering.

Based on this, I made a test case to compare expected result with the actual. The expected one is the result of the render process of citeproc-js using chicago-author-date with this metadata. I use citeproc-js as reference implementation.

Indeed, there are differences, but not what you described.

Result of citeproc-js

Belando, Mariane Garin, Izabel Christine Seara, and Ana Lívia Agostinho. 2020. “Estudo Acústico Sobre a Dupla Marcação de Plural Em Adjetivos Derivados Em -Oso(s) No Português Brasileiro.” Gradus - Revista Brasileira de Fonologia de Laboratório 4 (2): 32-58. //gradusjournal.com/index.php/gradus/article/view/145.

Result of citeproc-php

Belando, Mariane Garin, Izabel Christine Seara, and Ana Lívia Agostinho. 2020. “Estudo Acústico Sobre a Dupla marcação De Plural Em Adjetivos Derivados Em -oso(s) No Português Brasileiro”. Gradus - Revista Brasileira De Fonologia De Laboratório 4 (2): 32-58. //gradusjournal.com/index.php/gradus/article/view/145.

As you can see, there are differences between upper- & lower case on rendered container title. This is caused by <text variable="container-title" text-case="title" font-style="italic"/> in the chicago stylesheet.

Here an excerpt from CSL specs regarding title case:

Title case conversion (with text-case set to “title”) for English-language items is performed by:

For uppercase strings, the first character of each word remains capitalized. All other letters are lowercased. For lower or mixed case strings, the first character of each lowercase word is capitalized. The case of words in mixed or uppercase stays the same. In both cases, stop words are lowercased, unless they are the first or last word in the string, or follow a colon. The stop words are “a”, “an”, “and”, “as”, “at”, “but”, “by”, “down”, “for”, “from”, “in”, “into”, “nor”, “of”, “on”, “onto”, “or”, “over”, “so”, “the”, “till”, “to”, “up”, “via”, “with”, and “yet”.

In my understanding, this result of citeproc-php is not faulty with regard to the CSL specs.

It is possible that the missing first letters are caused by OJS?

quartelmestre commented 4 years ago

Indeed it is. I will investigate if the locale filtering is mangling either the input or the output. Thanks, Sebastian, I'll get back as soon as I can.

quartelmestre commented 4 years ago

Hi, Sebastian. No luck yet.

The relevant step in the OJS plugin is the call to CiteProc render function.

$citation = $citeProc->render(array($citationData), 'bibliography');

In my new test, I used the apa.csl style (APA 6th edition). I added a log function, and the modified code became this:

console_log( $citationData );
console_log( $tryLocale );
$citation = $citeProc->render(array($citationData), 'bibliography');
console_log( $citation );

The log from $citationData returned this:

{
  "type": "article-journal",
  "id": 133,
  "title": "Retomada do tom médio após intervalos de sonoridade",
  "container-title": "Gradus - Revista Brasileira de Fonologia de Laboratório",
  "publisher-place": "Curitiba",
  "abstract": "&lt;p style=&quot;-qt-block-indent: 0; text-indent: 0px; margin: 0px;&quot;&gt;A análise da média global das locuções é uma estratégia&lt;/p&gt;\r\n&lt;p style=&quot;-qt-block-indent: 0; text-indent: 0px; margin: 0px;&quot;&gt;para a avaliação da prosódia emocional. Esta pesquisa tem o propósito de&lt;/p&gt;\r\n&lt;p style=&quot;-qt-block-indent: 0; text-indent: 0px; margin: 0px;&quot;&gt;verificar se o Tom Médio pode ser referência para outras avaliações de&lt;/p&gt;\r\n&lt;p style=&quot;-qt-block-indent: 0; text-indent: 0px; margin: 0px;&quot;&gt;F0. De gravações de narrativas, extraíram-se o Tom Médio e o Tom Médio&lt;/p&gt;\r\n&lt;p style=&quot;-qt-block-indent: 0; text-indent: 0px; margin: 0px;&quot;&gt;móvel de F0 de sujeitos agrupados. Compararam-se os valores de&lt;/p&gt;\r\n&lt;p style=&quot;-qt-block-indent: 0; text-indent: 0px; margin: 0px;&quot;&gt;recuperação de F0 em relação a essas medidas quando ocorriam&lt;/p&gt;\r\n&lt;p style=&quot;-qt-block-indent: 0; text-indent: 0px; margin: 0px;&quot;&gt;interrupções de sonoridade na fala. A razão esperada seria 1. Ainda que&lt;/p&gt;\r\n&lt;p style=&quot;-qt-block-indent: 0; text-indent: 0px; margin: 0px;&quot;&gt;houvesse alguma diferenciação entre os grupos, as razões oscilaram entre&lt;/p&gt;\r\n&lt;p style=&quot;-qt-block-indent: 0; text-indent: 0px; margin: 0px;&quot;&gt;0,98 e 1,04, com desvio-padrão entre 0,04 e 0,05. Esses resultados&lt;/p&gt;\r\n&lt;p style=&quot;-qt-block-indent: 0; text-indent: 0px; margin: 0px;&quot;&gt;apontaram para o fato de que após interrupções de sonoridade, os&lt;/p&gt;\r\n&lt;p style=&quot;-qt-block-indent: 0; text-indent: 0px; margin: 0px;&quot;&gt;locutores tendem à recuperação dos valores do Tom Médio que antecediam&lt;/p&gt;\r\n&lt;p style=&quot;-qt-block-indent: 0; text-indent: 0px; margin: 0px;&quot;&gt;essa interrupção. Os resultados corroboram a hipótese de que o Tom Médio&lt;/p&gt;\r\n&lt;p style=&quot;-qt-block-indent: 0; text-indent: 0px; margin: 0px;&quot;&gt;é uma medida de referência segura para a avaliação das variações de F0.&lt;/p&gt;",
  "container-title-short": "gradus",
  "volume": "4",
  "issue": "2",
  "section": "",
  "URL": "//gradusjournal.com/index.php/gradus/article/view/133",
  "accessed": {
    "raw": "2020-07-20"
  },
  "author": [
    {
      "family": "Martins",
      "given": "Marcus Vinicius Moreira"
    },
    {
      "family": "Ferreira Netto",
      "given": "Waldemar"
    }
  ],
  "issued": {
    "raw": "2020-01-03"
  },
  "page": "11-31"
}

$tryLocale returned 'en-US'.

$citation returned

<div class="csl-bib-body">
  <div class="csl-entry">Martins, M. V. M., &#38; Ferreira Netto, W. (2020). Retomada do tom médio após intervalos de sonoridade. <i>radus evista rasileira e onologia e Laboratório</i>, <i>4</i>(2), 11-31. etrieved from //gradusjournal.com/index.php/gradus/article/view/133</div>
</div>

Any ideas?

seboettg commented 4 years ago

Do you observe this behavior with both PHP 7.2 and PHP 7.3? Seems to be an issue on your PHP environment, since I couldn't any find any incorrect result when trying to reproduce this. One idea: Missing multibyte support (https://www.php.net/manual/en/book.mbstring.php). please check if multibyte support is enabled. Create a phpinfo output and look for multibyte (https://www.php.net/manual/en/function.phpinfo.php).

quartelmestre commented 4 years ago

Right on target, Sebastian, I think it was indeed something in the PHP environment. mbstring was enabled, but I upgraded from PHP 7.2 to PHP 7.3 and tweaked some configuration options. This did the trick.

Thank you very much for your help.